Updating your OS is obviously super-important. But it’s also quite annoying and tedious, especially if you’re in charge of a number of systems. In about 99% it’s a monkey’s job, as it just involves variations of
Usually, nothing interesting happens, you just need to wait for the command to finish.
The potential consequences in the 1% cases lets us usually swallow the bitter pill and play the monkey. The Problem is, that in some cases there is a an update that involves a modification of some configuration file that contains some adjustments of you. Let’s say you configured a daemon to listen at a specific port of your server, but in the new version they changed the syntax of the config file. That can hardly be automatised. Leaving the old version of the config will break the software, deploying the new version will dispose your settings. Thus, human interaction is required…
At least I do not dare to think about a solution on how to automatise that. But we could …
Detect the 1% and Automatise the 99%
What do we need do to prevent the configuration conflict? We need to find out which software will be updated and see if we modified one of the configuration files:
Update the package list
Updating your systems package list can be considered safe:
The command downloads a list of available packages from the repositories and compares it with the list of packages installed on your system. Based on that, your update-systems knows which packages can be upgraded.
Find out which software will be updated.
The list of upgradeable packages can be obtained by doing a dry-run. The
--simulate flag shows us what will be done without touching the system,
-y answers every question with yes without human interaction, and
-v gives us a parsable list. For example, from a random system:
That tells us, the new versions of the tools
ndiff will be installed. Capturing that is simple, we basically just need to grep for
Check if we modified corresponding configuration files
To get the configuration files of a specific package we can ask the dpkg subsystem, for example for a dhcp client:
Every non-empty line contains a configuration file’s name and the corresponding md5 sum of the contents as delivered by the repository. That means, we just need to
md5sum all the files on our system and compare the hashes to see if we modified the file:
Now we should have everything we need to compile it into a script that we can give to cron :)
The safe-upgrade script
I developed a tiny tool that can be downloaded from GitHub.. It consists of two files:
/etc/cron.daily/safeupdatescript.shis the actual acript that does the update and safe-upgrade of the system.
/etc/default/deb-safeupgradecan be used to overwrite the settings (hostname, mail address of the admin, etc) for a system. If it exists, the other script will
In addition, there is a Debian package available from my apt-repository. Just install it with:
and let me know if there are any issues.
The mentioned figure
99% is just a guess and may vary. It strongly depends on your operating system, version, and the software installed ;-)
- aptitude (12) ,
- debian (35) ,
- job (7) ,
- security (29) ,
- simplification (16) ,
- ubuntu (9) ,
- update (8)