You are here

Disable pop-ups for an unattended/non-interactive apt-get install in Ubuntu/Debian

Submitted by Druss on Mon, 2014-08-25 17:37

So, here I was writing a script that would automate the installation of a package in Ubuntu 14.04 and all was going swimmingly. Until I ran it. You know how some apt-get installs sometimes involve a technicolor pop-up that asks you for stuff? Well, those pop-ups interrupted my script which didn't proceed further. After much digging, I found that there are a couple of solutions for this:

  1. One trick is to set a flag that disables the interactive pop-ups. This can be done like so:
    $ export DEBIAN_FRONTEND=noninteractive
    $ aptitude -y install foopackage
    $ aptitude -y install barpackage
    $ unset DEBIAN_FRONTEND

    IOW, set the flag, perform the install, disable the flag. Disabling the flag can also be done by running dpkg-reconfigure debconf.

    An alternative (and something of a shortcut) is to simply use (all in one line):
    DEBIAN_FRONTEND=noninteractive aptitude -y install foopackage

    Rather nifty :)

  2. The other option is relatively more involved and is useful when you want to populate fields rather than accept the defaults.
    $ echo "foo-server foo-server/root_password password ABCDE" | debconf-set-selections
    $ echo "foo-server foo-server/root_password_again password ABCDE" | debconf-set-selections
    $ apt-get -y install foo-server

    The above is what is used to run through the prompts during a typical MySQL installation. IOW, foo=mysql. To get the list of variables for other packages, you will need to install debconf-utils and then run the appropriately named debconf-get-selection foo-server to get details about the structure of the foo-server package.

(BTW, the -y switch in the apt-get and aptitude statements is short for "assume yes for everything" and ensures that we accept the default choice when apt throws up any prompts.)

Hope this helps!

Comments

It's realy amazing! Thanx a lot!