Skip to content

Commit

Permalink
enhance maintenance script
Browse files Browse the repository at this point in the history
  • Loading branch information
buanet committed Apr 25, 2023
1 parent a04f210 commit 7a45595
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Changelog

### v8.1.0-beta.2 (coming soon)
* prohibit restore when startup script is still running
* extend time before restart after restore is done
* v8.1.0-beta.1 (14.04.2023)
* enhance github actions
* enhance log output of maintenance script on restore ([#333](https://github.com/buanet/ioBroker.docker/issues/333))
Expand Down
25 changes: 19 additions & 6 deletions debian/scripts/maintenance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ maintenance_enabled() {
[[ -f "$healthcheck" && "$(cat "$healthcheck")" == maintenance ]]
}

# check status starting
check_starting() {
[[ -f "$healthcheck" && "$(cat "$healthcheck")" == starting ]]
}

# display maintenance status
maintenance_status() {
if maintenance_enabled; then
Expand Down Expand Up @@ -221,6 +226,8 @@ restart_container() {
# restore iobroker
restore_iobroker() {
echo 'You are now going to perform a restore of your iobroker.'
echo 'During the restore process, the container will automatically switch into maintenance mode and stop ioBroker.'
echo 'Depending on the restart policy, your container will be stopped or restarted automatically after the restore.'

if [[ "$autoconfirm" != yes ]]; then
local reply
Expand All @@ -235,11 +242,17 @@ restore_iobroker() {
echo 'This command was already confirmed by the -y or --yes option.'
fi

echo -n 'Stopping ioBroker...'
stop_iob
if check_starting > /dev/null; then
echo "Startup script is still running."
echo "Please check container log and wait until ioBroker is sucessfully started."
echo "Then try again."
return 1
fi

# fixing permission errors during restore
#chown -R $setuid:$setgid /opt/iobroker/backup
if ! maintenance_enabled > /dev/null; then
autoconfirm=yes
enable_maintenance
fi

echo -n "Restoring ioBroker... "
set +e
Expand All @@ -263,8 +276,8 @@ restore_iobroker() {
echo "!!!! You can view installation process by taking a look at ioBroker log. !!!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
sleep 10
echo 'Container will be stopped or restarted in 5 seconds...'
sleep 5
echo 'Container will be stopped or restarted in 10 seconds...'
sleep 10
echo 'stopping' > "$healthcheck"
pkill -u root
}
Expand Down

0 comments on commit 7a45595

Please sign in to comment.