X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=filesystem%2Fusr%2Flocal%2Fbin%2Fmyupgrade;fp=filesystem%2Fusr%2Flocal%2Fbin%2Fzelous-unattended-reboot;h=3df5f0e12211b67707eb8616ed27bbd687254c65;hp=a4672f38b9e6f1034f0157f46fbf5fdfd9f5b786;hb=343a048be4b32d18540c6531048d2b9a006774ae;hpb=50e3ebaf4941651899a3b52b5245052c3f4ed725 diff --git a/filesystem/usr/local/bin/zelous-unattended-reboot b/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 a4672f3..3df5f0e 100755 --- a/filesystem/usr/local/bin/zelous-unattended-reboot +++ b/filesystem/usr/local/bin/myupgrade @@ -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