diff --git a/testing/Dockerfile b/debian12/Dockerfile similarity index 100% rename from testing/Dockerfile rename to debian12/Dockerfile diff --git a/testing/scripts/healthcheck.sh b/debian12/scripts/healthcheck.sh similarity index 100% rename from testing/scripts/healthcheck.sh rename to debian12/scripts/healthcheck.sh diff --git a/debian12/scripts/iobroker.sh b/debian12/scripts/iobroker.sh new file mode 100644 index 0000000..96ee5f4 --- /dev/null +++ b/debian12/scripts/iobroker.sh @@ -0,0 +1,62 @@ +#!/usr/bin/bash + +# run iob fix +iob_fix () { + if [ "$(id -u)" -eq 0 ]; then + echo "The ioBroker fixer script is not specifically designed to run in Docker." + echo "Although it is generally safe to use, use it at your own risk and make sure to restart your container immediately after execution!" + + local reply + read -rp 'Do you want to continue? [yes/no] ' reply + if [[ "$reply" == y || "$reply" == Y || "$reply" == yes ]]; then + : # continue + else + return 1 + fi + curl -sL https://iobroker.net/fix.sh | bash - + else + echo "Due to some limitations in Docker, you need to run the ioBroker fixer script as root." + echo "Please connect as root user and try again." + fi +} + +# run iob diag +iob_diag () { + if [ "$(id -u)" -eq 0 ]; then + echo "The ioBroker diag script is not specifically designed to run in Docker." + echo "Although it is generally safe to use, use it at your own risk." + local reply + read -rp 'Do you want to continue? [yes/no] ' reply + if [[ "$reply" == y || "$reply" == Y || "$reply" == yes ]]; then + : # continue + else + return 1 + fi + curl -sLf https://iobroker.net/diag.sh --output /home/iobroker/.diag.sh && bash /home/iobroker/.diag.sh | gosu iobroker tee /home/iobroker/iob_diag.log + else + echo "Due to some limitations in Docker, you need to run the ioBroker fixer script as root." + echo "Please connect as root user and try again." + fi +} + +if [ "$1" = "fix" ]; then # call iobroker fixer + iob_fix +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 + shift + if [ "$(id -u)" -eq 0 ]; then # check for execution as root + 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 + gosu iobroker node /opt/iobroker/node_modules/iobroker.js-controller/iobroker.js "$@" + else + node /opt/iobroker/node_modules/iobroker.js-controller/iobroker.js "$@" + fi +fi diff --git a/testing/scripts/iobroker_startup.sh b/debian12/scripts/iobroker_startup.sh similarity index 99% rename from testing/scripts/iobroker_startup.sh rename to debian12/scripts/iobroker_startup.sh index 2c04cda..e4f96e2 100644 --- a/testing/scripts/iobroker_startup.sh +++ b/debian12/scripts/iobroker_startup.sh @@ -221,7 +221,7 @@ echo "$(printf -- '-%.0s' {1..80})" echo " " # Backing up original iobroker executable to fix sudo bug with gosu -if [[ ! -f /opt/iobroker/iobroker.bak ]]; then +if [[ -n $(cmp /opt/scripts/iobroker.sh /opt/iobroker/iobroker) ]]; then echo -n "Replacing ioBroker executable to fix sudo bug... " cp -a /opt/iobroker/iobroker /opt/iobroker/iobroker.bak cp -f /opt/scripts/iobroker.sh /opt/iobroker/iobroker diff --git a/testing/scripts/maintenance.sh b/debian12/scripts/maintenance.sh similarity index 100% rename from testing/scripts/maintenance.sh rename to debian12/scripts/maintenance.sh diff --git a/testing/scripts/setup_avahi.sh b/debian12/scripts/setup_avahi.sh similarity index 100% rename from testing/scripts/setup_avahi.sh rename to debian12/scripts/setup_avahi.sh diff --git a/testing/scripts/setup_iob_db.sh b/debian12/scripts/setup_iob_db.sh similarity index 100% rename from testing/scripts/setup_iob_db.sh rename to debian12/scripts/setup_iob_db.sh diff --git a/testing/scripts/setup_packages.sh b/debian12/scripts/setup_packages.sh similarity index 100% rename from testing/scripts/setup_packages.sh rename to debian12/scripts/setup_packages.sh diff --git a/testing/scripts/setup_zwave.sh b/debian12/scripts/setup_zwave.sh similarity index 100% rename from testing/scripts/setup_zwave.sh rename to debian12/scripts/setup_zwave.sh diff --git a/testing/test_stack.yml b/debian12/test_stack.yml similarity index 100% rename from testing/test_stack.yml rename to debian12/test_stack.yml diff --git a/testing/userscripts/userscript_everystart_example.sh b/debian12/userscripts/userscript_everystart_example.sh similarity index 100% rename from testing/userscripts/userscript_everystart_example.sh rename to debian12/userscripts/userscript_everystart_example.sh diff --git a/testing/userscripts/userscript_firststart_example.sh b/debian12/userscripts/userscript_firststart_example.sh similarity index 100% rename from testing/userscripts/userscript_firststart_example.sh rename to debian12/userscripts/userscript_firststart_example.sh diff --git a/testing/scripts/iobroker.sh b/testing/scripts/iobroker.sh deleted file mode 100644 index 0a88e77..0000000 --- a/testing/scripts/iobroker.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/bash - -if [ "$(id -u)" -eq 0 ]; then - echo "WARNING! IoBroker should not be executed as root!" -fi - -if [ "$1" = "fix" ]; then # call iobroker fixer - curl -sL https://iobroker.net/fix.sh | bash - -elif [ "$1" = "diag" ]; then # call iobroker diag script - if [ "$(id -u)" -eq 0 ]; then # check for execution as root - gosu iobroker curl -sLf https://iobroker.net/diag.sh --output /home/iobroker/.diag.sh && bash /home/iobroker/.diag.sh | gosu iobroker tee /home/iobroker/iob_diag.log - else - curl -sLf https://iobroker.net/diag.sh --output /home/iobroker/.diag.sh && bash /home/iobroker/.diag.sh | tee /home/iobroker/iob_diag.log - fi -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 "Please check ioBroker Docker image docs (https://docs.buanet.de) for the proper way to perform this action!" -else # passing all other parameters to iobroker.js - if [ "$(id -u)" -eq 0 ]; then # check for execution as root - gosu iobroker node /opt/iobroker/node_modules/iobroker.js-controller/iobroker.js "$@" - else - node /opt/iobroker/node_modules/iobroker.js-controller/iobroker.js "$@" - fi -fi