So I use automatic updates (Update Manager > Preferences > Automation) in Linux Mint 19.2 Cinnamon and I was looking for a way to get notified if a reboot is required after installing updates. I found out that updates that require a reboot will trigger the creation of the file
/var/run/reboot-requiredand the names of the packages in question will be stored in
So I wrote a little script that checks if the first file exists. If so, it will trigger a notification that lists the package(s) that require(s) a reboot:
Code: Select all
if [ -f /var/run/reboot-required ]; then export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep cinnamon-sessio)/environ) MAINUSER=$(id -nu 1000) su $MAINUSER -c "notify-send -i mintupdate \"Reboot required\" \"$(cat /var/run/reboot-required.pkgs)\""& fi
cinnamon-sessiowith gnome-session and maybe there's also mate-session or xfce-session? Also keep in mind the 15 character limit for process names or it won't return the process ID (that's why there is no n at the end of cinnamon-sessio).
For portability, this script assumes a regular single user installation where the main user usually has a uid of 1000. Of course you can also hardcode the username of the logged in user that needs to receive the notifications if you like/require.
The line that sends the actual notification ends in & (forks the notify-send process to the background) because otherwise the script (and I guess the anacron script that called this one too) won't finish until the notification has been closed or dismissed.
Put this script in
/etc/cron.daily/and it will check daily if a reboot is required.
I thought I'd put this out there, seeing as I searched these forums and didn't get any relevant results before I came up with this solution myself. I've used this script for a while now and it works like a charm!