X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=filesystem%2Fusr%2Flocal%2Fbin%2Fmyupgrade;h=e762246d09756f9c12c9d3042e0d433c7a69c304;hb=4d0dc703ef2e62cd16ea84f27456f6f50f74baa3;hp=b990fbb70c080db20d91855c4c1d46931cd54bc1;hpb=b1c29177fe76f8f2a557f7f36c987df3ef2a6cb4;p=distro-setup diff --git a/filesystem/usr/local/bin/myupgrade b/filesystem/usr/local/bin/myupgrade index b990fbb..e762246 100755 --- a/filesystem/usr/local/bin/myupgrade +++ b/filesystem/usr/local/bin/myupgrade @@ -4,8 +4,16 @@ 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 +source /usr/local/lib/err +pre="${0##*/}:" +m() { printf "$pre %s\n" "$*"; "$@"; } +e() { printf "$pre %s\n" "$*"; } +err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $pre: $*" >&2; } + +if [[ $EUID == 0 ]]; then + err "run as nonroot" + exit 1 +fi hn=$(hostname -f) source /a/bin/bash_unpublished/source-state @@ -13,8 +21,19 @@ if [[ $HOSTNAME == "$MAIL_HOST" || $hn == li.b8.nz ]]; then exit 0 fi -/usr/sbin/checkrestart -v -i bash -b /a/bin/distro-setup/checkrestart-blacklist | \ - sed '/^Found 0 processes using old versions of upgraded files$/d' >/var/log/checkrestart.log +l() { + "$@" |& systemd-cat -t myupgrade +} +l /a/bin/buildscripts/tor-browser +l /a/bin/buildscripts/go +l /a/bin/buildscripts/rust +l /a/bin/buildscripts/misc +l go get -u mvdan.cc/fdroidcl + +cmd="sudo /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 @@ -23,7 +42,8 @@ if [[ -s /var/log/checkrestart.log ]]; then done for x in {30..1}; do if ! fuser /var/lib/dpkg/lock &> /dev/null; then - /sbin/reboot + echo "pid $PID. unattended upgrade, rebooting now" | pee cat "wall -n" + sudo /sbin/reboot exit 0 fi echo "pid $PID. unattended upgrade reboot waiting 10 seconds for dpkg lock" | wall -n