Search code examples
shellubuntudebianiptables

Prevent prompt when `apt install -y iptables persistent` on Debian/Ubuntu


I'm making a script of auto-starting server.

when I exec following command, I get blue screen prompt. What the name of the scereen?

apt install -y iptables-persistent

The goal what I wanna do is one of following

  • prevent this prompt to raise
  • send command (ENTER) to this prompt

Of course, 2-times manual ENTER solve this problem, but I want to automate this step.

what I tried:

  • apt install -y iptables-persistent > /dev/null
  • apt install -y iptables-persistent $ echo "\n"
  • expect -c "spawn apt install -y iptables-persistent expect\"\(.*\)\" send --\"\n\""

[ENVIRONMENT]

  • Debian 9
  • Ubuntu 18.04

Solution

  • Use this command to fully automate the installation

    echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
    echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
    sudo apt-get -y install iptables-persistent