add reboot if set when updating the update script

This commit is contained in:
Daniel Hansson 2021-08-06 00:28:55 +02:00 committed by GitHub
parent 3391b71cb1
commit d2e320cab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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