Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a shell script to automatically configure new Ubuntu virtual machines for my purposes. I would like this script to install and enable unattended-upgrades, but I cannot figure out how to do so without user interaction.

The usual way to enable upgrades is dpkg-reconfigure unattended-upgrades, but of course that is interactive. The noninteractive front end avoids asking any questions at all, and the text front end seems bound and determined to do its I/O with the tty and not with stdin/stdout.

share|improve this question
    
I've not used this tool before, but it looks like enabling it writes a 1 to the two lines in the file /etc/apt/apt.conf.d/20auto-upgrades. If you manually write that file will it work? –  mfisch Nov 17 '12 at 3:43
add comment

2 Answers 2

Just make a copy of /etc/apt/apt.conf.d/20auto-upgrades after configuring it the way you like, and drop that into place on your target machine. You could embed it in your script, or you could rsync or wget it in from a server, or whatever.

So basically your script might do something like this:

apt-get install unattended-upgrades
wget -O /etc/apt/apt.conf.d/20auto-upgrades http://myserver.mytld/confs/20auto-upgrades
/etc/init.d/unattended-upgrades restart

There's really no reason to monkey with the dpkg-reconfigure script at all.

If you don't want to fetch the conf file from a remote server, it's VERY very short and simple - the default version, which fetches and installs security updates only, looks like this:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

So you could also pretty easily just echo those lines into the 20auto-upgrades file directly.

share|improve this answer
add comment

According to me , You have to Write your own cron script that calls aptitude for this purpose, Check out third topic Write your own cron script that calls aptitude in this documentation.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.