From 86409d2960691b5497e71a7cfb56d9bb2d1a9860 Mon Sep 17 00:00:00 2001 From: enoch85 Date: Sat, 26 Sep 2026 14:53:58 +0000 Subject: [PATCH] update.sh: only turn the last exit into a reboot Enabling reboots after automatic updates ran sed "s|exit|...|g" on update.sh, which also replaced the early exit after the lower case check. With reboots on, "update.sh MINOR" then scheduled a reboot and ran a full (major) update instead of exiting. Disabling automatic updates deletes the lines with shutdown, so afterwards the early exit was gone completely and the same happened without reboots. Only replace the exit on the last line, so a wrong argument always exits. The updater downloads update.sh on every run and reapplies the reboot edit, so existing VMs pick this up automatically. --- addons/automatic_updates.sh | 2 +- menu/main_menu.sh | 2 +- nextcloud_update.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/automatic_updates.sh b/addons/automatic_updates.sh index 3c0f33fe30..906dbac994 100644 --- a/addons/automatic_updates.sh +++ b/addons/automatic_updates.sh @@ -42,7 +42,7 @@ mkdir -p "$VMLOGS"/updates crontab -u root -l | { cat; echo "0 $AUT_UPDATES_TIME * 1-12 6 $SCRIPTS/update.sh minor >> $VMLOGS/updates/update-\$(date +\%Y-\%m-\%d_\%H:\%M).log 2>&1"; } | crontab -u root - if yesno_box_yes "Do you want to reboot your server after every update? *recommended*" then - sed -i "s|exit|/sbin/shutdown -r +10|g" "$SCRIPTS"/update.sh + sed -i '$ s|^exit$|/sbin/shutdown -r +10|' "$SCRIPTS"/update.sh echo "exit" >> "$SCRIPTS"/update.sh fi diff --git a/menu/main_menu.sh b/menu/main_menu.sh index ec3d4a9265..574076b7d3 100644 --- a/menu/main_menu.sh +++ b/menu/main_menu.sh @@ -81,7 +81,7 @@ To upgrade to the latest version, please run: 'sudo bash $SCRIPTS/update.sh' fro download_script STATIC update if [ -n "$REBOOT_SET" ] then - sed -i "s|exit|/sbin/shutdown -r +10|g" "$SCRIPTS"/update.sh + sed -i '$ s|^exit$|/sbin/shutdown -r +10|' "$SCRIPTS"/update.sh fi do_the_update else diff --git a/nextcloud_update.sh b/nextcloud_update.sh index c4ea49416b..74a1967a12 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -276,7 +276,7 @@ chmod +x "$SCRIPTS"/update.sh # Restore reboot if it was enabled if [ "$REBOOT_ENABLED" = 1 ] then - sed -i "s|exit|/sbin/shutdown -r +10|g" "$SCRIPTS"/update.sh + sed -i '$ s|^exit$|/sbin/shutdown -r +10|' "$SCRIPTS"/update.sh echo "exit" >> "$SCRIPTS"/update.sh fi