bunch of updates and fixes
[distro-setup] / filesystem / usr / local / bin / myupgrade
index 3df5f0e12211b67707eb8616ed27bbd687254c65..712047a684e3ffc1de594b79d1eeefc1bae27924 100755 (executable)
@@ -13,13 +13,19 @@ if [[ $HOSTNAME == "$MAIL_HOST" || $hn == li.b8.nz ]]; then
   exit 0
 fi
 
-if [[ $(/usr/sbin/checkrestart | wc -l) != 1 ]]; then
+cmd="$s /usr/sbin/checkrestart -p"
+if [[ $($cmd | sed '/^Found 0 processes using old versions of upgraded files$/d' | wc -l) != 0 ]]; then
+  $cmd -v | pee cat "wall -n"
+fi
+
+if [[ -s /var/log/checkrestart.log ]]; then
   for x in {30..1}; do
     echo "pid $PID. unattended upgrade, rebooting in $((x*10)) seconds" | wall -n
     sleep 10
   done
   for x in {30..1}; do
     if ! fuser /var/lib/dpkg/lock &> /dev/null; then
+      echo "pid $PID. unattended upgrade, rebooting now" | pee cat "wall -n"
       /sbin/reboot
       exit 0
     fi