I have installed a (x)Ubuntu 14.04 on a friend's PC. Automatic updates are set to "download and automatic install updates".
The problem is that, after some months of use, he unknowingly shuts down his PC before packages upgrade complete. That leads to broken dependencies/packages, which leads to updating being affected and the need to run sudo dpkg --configure -a
Is it possible to make Ubuntu wait for the updates to complete before PC shutdown or reboot like Windows does to ensure that there will never be broken packages and that his PC will remain updated automatically?
Best Answer
Molly-Guard is a program for exactly this purpose; it requires you do a small amount of setup, and have
/usr/sbin
before/sbin
in your$PATH
.Otherwise, according to this the exact details are highly dependent on the GUI / DE's implementation. Since we know your friend is using Xubuntu, this narrows it, but without recompiling Xfce with this support built-in (which would create further issues) it seems very hard.
According to my bountiful research, you can theoretically just replace
/sbin/shutdown
with a script that checks if an apt job is up and executessudo shutdown -c
orsudo init 2
to cancel a running shutdown andwait
for it to exit, but I'm not sure how robust this is.According to this, you could just make it hard for the user to shutdown, instead of hooking a script.
Finally, as outlined here, you could install
unattended-upgrades
over whatever system you're using for autoupdates now, and make sure it exits before shutdown as detailed in this answer.There are many options, all of which are varying levels of unreliable, but I think the best one, which solves what I think is, to some extent, an underlying X / Y Problem at play here, is this:
Use
crontab
to make his computer rundpkg --configure -a
on every boot.@LovesTha: For your purpose, I recommend
unattended-upgrades
, or perhaps Molly-Guard.