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