apt-get update non interactive

David picture David · Oct 27, 2015 · Viewed 15k times · Source

I'm trying to make an update fully non interactive.(on ubuntu 14.04.3 LTS) I thought it will be easy with this type of command:

export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get upgrade -q -y --force-yes && apt-get dist-upgrade -q -y --force-yes

but no... I always have a question like:

Configuration file '/etc/cloud/cloud.cfg'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** cloud.cfg (Y/I/N/O/D/Z) [default=N] ?

So do you known how I can accept the default value automatically ?

Answer

ryanpcmcquen picture ryanpcmcquen · Oct 27, 2015

You need to pass some dpkg options to your commands, for instance:

export DEBIAN_FRONTEND=noninteractive
apt-get update && 
    apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes &&
    apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -q -y --force-yes

On a side note, I would recommend using only dist-upgrade, you will eventually end up with broken dependencies if you use upgrade.