From f8dfb7722fe8f1b190450b2c9f83d16df8fa5fcb Mon Sep 17 00:00:00 2001 From: piterpunk Date: Wed, 29 Dec 2021 17:51:30 -0300 Subject: File to flag if the system needs restart Creates /var/run/needs_restarting file if any "critical" package got upgraded. As the /var/run/ is ephemeral and renewed each boot, the file disappears after reboot. The packages that flags the restart need are: - kernel-generic, kernel-huge: as a new kernel needs a restart to be running. - glibc, glibc-solibs: Restart is the only way to be sure that all running binaries are using the new glibc. - eudev, elogind, dbus: those provides some very basic system services. - openssl, openssl-solibs: security bugs on those libs are dangerous, the reboot makes sure that all running binaries are using the newer version. --- files/core-functions.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/files/core-functions.sh b/files/core-functions.sh index 463a190..56314e9 100644 --- a/files/core-functions.sh +++ b/files/core-functions.sh @@ -1318,6 +1318,28 @@ for slackpkg to work properly. fi } +# Checks if a critical package were upgraded by Slackpkg. +# The /var/run/needs_restarting file contains the list of upgraded +# packages. +# +# The file only is created if /var/run filesystem type is tmpfs so +# the reboot will clean it +function needs_restarting() { + if [ "$(stat -f -c %T /var/run/)" = "tmpfs" ]; then + find $ROOT/var/log/packages/ -cnewer $TMPDIR/timestamp -type f \( \ + -name "kernel-generic-[0-9]*" -o \ + -name "kernel-huge-[0-9]*" -o \ + -name "openssl-solibs-[0-9]*" -o \ + -name "openssl-[0-9]*" -o \ + -name "glibc-[0-9]*" -o \ + -name "aaa_glibc-solibs-[0-9]*" -o \ + -name "eudev-[0-9]*" -o \ + -name "elogind-[0-9]*" -o \ + -name "dbus-[0-9]*" \) | \ + awk -F/ '{ print $NF }' >> $ROOT/var/run/needs_restarting + fi +} + function remove_pkg() { local i @@ -1342,6 +1364,7 @@ function upgrade_pkg() { for i in $SHOWLIST; do getpkg $i upgradepkg Upgrading done + needs_restarting } function install_pkg() { -- cgit v1.2.3