From 4cfbdb32d6d38a5ab493bb5be083541f1677b36a Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 30 Jan 2022 11:43:14 +0100 Subject: [PATCH] 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. --- bundles/apt/files/check_unattended_upgrades | 12 ++++++++---- bundles/apt/files/upgrade-and-reboot | 13 ++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/bundles/apt/files/check_unattended_upgrades b/bundles/apt/files/check_unattended_upgrades index ba0044f..479e828 100644 --- a/bundles/apt/files/check_unattended_upgrades +++ b/bundles/apt/files/check_unattended_upgrades @@ -22,12 +22,16 @@ case "$exitcode" in exit 1 ;; reboot) - echo "Upgrades require a reboot, but automatic rebooting is disabled" - exit 1 ;; 0) - echo "OK" - exit 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" diff --git a/bundles/apt/files/upgrade-and-reboot b/bundles/apt/files/upgrade-and-reboot index 6c382f1..ab99a10 100644 --- a/bundles/apt/files/upgrade-and-reboot +++ b/bundles/apt/files/upgrade-and-reboot @@ -44,18 +44,13 @@ then exit 1 fi -if [[ -f /var/run/reboot-required ]] +if [[ -f /var/run/reboot-required ]] && [[ "$auto_reboot_enabled" == "True" ]] then - if [[ "$auto_reboot_enabled" == "False" ]] + if [[ -n "$reboot_mail_to" ]] then - echo "reboot" > "$statusfile" - else - if [[ -n "$reboot_mail_to" ]] - then - date | mail -s "SYSREBOOTNOW $nodename" "$reboot_mail_to" - fi - systemctl reboot + date | mail -s "SYSREBOOTNOW $nodename" "$reboot_mail_to" fi + systemctl reboot fi echo "upgrade-and-reboot for node $nodename is DONE"