From d2e320cab776b430c94f7bdf416d6501fc6f794c Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 6 Aug 2021 00:28:55 +0200 Subject: [PATCH] add reboot if set when updating the update script --- menu/main_menu.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/menu/main_menu.sh b/menu/main_menu.sh index 1709e745..d0b2f50a 100644 --- a/menu/main_menu.sh +++ b/menu/main_menu.sh @@ -47,6 +47,8 @@ case "$choice" in "Update Nextcloud major") if [ -f "$SCRIPTS"/update.sh ] then + # Check if automated updates are set + REBOOT_SET=$(grep -rc "shutdown -r" "$SCRIPTS"/update.sh) # Check if it's older than 60 days (60 seconds * 60 minutes * 24 hours * 60 days) if [ "$(stat --format=%Y "$SCRIPTS"/update.sh)" -le "$(( $(date +%s) - ((60*60*24*60)) ))" ] then @@ -54,8 +56,14 @@ case "$choice" in then print_text_in_color "$ICyan" "Downloading the latest update script..." download_script STATIC update + if [ -n "$REBOOT_SET" ] + then + sed -i "s|exit|/sbin/shutdown -r +1|g" "$SCRIPTS"/update.sh + fi chmod +x "$SCRIPTS"/update.sh bash "$SCRIPTS"/update.sh + else + bash "$SCRIPTS"/update.sh fi else bash "$SCRIPTS"/update.sh @@ -70,6 +78,8 @@ case "$choice" in "Update Nextcloud minor") if [ -f "$SCRIPTS"/update.sh ] then + # Check if automated updates are set + REBOOT_SET=$(grep -rc "shutdown -r" "$SCRIPTS"/update.sh) # Check if it's older than 60 days (60 seconds * 60 minutes * 24 hours * 60 days) if [ "$(stat --format=%Y "$SCRIPTS"/update.sh)" -le "$(( $(date +%s) - ((60*60*24*60)) ))" ] then @@ -77,8 +87,14 @@ case "$choice" in then print_text_in_color "$ICyan" "Downloading the latest update script..." download_script STATIC update + if [ -n "$REBOOT_SET" ] + then + sed -i "s|exit|/sbin/shutdown -r +1|g" "$SCRIPTS"/update.sh + fi chmod +x "$SCRIPTS"/update.sh bash "$SCRIPTS"/update.sh minor + else + bash "$SCRIPTS"/update.sh minor fi else bash "$SCRIPTS"/update.sh minor