From e20f66ada682545db195e90079d20bfd3a99f617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Germann?= Date: Mon, 20 Dec 2021 23:15:50 +0100 Subject: [PATCH 1/3] Update CHANGELOG.md --- debian/scripts/maintenance.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/debian/scripts/maintenance.sh b/debian/scripts/maintenance.sh index 37bfe9d..de3e5ab 100644 --- a/debian/scripts/maintenance.sh +++ b/debian/scripts/maintenance.sh @@ -21,10 +21,10 @@ display_help() { echo '' echo "COMMANDS" echo "------------------" - echo " status > gives the current state of maintenance mode" + echo " status > reports the current state of maintenance mode" echo " on > switches mantenance mode ON" - echo " off > switches mantenance mode OFF and shuts down/ restarts container" - echo " upgrade > will put container to maintenance mode and upgrade iobroker" + echo " off > switches mantenance mode OFF and shuts down or restarts container" + echo " upgrade > will put container to maintenance mode and upgrade ioBroker" echo " help > shows this help" echo '' echo "OPTIONS" @@ -101,11 +101,11 @@ switch_off() { if [ $(cat /opt/scripts/.docker_config/.healthcheck) == 'maintenance' ] && [ "$autoconfirm" == "no" ] # maintenance mode ON / autoconfirm = no then echo 'You are now going to deactivate maintenance mode for this container.' - echo 'Depending on the restart policy, your container will be stopped/ restarted immediately.' + echo 'Depending on the restart policy, your container will be stopped or restarted immediately.' read -p 'Do you want to continue [yes/no]? ' A if [ "$A" == "y" ] || [ "$A" == "Y" ] || [ "$A" == "yes" ] then - echo 'Deactivating maintenance mode and forcing container to stop/ restart...' + echo 'Deactivating maintenance mode and forcing container to stop or restart...' echo "stopping" > /opt/scripts/.docker_config/.healthcheck pkill -u root echo 'Done.' @@ -116,9 +116,9 @@ switch_off() { elif [ $(cat /opt/scripts/.docker_config/.healthcheck) == 'maintenance' ] && [ "$autoconfirm" == "yes" ] # maintenance mode ON / autoconfirm = yes then echo 'You are now going to deactivate maintenance mode for this container.' - echo 'Depending on the restart policy, your container will be stopped/ restarted immediately.' + echo 'Depending on the restart policy, your container will be stopped or restarted immediately.' echo 'This command was already confirmed by -y or --yes option.' - echo 'Deactivating maintenance mode and forcing container to stop/ restart...' + echo 'Deactivating maintenance mode and forcing container to stop or restart...' echo "stopping" > /opt/scripts/.docker_config/.healthcheck pkill -u root echo 'Done.' @@ -135,7 +135,7 @@ upgrade() { echo 'You are now going to upgrade your js-controller.' echo 'As this will change data in /opt/iobroker, make sure you have a backup!' echo 'During the upgrade process the container will automatically switch into maintenance mode and stop ioBroker.' - echo 'Depending of the restart policy, you container will be stoped/ restarted automatically after the upgrade.' + echo 'Depending of the restart policy, your container will be stopped or restarted automatically after the upgrade.' read -p 'Do you want to continue [yes/no]? ' A if [ "$A" == "y" ] || [ "$A" == "Y" ] || [ "$A" == "yes" ] then @@ -152,7 +152,7 @@ upgrade() { iobroker upgrade self sleep 1 echo 'Done.' - echo 'Container will be stopped/ restarted in 5 seconds...' + echo 'Container will be stopped or restarted in 5 seconds...' sleep 5 echo "stopping" > /opt/scripts/.docker_config/.healthcheck pkill -u root @@ -165,7 +165,7 @@ upgrade() { echo 'You are now going to upgrade your js-controller.' echo 'As this will change data in /opt/iobroker, make sure you have a backup!' echo 'During the upgrade process the container will automatically switch into maintenance mode and stop ioBroker.' - echo 'Depending of the restart policy, you container will be stoped/ restarted automatically after the upgrade.' + echo 'Depending of the restart policy, your container will be stopped or restarted automatically after the upgrade.' echo 'This command was already confirmed by -y or --yes option.' echo 'Activating maintenance mode...' echo "maintenance" > /opt/scripts/.docker_config/.healthcheck @@ -180,7 +180,7 @@ upgrade() { iobroker upgrade self sleep 1 echo 'Done.' - echo 'Container will be stopped/ restarted in 5 seconds...' + echo 'Container will be stopped or restarted in 5 seconds...' sleep 5 echo "stopping" > /opt/scripts/.docker_config/.healthcheck pkill -u root From 6ccf196ae29b81a5191b149fda9eedc6763a4235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Gro=C3=9F?= Date: Thu, 23 Dec 2021 17:34:38 +0100 Subject: [PATCH 2/3] Whitespace fixes --- debian/scripts/maintenance.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/debian/scripts/maintenance.sh b/debian/scripts/maintenance.sh index de3e5ab..3b81aa8 100644 --- a/debian/scripts/maintenance.sh +++ b/debian/scripts/maintenance.sh @@ -30,8 +30,8 @@ display_help() { echo "OPTIONS" echo "------------------" echo " -y|--yes > confirms the used command without asking" - echo " -h|--help > shows this help" - echo '' + echo " -h|--help > shows this help" + echo '' exit 0 } @@ -131,7 +131,7 @@ switch_off() { # upgrade js-controller upgrade() { if [ "$autoconfirm" == "no" ] - then + then echo 'You are now going to upgrade your js-controller.' echo 'As this will change data in /opt/iobroker, make sure you have a backup!' echo 'During the upgrade process the container will automatically switch into maintenance mode and stop ioBroker.' @@ -161,8 +161,8 @@ upgrade() { exit 0 fi elif [ "$autoconfirm" == "yes" ] - then - echo 'You are now going to upgrade your js-controller.' + then + echo 'You are now going to upgrade your js-controller.' echo 'As this will change data in /opt/iobroker, make sure you have a backup!' echo 'During the upgrade process the container will automatically switch into maintenance mode and stop ioBroker.' echo 'Depending of the restart policy, your container will be stopped or restarted automatically after the upgrade.' @@ -198,7 +198,7 @@ for i in "$@"; do reverse="$i $reverse" done -# checking the arguments +# checking the arguments for i in $reverse; do case $i in help|-h|--help) From 296ff3c61275cad60369e652cf20941bf1492af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Gro=C3=9F?= Date: Thu, 23 Dec 2021 17:39:05 +0100 Subject: [PATCH 3/3] Deduplicate upgrade code paths with or without --yes option --- debian/scripts/maintenance.sh | 69 +++++++++++++---------------------- 1 file changed, 25 insertions(+), 44 deletions(-) diff --git a/debian/scripts/maintenance.sh b/debian/scripts/maintenance.sh index 3b81aa8..11aa914 100644 --- a/debian/scripts/maintenance.sh +++ b/debian/scripts/maintenance.sh @@ -130,62 +130,43 @@ switch_off() { # upgrade js-controller upgrade() { + echo 'You are now going to upgrade your js-controller.' + echo 'As this will change data in /opt/iobroker, make sure you have a backup!' + echo 'During the upgrade process the container will automatically switch into maintenance mode and stop ioBroker.' + echo 'Depending of the restart policy, your container will be stopped or restarted automatically after the upgrade.' + if [ "$autoconfirm" == "no" ] then - echo 'You are now going to upgrade your js-controller.' - echo 'As this will change data in /opt/iobroker, make sure you have a backup!' - echo 'During the upgrade process the container will automatically switch into maintenance mode and stop ioBroker.' - echo 'Depending of the restart policy, your container will be stopped or restarted automatically after the upgrade.' read -p 'Do you want to continue [yes/no]? ' A if [ "$A" == "y" ] || [ "$A" == "Y" ] || [ "$A" == "yes" ] then - echo 'Activating maintenance mode...' - echo "maintenance" > /opt/scripts/.docker_config/.healthcheck - sleep 1 - echo 'Done.' - echo 'Stopping ioBroker...' - pkill -u iobroker - sleep 1 - echo 'Done.' - echo 'Upgrading js-controller...' - iobroker update - iobroker upgrade self - sleep 1 - echo 'Done.' - echo 'Container will be stopped or restarted in 5 seconds...' - sleep 5 - echo "stopping" > /opt/scripts/.docker_config/.healthcheck - pkill -u root - exit 0 + : # Continue. else exit 0 fi elif [ "$autoconfirm" == "yes" ] then - echo 'You are now going to upgrade your js-controller.' - echo 'As this will change data in /opt/iobroker, make sure you have a backup!' - echo 'During the upgrade process the container will automatically switch into maintenance mode and stop ioBroker.' - echo 'Depending of the restart policy, your container will be stopped or restarted automatically after the upgrade.' echo 'This command was already confirmed by -y or --yes option.' - echo 'Activating maintenance mode...' - echo "maintenance" > /opt/scripts/.docker_config/.healthcheck - sleep 1 - echo 'Done.' - echo 'Stopping ioBroker...' - pkill -u iobroker - sleep 1 - echo 'Done.' - echo 'Upgrading js-controller...' - iobroker update - iobroker upgrade self - sleep 1 - echo 'Done.' - echo 'Container will be stopped or restarted in 5 seconds...' - sleep 5 - echo "stopping" > /opt/scripts/.docker_config/.healthcheck - pkill -u root - exit 0 fi + + echo 'Activating maintenance mode...' + echo "maintenance" > /opt/scripts/.docker_config/.healthcheck + sleep 1 + echo 'Done.' + echo 'Stopping ioBroker...' + pkill -u iobroker + sleep 1 + echo 'Done.' + echo 'Upgrading js-controller...' + iobroker update + iobroker upgrade self + sleep 1 + echo 'Done.' + echo 'Container will be stopped or restarted in 5 seconds...' + sleep 5 + echo "stopping" > /opt/scripts/.docker_config/.healthcheck + pkill -u root + exit 0 } ########################################