2020-11-10 08:50:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-11-21 09:30:05 +00:00
|
|
|
statusfile="/var/tmp/unattended_upgrades.status"
|
2020-11-10 08:50:20 +00:00
|
|
|
if ! [[ -f "$statusfile" ]]
|
|
|
|
then
|
|
|
|
echo "Status file not found"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
|
|
|
mtime=$(stat -c %Y $statusfile)
|
2020-12-10 21:11:28 +00:00
|
|
|
now=$(date +%s)
|
|
|
|
if (( $now - $mtime > 60*60*24*8 ))
|
2020-11-10 08:50:20 +00:00
|
|
|
then
|
|
|
|
echo "Status file is older than 8 days!"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
|
|
|
exitcode=$(cat $statusfile)
|
|
|
|
case "$exitcode" in
|
|
|
|
abort_ssh)
|
|
|
|
echo "Upgrades skipped due to active SSH login"
|
|
|
|
exit 1
|
|
|
|
;;
|
2022-01-04 14:14:39 +00:00
|
|
|
reboot)
|
|
|
|
echo "Upgrades require a reboot, but automatic rebooting is disabled"
|
|
|
|
exit 1
|
|
|
|
;;
|
2020-11-10 08:50:20 +00:00
|
|
|
0)
|
|
|
|
echo "OK"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Last exitcode was $exitcode"
|
|
|
|
exit 2
|
|
|
|
;;
|
|
|
|
esac
|