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
8 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
11 source /a
/bin
/bash_unpublished
/source-state
12 if [[ $HOSTNAME == "$MAIL_HOST" ||
$hn == li.b8.nz
]]; then
16 /usr
/sbin
/checkrestart
-v -i bash
-b /a
/bin
/distro-setup
/checkrestart-blacklist | \
17 sed '/^Found 0 processes using old versions of upgraded files$/d' >/var
/log
/checkrestart.log
19 if [[ -s /var
/log
/checkrestart.log
]]; then
21 echo "pid $PID. unattended upgrade, rebooting in $((x*10)) seconds" | wall
-n
25 if ! fuser
/var
/lib
/dpkg
/lock
&> /dev
/null
; then
29 echo "pid $PID. unattended upgrade reboot waiting 10 seconds for dpkg lock" | wall
-n
32 echo "pid $PID. dpkg locked for 5 minutes, automatic reboot failed" | pee
cat "wall -n"