automatically reboot on services needsrestart doesnt handle
authorIan Kelling <ian@iankelling.org>
Wed, 16 Feb 2022 05:01:18 +0000 (00:01 -0500)
committerIan Kelling <ian@iankelling.org>
Wed, 16 Feb 2022 05:01:18 +0000 (00:01 -0500)
filesystem/usr/local/bin/myupgrade

index e5401dc836675ab54f9aafb31490ca5cf08ed7e7..ee1890f4415b72a42840d85eebdd3587d0718731 100755 (executable)
@@ -38,16 +38,9 @@ myreboot() {
 }
 
 
-if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
-  ksta=$(needrestart -b | sed -n 's/NEEDRESTART-KSTA: *//p');
-  case $ksta in
-    1) : ;;
-    [023]) myreboot ;;
-    *) err error: unknown kernel status ;;
-  esac
-fi
-
-# needsrestarts automatic restarts failed.
 if ! out=$(/sbin/needrestart -p 2>&1); then
   e "$out"
+  if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
+    myreboot
+  fi
 fi