shellcheck, better automated upgrades
[distro-setup] / filesystem / usr / local / bin / myupgrade
similarity index 56%
rename from filesystem/usr/local/bin/zelous-unattended-reboot
rename to filesystem/usr/local/bin/myupgrade
index a4672f38b9e6f1034f0157f46fbf5fdfd9f5b786..3df5f0e12211b67707eb8616ed27bbd687254c65 100755 (executable)
@@ -1,4 +1,18 @@
 #!/bin/bash
+# Copyright (C) 2019 Ian Kelling
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
+
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
+hn=$(hostname -f)
+source /a/bin/bash_unpublished/source-state
+if [[ $HOSTNAME == "$MAIL_HOST" || $hn == li.b8.nz ]]; then
+  exit 0
+fi
+
 if [[ $(/usr/sbin/checkrestart | wc -l) != 1 ]]; then
   for x in {30..1}; do
     echo "pid $PID. unattended upgrade, rebooting in $((x*10)) seconds" | wall -n