This commit is contained in:
buanet
2020-07-28 09:58:19 +02:00
parent a78610eb68
commit bc4fd8349f
2 changed files with 57 additions and 1 deletions

View File

@@ -90,7 +90,7 @@ echo "$(printf -- '-%.0s' {1..60})"
echo ' '
# Installing additional packages and setting uid/gid
if [ "$packages" != "" ] || [ $(cat /etc/group | grep 'iobroker:' | cut -d':' -f3) != $setgid ] || [ $(cat /etc/passwd | grep 'iobroker:' | cut -d':' -f3) != $setuid ]
if [ "$packages" != "" ] || [ $(cat /etc/group | grep 'iobroker:' | cut -d':' -f3) != $setgid ] || [ $(cat /etc/passwd | grep 'iobroker:' | cut -d':' -f3) != $setuid ] || [ -f /opt/.firstrun ]
then
if [ "$packages" != "" ]
then
@@ -110,6 +110,13 @@ then
echo "Done."
echo ' '
fi
if [ -f /opt/.firstrun ]
then
echo "Registering maintenance-mode script as command."
echo "alias maintenance-mode=\'/opt/scripts/maintenance-mode.sh\'" >> /root/.bashrc
echo "Done."
echo ' '
fi
else
echo "Nothing to do here."
echo ' '

View File

@@ -0,0 +1,49 @@
#!/bin/bash
if [ "$1" == "status" ]
then
if [ "$cat /opt/iobroker/.docker_config/.healthcheck" == "maintenance" ]
then
echo 'Maintenance mode is ON.'
exit 0
elif [ "$cat /opt/iobroker/.docker_config/.healthcheck" != "maintenance" ]
then
echo 'Maintenance mode is OFF.'
exit 0
fi
elif [ "$1" == "on" ]
then
echo 'This will stop ioBroker and enable maintenance mode for this container.'
read -p 'Continue? Type yes or no: ' A
if [ "$A" == "y" ] || [ "$A" == "yes" ]
then
echo 'Enabling maintenance mode...'
echo "maintenance" > /opt/iobroker/.docker_config/.healthcheck
echo 'Done.'
sleep 2
echo 'Stopping ioBroker...'
pkill -u iobroker
echo 'Done.'
exit 0
else
exit 0
fi
elif [ "$1" == "off" ]
then
echo 'Depending of the restart policy of this container, this will force it to stop (and restart) immediately.'
echo 'Maintenance mode will be disabled after the restart.'
read -p 'Continue? Type yes or no: ' A
if [ "$A" == "y" ] || [ "$A" == "yes" ]
then
echo "Disabling maintenance mode and forcing container to stop/ restart..."
echo "maintenance" > /opt/iobroker/.docker_config/.healthcheck
pkill -u root
exit 0
else
exit 0
fi
else
echo 'Invalid command. Please try again.'
fi
exit 0