2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
5 if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
7 source /usr
/local
/lib
/err
9 m
() { printf "$pre %s\n" "$*"; "$@"; }
10 e
() { printf "$pre %s\n" "$*"; }
11 err
() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $pre: $*" >&2; }
13 if [[ $EUID == 0 ]]; then
19 source /a
/bin
/bash_unpublished
/source-state
22 "$@" |
& systemd-cat
-t myupgrade
24 l
/a
/bin
/buildscripts
/rust
27 for pkg
in xorg wayland
; do
28 if dpkg
-s -- $x |
& grep -Fx "Status: install ok installed" &> /dev
/null
; then
35 l
/a
/bin
/buildscripts
/tor-browser
36 l
/a
/bin
/buildscripts
/misc
40 source /a
/bin
/distro-setup
/path-add-function
41 export GOPATH
=$HOME/go
43 path-add
/usr
/local
/go
/bin
44 l
/a
/bin
/buildscripts
/go
45 l go get
-u mvdan.cc
/fdroidcl
47 cmd
="sudo /usr/sbin/checkrestart -p"
48 if [[ $
($cmd |
sed '/^Found 0 processes using old versions of upgraded files$/d' |
wc -l) != 0 ]]; then
49 $cmd -v | pee
cat "wall -n"
52 # no automatic reboot for these hosts
53 if [[ $HOSTNAME == "$MAIL_HOST" ||
$hn == li.b8.nz
]]; then
57 if [[ -s /var
/log
/checkrestart.log
]]; then
59 echo "pid $PID. unattended upgrade, rebooting in $((x*10)) seconds" | sudo wall
-n
63 if ! fuser
/var
/lib
/dpkg
/lock
&> /dev
/null
; then
64 echo "pid $PID. unattended upgrade, rebooting now" | pee
cat "sudo wall -n"
68 echo "pid $PID. unattended upgrade reboot waiting 10 seconds for dpkg lock" | sudo wall
-n
71 echo "pid $PID. dpkg locked for 5 minutes, automatic reboot failed" | pee
cat "sudo wall -n"