mirror of
https://github.com/buanet/ioBroker.docker.git
synced 2025-12-17 18:39:01 +02:00
Compare commits
4 Commits
v9.0.1
...
v9.1.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf87667fc0 | ||
|
|
375d192c7c | ||
|
|
4738e035b5 | ||
|
|
814cfae657 |
@@ -1,5 +1,12 @@
|
||||
## Changelog
|
||||
|
||||
### v9.1.0-beta.1 (03.11.2023)
|
||||
* improve maintenance command by symlinking ([#390](https://github.com/buanet/ioBroker.docker/issues/390))
|
||||
* fix restore/ adding backup file selection ([#394](https://github.com/buanet/ioBroker.docker/issues/394))
|
||||
* fix calling iob start|stop with parameters
|
||||
* enhance logging in iobroker_startup.sh
|
||||
* add error handling for user scripts
|
||||
|
||||
### v9.0.1 (10.10.2023)
|
||||
* fix issue with avahi setup ([#384](https://github.com/buanet/ioBroker.docker/issues/384); [#385 by @z1r0](https://github.com/buanet/ioBroker.docker/pull/385))
|
||||
* add silent cleanup to setup_avahi.sh
|
||||
|
||||
@@ -39,27 +39,48 @@ iob_diag () {
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" = "fix" ]; then # call iobroker fixer
|
||||
iob_fix
|
||||
elif [ "$1" = "node fix" ]; then # call iobroker node fixer
|
||||
echo "The execution of this command is blocked as your ioBroker is running inside a Docker container!"
|
||||
echo "To fix any issues with nodejs, please pull the latest version of the Docker image and recreate your container."
|
||||
elif [ "$1" = "diag" ]; then # call iobroker diag script
|
||||
iob_diag
|
||||
elif [ "$1" = "start" ] || [ "$1" = "stop" ] || [ "$1" = "restart" ]; then # block execution of iobroker start | stop | restart
|
||||
echo "The execution of this command is blocked as your ioBroker is running inside a Docker container!"
|
||||
echo "For more details see ioBroker Docker image docs (https://docs.buanet.de/iobroker-docker-image/docs/) or use the maintenance script 'maintenance --help'."
|
||||
elif [ "$1" = "m" ] || [ "$1" = "maint" ] || [ "$1" = "maintenance" ]; then # call iobroker maintenance script
|
||||
# run iobroker maintenance script
|
||||
iob_maint() {
|
||||
shift
|
||||
if [ "$(id -u)" -eq 0 ]; then # check for execution as root
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
gosu iobroker bash /opt/scripts/maintenance.sh "$@"
|
||||
else
|
||||
bash /opt/scripts/maintenance.sh "$@"
|
||||
fi
|
||||
else # passing all other parameters to iobroker.js
|
||||
if [ "$(id -u)" -eq 0 ]; then # check for execution as root
|
||||
}
|
||||
|
||||
# pass parameters and run iobroker.js
|
||||
iob_run() {
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
gosu iobroker node /opt/iobroker/node_modules/iobroker.js-controller/iobroker.js "$@"
|
||||
else
|
||||
node /opt/iobroker/node_modules/iobroker.js-controller/iobroker.js "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" = "fix" ]; then
|
||||
# call iobroker fixer
|
||||
iob_fix
|
||||
elif [ "$1" = "node fix" ]; then
|
||||
# call iobroker node fixer
|
||||
echo "The execution of this command is blocked as your ioBroker is running inside a Docker container!"
|
||||
echo "To fix any issues with nodejs, please pull the latest version of the Docker image and recreate your container."
|
||||
elif [ "$1" = "diag" ]; then
|
||||
# call iobroker diag script
|
||||
iob_diag
|
||||
elif [ "$1" = "start" ] || [ "$1" = "stop" ] || [ "$1" = "restart" ]; then
|
||||
# block execution of iobroker start | stop | restart but pass start | stop for adapters
|
||||
if [ ! "$2" ]; then
|
||||
echo "The execution of this command is blocked as your ioBroker is running inside a Docker container!"
|
||||
echo "For more details see ioBroker Docker image docs (https://docs.buanet.de/iobroker-docker-image/docs/) or use the maintenance script 'maintenance --help'."
|
||||
else
|
||||
# passing all other parameters to iobroker.js but check for execution as root
|
||||
iob_run "$@"
|
||||
fi
|
||||
elif [ "$1" = "m" ] || [ "$1" = "maint" ] || [ "$1" = "maintenance" ]; then
|
||||
# call iobroker maintenance script but check for execution as root
|
||||
iob_maint "$@"
|
||||
else
|
||||
# passing all other parameters to iobroker.js but check for execution as root
|
||||
iob_run "$@"
|
||||
fi
|
||||
|
||||
@@ -133,11 +133,7 @@ if [[ -f /opt/.docker_config/.first_run ]]; then
|
||||
if [[ "$offlinemode" = "true" ]]; then
|
||||
echo "OFFLINE_MODE is \"true\". Skipping Linux package updates on first run."
|
||||
else
|
||||
if bash /opt/scripts/setup_packages.sh -update; then
|
||||
echo " "
|
||||
else
|
||||
echo "Error: Updating failed."
|
||||
fi
|
||||
if ! bash /opt/scripts/setup_packages.sh -update; then echo "Failed."; fi
|
||||
fi
|
||||
echo " "
|
||||
# Installing packages from ENV
|
||||
@@ -145,18 +141,14 @@ if [[ -f /opt/.docker_config/.first_run ]]; then
|
||||
echo "PACKAGES is set, but OFFLINE_MODE is \"true\". Skipping Linux package installation."
|
||||
elif [[ "$packages" != "" ]]; then
|
||||
echo "PACKAGES is set. Installing the following additional Linux packages: ""$packages"
|
||||
if bash /opt/scripts/setup_packages.sh -install; then
|
||||
echo " "
|
||||
else
|
||||
echo "Error: Installation failed."
|
||||
fi
|
||||
if ! bash /opt/scripts/setup_packages.sh -install; then echo "Failed."; fi
|
||||
fi
|
||||
echo " "
|
||||
# Register maintenance script
|
||||
echo -n "Registering maintenance script as command... "
|
||||
echo "alias maintenance='/opt/scripts/maintenance.sh'" >> /etc/bash.bashrc
|
||||
echo "alias maint='/opt/scripts/maintenance.sh'" >> /etc/bash.bashrc
|
||||
echo "alias m='/opt/scripts/maintenance.sh'" >> /etc/bash.bashrc
|
||||
ln -s /opt/scripts/maintenance.sh /bin/maintenance
|
||||
ln -s /opt/scripts/maintenance.sh /bin/maint
|
||||
ln -s /opt/scripts/maintenance.sh /bin/m
|
||||
echo "Done."
|
||||
else
|
||||
echo "This is not the first run of this container. Skipping first run preparation."
|
||||
@@ -505,17 +497,24 @@ elif [[ -f /opt/userscripts/userscript_firststart.sh || -f /opt/userscripts/user
|
||||
echo "Userscript for first start detected and this is the first start of a new container."
|
||||
echo "Running userscript_firststart.sh... "
|
||||
chmod 755 /opt/userscripts/userscript_firststart.sh
|
||||
bash /opt/userscripts/userscript_firststart.sh
|
||||
if ! bash /opt/userscripts/userscript_firststart.sh; then
|
||||
echo "Failed."
|
||||
else
|
||||
echo "Done."
|
||||
fi
|
||||
fi
|
||||
if [[ -f /opt/userscripts/userscript_everystart.sh ]]; then
|
||||
echo "Userscript for every start detected. Running userscript_everystart.sh... "
|
||||
chmod 755 /opt/userscripts/userscript_everystart.sh
|
||||
bash /opt/userscripts/userscript_everystart.sh
|
||||
if ! bash /opt/userscripts/userscript_everystart.sh; then
|
||||
echo "Failed."
|
||||
else
|
||||
echo "Done."
|
||||
fi
|
||||
fi
|
||||
echo " "
|
||||
fi
|
||||
|
||||
|
||||
# Removing first run an fresh install markers when exists
|
||||
if [[ -f /opt/.docker_config/.first_run ]]; then rm -f /opt/.docker_config/.first_run; fi
|
||||
|
||||
@@ -165,12 +165,12 @@ stop_iob() {
|
||||
|
||||
if [[ "$killbyname" != yes ]]; then
|
||||
# pgrep exits with status 1 when there are no matches
|
||||
while pgrep -u iobroker -f 'io.' > /dev/null; (( $? != 1 )); do
|
||||
while pgrep -u iobroker -f 'io\..' > /dev/null; (( $? != 1 )); do
|
||||
if (($(date +%s) > timeout)); then
|
||||
echo -e "\nTimeout reached. Killing remaining processes..."
|
||||
pgrep --list-full -u iobroker
|
||||
pkill --signal SIGKILL -u iobroker -f 'io.'
|
||||
echo "\nDone."
|
||||
pgrep --list-full -u iobroker -f 'io\..'
|
||||
pkill --signal SIGKILL -u iobroker -f 'io\..'
|
||||
echo "Done."
|
||||
return
|
||||
fi
|
||||
sleep 1
|
||||
@@ -184,6 +184,7 @@ stop_iob() {
|
||||
fi
|
||||
|
||||
echo -e "Done."
|
||||
echo " "
|
||||
}
|
||||
|
||||
# restart container
|
||||
@@ -219,35 +220,63 @@ restore_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."
|
||||
|
||||
# check autoconfirm
|
||||
if [[ "$autoconfirm" != yes ]]; then
|
||||
local reply
|
||||
|
||||
read -rp 'Do you want to continue [yes/no]? ' reply
|
||||
if [[ "$reply" == y || "$reply" == Y || "$reply" == yes ]]; then
|
||||
: # continue
|
||||
else
|
||||
if [[ "$reply" != y && "$reply" != Y && "$reply" != yes ]]; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
echo " "
|
||||
|
||||
# check startup script running
|
||||
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
|
||||
|
||||
# check mainenance mode
|
||||
if ! maintenance_enabled > /dev/null; then
|
||||
autoconfirm=yes
|
||||
enable_maintenance
|
||||
fi
|
||||
|
||||
echo -n "Restoring ioBroker... "
|
||||
# list backup files
|
||||
backup_dir="/opt/iobroker/backups"
|
||||
backup_files=($(find $backup_dir -type f))
|
||||
backup_count=${#backup_files[@]}
|
||||
|
||||
if [[ $backup_count -eq 0 ]]; then
|
||||
echo "Ther are no backup files in $backup_dir."
|
||||
echo "Please check and try again."
|
||||
return 1
|
||||
elif [[ $backup_count -eq 1 ]]; then
|
||||
selected_backup=$(basename "${backup_files[0]}")
|
||||
echo "There is one backup file in $backup_dir."
|
||||
else
|
||||
# more than one backup file found, ask user to select
|
||||
echo "There is more than one backup file in $backup_dir."
|
||||
echo "Please select file for restore:"
|
||||
for ((i=0; i<$backup_count; i++)); do
|
||||
echo "$i: $(basename "${backup_files[$i]}")"
|
||||
done
|
||||
echo
|
||||
|
||||
read -rp "Enter the number of the backup to restore (0-$((backup_count - 1))): " selected_number
|
||||
selected_backup=$(basename "${backup_files[$selected_number]}")
|
||||
fi
|
||||
|
||||
# restoe backup
|
||||
echo -n "Restoring ioBroker from $selected_backup... "
|
||||
set +e
|
||||
bash iobroker restore 0 > /opt/iobroker/log/restore.log 2>&1
|
||||
return=$?
|
||||
bash iobroker restore "$selected_backup" > /opt/iobroker/log/restore.log 2>&1
|
||||
return_value=$?
|
||||
set -e
|
||||
if [[ "$return" -ne 0 ]]; then
|
||||
|
||||
if [[ "$return_value" -ne 0 ]]; then
|
||||
echo "Failed."
|
||||
echo "For more details see \"/opt/iobroker/log/restore.log\"."
|
||||
echo "Please check backup file location and permissions and try again."
|
||||
@@ -265,8 +294,8 @@ restore_iobroker() {
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
sleep 10
|
||||
echo "Container will be stopped or restarted in 10 seconds..."
|
||||
sleep 10
|
||||
echo "stopping" > "$healthcheck"
|
||||
sleep 10
|
||||
pkill -u iobroker
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user