bundlewrap/bundles/apt/files/check_unattended_upgrades
Franziska Kunsmann 4cfbdb32d6
Some checks failed
kunsi/bundlewrap/pipeline/head There was a failure building this commit
bundles/apt: check for "reboot required" in icinga check only
This avoids the need to manually adjust the status file after a reboot of
the server.
2022-01-30 11:43:14 +01:00

40 lines
753 B
Bash

#!/bin/bash
statusfile="/var/tmp/unattended_upgrades.status"
if ! [[ -f "$statusfile" ]]
then
echo "Status file not found"
exit 3
fi
mtime=$(stat -c %Y $statusfile)
now=$(date +%s)
if (( $now - $mtime > 60*60*24*8 ))
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
;;
reboot)
;;
0)
if [[ -f /var/run/reboot-required ]]
then
echo "OK, but updates require a reboot"
exit 1
else
echo "OK"
exit 0
fi
;;
*)
echo "Last exitcode was $exitcode"
exit 2
;;
esac