Difference between revisions of "Unattended-upgrades"

From MythTV Official Wiki
Jump to: navigation, search
m
Line 34: Line 34:
  
 
I discovered the above by looking in /var/lib/apt/lists/ppa.launchpad.net_mythbuntu_0.29_ubuntu_dists_xenial_InRelease, and picking out the Origin: line.
 
I discovered the above by looking in /var/lib/apt/lists/ppa.launchpad.net_mythbuntu_0.29_ubuntu_dists_xenial_InRelease, and picking out the Origin: line.
 +
 +
Obviously and finally, /usr/bin/shutdown-after-upgrade.sh has to be used in mythtv-setup or mythwelcome -s as the command to shutdown the machine.

Revision as of 13:30, 27 May 2018

When enabling unattended-upgrades on a machine running MythTV, a decision has to be made when to allow the upgrades to take place. If mythbackend were to be upgraded whilst a recording was taking place, the recording would be stopped.

If the machine runs 24/7, then, for instance, the output of mythtv-status could be parsed and the upgrade allowed if the next recording was not planned in the next x minutes.

If the machine is allowed to shutdown and wakeup between recordings, then the obvious solution is to upgrade before shutting down.

However, when I simply enabled the "upgrade on shutdown" option in unattended-upgrades, the shutdown was not delayed, and thus took place in the middle of the upgrade, requiring the upgrade to be fixed manually.

Therefore, I created the following at /usr/bin/shutdown-after-upgrade.sh

#!/bin/bash
/usr/bin/mythtv-status --email root --email-only-on-alert
# if we upgraded something, then reboot
/usr/bin/unattended-upgrade -d | grep -q 'No packages'
if [ $? -eq 0 ]
then
 # Give it 60s to email the log from unattended-upgrades
 /sbin/shutdown -h
else
 /sbin/shutdown -r
fi

I found that some upgrading some packages (particularly kernel packages) messed up the wake-up time in the BIOS, so the above restarts the machine if anything was upgraded. Obviously, if it were clear that only kernel packages caused this problem, then the script could be refined appropriately.

I added /usr/bin/shutdown-after-upgrade.sh to /etc/sudoers

The above initially only worked for packages from the Ubuntu repositories. In order to include the packages from the MythTV PPA on launchpad, I editted /etc/apt/apt.conf.d/50unattended-upgrades and added

"LP-PPA-mythbuntu-0.29:${distro_codename}";

to

Unattended-Upgrade::Allowed-Origins

I discovered the above by looking in /var/lib/apt/lists/ppa.launchpad.net_mythbuntu_0.29_ubuntu_dists_xenial_InRelease, and picking out the Origin: line.

Obviously and finally, /usr/bin/shutdown-after-upgrade.sh has to be used in mythtv-setup or mythwelcome -s as the command to shutdown the machine.