Merge ~brian-murray/update-notifier:livepatch into update-notifier:master

Proposed by Brian Murray
Status: Merged
Approved by: William Wilson
Approved revision: e98569e77b1aa2f2859a72debdf7dd3470625404
Merged at revision: e98569e77b1aa2f2859a72debdf7dd3470625404
Proposed branch: ~brian-murray/update-notifier:livepatch
Merge into: update-notifier:master
Diff against target: 34 lines (+23/-0)
1 file modified
data/notify-reboot-required (+23/-0)
Reviewer Review Type Date Requested Status
William Wilson Pending
Review via email: mp+413982@code.launchpad.net

Description of the change

canonical-livepatch provides its own motd message regarding whether or not a reboot is required and if the only reason a reboot is required is due to a kernel update then we should use canonical-livepatch's message. Otherwise we should show the update-notifier reboot required message.

To post a comment you must log in.
Revision history for this message
William Wilson (jawn-smith) wrote :

Looks good to me. I mocked up a fake /snap/bin/canonical-livepath to run through some different scenarios and it works as expected.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/data/notify-reboot-required b/data/notify-reboot-required
2index f2ecd7b..ed9985b 100644
3--- a/data/notify-reboot-required
4+++ b/data/notify-reboot-required
5@@ -22,6 +22,29 @@ if [ "$0" = "/etc/kernel/postinst.d/update-notifier" ]; then
6 DPKG_MAINTSCRIPT_PACKAGE=linux-base
7 fi
8
9+KERNEL_UPGRADED=0
10+# Prefer showing the canonical-livepatch reboot message if one is required
11+if [ -f "/snap/bin/canonical-livepatch" ]; then
12+ # k-u-r returns 1 if livepatch isn't enabled or if a reboot isn't required
13+ kur_rc=$(/snap/bin/canonical-livepatch kernel-upgrade-required 2> /dev/null)
14+ if [ $? -eq 0 ]; then
15+ exit 0;
16+ elif [ $? -eq 1 ]; then
17+ # status returns 1 if livepatch isn't enabled
18+ status_rc=$(/snap/bin/canonical-livepatch status 2> /dev/null)
19+ if [ $? -eq 0 ]; then
20+ KERNEL_UPGRADED=1
21+ fi
22+ fi
23+fi
24+
25+# while a reboot isn't required for the new kernel it might be for another package
26+if [ $KERNEL_UPGRADED -eq 1 ]; then
27+ if [ "$(echo $DPKG_MAINTSCRIPT_PACKAGE | cut -c1-5)" = "linux" ]; then
28+ exit 0;
29+ fi
30+fi
31+
32 # Wake the applet up
33 echo "*** $(eval_gettext "System restart required") ***" > /var/run/reboot-required
34 echo "$DPKG_MAINTSCRIPT_PACKAGE" >> /var/run/reboot-required.pkgs

Subscribers

People subscribed via source and target branches