From f7de2fbad2d109856427240a35f106a718efc6e6 Mon Sep 17 00:00:00 2001 From: Alexander Sajzew Date: Tue, 10 Oct 2023 17:24:01 +0200 Subject: [PATCH 01/10] updated start command for avahi-daemon to work with Debian 12 (fixes #384) --- debian12/scripts/setup_avahi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian12/scripts/setup_avahi.sh b/debian12/scripts/setup_avahi.sh index 46d5873..a20634e 100644 --- a/debian12/scripts/setup_avahi.sh +++ b/debian12/scripts/setup_avahi.sh @@ -32,7 +32,7 @@ echo -n "[setup_avahi.sh] Starting dbus... " echo "Done." echo -n "[setup_avahi.sh] Starting avahi-daemon... " - /etc/init.d/avahi-daemon start >> /opt/scripts/avahi_startup.log 2>&1 + avahi-daemon -D echo "Done." exit 0 From 3553ce3a653c5304b52ee9cac87b0dbc3f2ffbdd Mon Sep 17 00:00:00 2001 From: Alexander Sajzew Date: Tue, 10 Oct 2023 18:37:24 +0200 Subject: [PATCH 02/10] start without daemonize and put it into background so we can redirect logs --- debian12/scripts/setup_avahi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian12/scripts/setup_avahi.sh b/debian12/scripts/setup_avahi.sh index a20634e..a68e429 100644 --- a/debian12/scripts/setup_avahi.sh +++ b/debian12/scripts/setup_avahi.sh @@ -32,7 +32,7 @@ echo -n "[setup_avahi.sh] Starting dbus... " echo "Done." echo -n "[setup_avahi.sh] Starting avahi-daemon... " - avahi-daemon -D + avahi-daemon >> /opt/scripts/avahi_startup.log 2>&1 & echo "Done." exit 0 From f01167d513c3a48b78f87811cde5a5f53055bc13 Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 10 Oct 2023 19:01:12 +0200 Subject: [PATCH 03/10] add silent cleanup to setup_avahi.sh --- .VERSION | 2 +- CHANGELOG.md | 4 ++++ debian12/scripts/setup_avahi.sh | 8 +++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.VERSION b/.VERSION index 4cf2aaf..dc441a2 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v9.0.0 \ No newline at end of file +v9.0.1-beta.1 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 10a42f5..0eb131b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog +### 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 + ### v9.0.0 (09.10.2023) * update official docs * v9.0.0-beta.2 (28.09.2023) diff --git a/debian12/scripts/setup_avahi.sh b/debian12/scripts/setup_avahi.sh index a68e429..26c7cd5 100644 --- a/debian12/scripts/setup_avahi.sh +++ b/debian12/scripts/setup_avahi.sh @@ -5,9 +5,11 @@ then echo "[setup_avahi.sh] Avahi is already installed. Nothing to do here." else echo -n "[setup_avahi.sh] Avahi-daemon is NOT installed. Going to install it now... " - apt-get update > /opt/scripts/avahi_startup.log 2>&1 - apt-get install -y --no-install-recommends libavahi-compat-libdnssd-dev avahi-daemon >> /opt/scripts/avahi_startup.log 2>&1 - rm -rf /var/lib/apt/lists/* >> /opt/scripts/avahi_startup.log 2>&1 + apt-get -q update > /opt/scripts/avahi_startup.log 2>&1 + apt-get -q -y --no-install-recommends install libavahi-compat-libdnssd-dev avahi-daemon >> /opt/scripts/avahi_startup.log 2>&1 + # Silent Cleanup + apt-get -qq autoclean -y && apt-get -qq autoremove && apt-get -qq clean + rm -rf /tmp/* /var/tmp/* /root/.cache/* /var/lib/apt/lists/* || true echo "Done." echo -n "[setup_avahi.sh] Configuring avahi-daemon... " sed -i '/^rlimit-nproc/s/^\(.*\)/#\1/g' /etc/avahi/avahi-daemon.conf From 24d5f3c9ed954803c98e06e24a6fc7f626de8475 Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 10 Oct 2023 19:47:37 +0200 Subject: [PATCH 04/10] set push to true for dev-node20 --- .github/workflows/build-debian12-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-debian12-dev.yml b/.github/workflows/build-debian12-dev.yml index f912733..145f2bd 100644 --- a/.github/workflows/build-debian12-dev.yml +++ b/.github/workflows/build-debian12-dev.yml @@ -134,7 +134,7 @@ jobs: with: context: ./debian12 file: ./debian12/Dockerfile - push: false + push: true platforms: | linux/amd64 linux/arm64 From d4469b80d50f971a7a64832f3129b0f9076ae367 Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 10 Oct 2023 20:06:51 +0200 Subject: [PATCH 05/10] change version --- .VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.VERSION b/.VERSION index dc441a2..8f80905 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v9.0.1-beta.1 \ No newline at end of file +v9.0.1 \ No newline at end of file From 4614b8c41a45670802ae63cb0db9a49aa020308c Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 10 Oct 2023 20:49:48 +0200 Subject: [PATCH 06/10] fix issue with apt repo failing --- debian12/scripts/iobroker_startup.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/debian12/scripts/iobroker_startup.sh b/debian12/scripts/iobroker_startup.sh index efe0957..c764160 100644 --- a/debian12/scripts/iobroker_startup.sh +++ b/debian12/scripts/iobroker_startup.sh @@ -133,7 +133,11 @@ 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 - bash /opt/scripts/setup_packages.sh -update + if bash /opt/scripts/setup_packages.sh -update; then + echo " " + else + echo "Error: Updating failed." + fi fi echo " " # Installing packages from ENV @@ -141,7 +145,11 @@ 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" - bash /opt/scripts/setup_packages.sh -install + if bash /opt/scripts/setup_packages.sh -install; then + echo " " + else + echo "Error: Installation failed." + fi fi echo " " # Register maintenance script From 317264f849a3b6851636df5cdf4cd8cb20bfb4f8 Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 10 Oct 2023 22:41:27 +0200 Subject: [PATCH 07/10] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eb131b..e9d3883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 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 +* add error handling for package updates/ install ### v9.0.0 (09.10.2023) * update official docs From 55c5b445371f1f16fbcc70b52663c485386a54cd Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 10 Oct 2023 22:58:03 +0200 Subject: [PATCH 08/10] fix calling iob in iobroker_startup.sh --- CHANGELOG.md | 1 + debian12/scripts/iobroker_startup.sh | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9d3883..9a15126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * 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 * add error handling for package updates/ install +* fix calling iob in iobroker_startup.sh ([#388](https://github.com/buanet/ioBroker.docker/issues/388)) ### v9.0.0 (09.10.2023) * update official docs diff --git a/debian12/scripts/iobroker_startup.sh b/debian12/scripts/iobroker_startup.sh index c764160..52da59f 100644 --- a/debian12/scripts/iobroker_startup.sh +++ b/debian12/scripts/iobroker_startup.sh @@ -316,7 +316,7 @@ if [[ -f /opt/iobroker/.fresh_install && "$multihost" != "slave" ]]; then echo -n "Initializing a fresh installation of ioBroker... " if [[ ! -d "/opt/iobroker/log" ]]; then gosu iobroker mkdir "/opt/iobroker/log"; fi set +e - bash iob setup first > /opt/iobroker/log/iob_setup_first.log 2>&1 + gosu iobroker iob setup first > /opt/iobroker/log/iob_setup_first.log 2>&1 return=$? set -e rm -f /opt/iobroker/.fresh_install @@ -331,11 +331,11 @@ if [[ -f /opt/iobroker/.fresh_install && "$multihost" != "slave" ]]; then else echo -n "Checking Database connection... " set +e - if iob uuid &> /dev/null; then + if gosu iobroker iob uuid &> /dev/null; then echo "Done." echo " " else - errormsg=$(iob uuid 2>&1 | sed 's/^/[DEBUG] /') + errormsg=$(gosu iobroker iob uuid 2>&1 | sed 's/^/[DEBUG] /') echo "Failed." if [[ "$debug" == "true" ]]; then echo "[DEBUG] Error message: " @@ -355,20 +355,20 @@ if [[ "$multihost" == "slave" ]]; then else # get admin instance and hostname set +e - admininstance=$(bash iobroker list instances | grep 'enabled' | grep -m 1 -o 'system.adapter.admin..') + admininstance=$(gosu iobroker iob list instances | grep 'enabled' | grep -m 1 -o 'system.adapter.admin..') set -e if [[ "$admininstance" != "" ]]; then if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected admin instance is:" "$admininstance"; fi - adminhostname=$(bash iobroker object get "$admininstance" --pretty | grep -oP '(?<="host": ")[^"]*') + adminhostname=$(gosu iobroker iob object get "$admininstance" --pretty | grep -oP '(?<="host": ")[^"]*') if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected admin hostname is:" "$adminhostname"; fi else set +e - admininstance=$(bash iobroker list instances | grep 'disabled' | grep -m 1 -o 'system.adapter.admin..') + admininstance=$(gosu iobroker iob list instances | grep 'disabled' | grep -m 1 -o 'system.adapter.admin..') set -e if [[ "$admininstance" != "" ]]; then if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected admin instance is disabled."; fi if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected admin instance is:" "$admininstance"; fi - adminhostname=$(bash iobroker object get "$admininstance" --pretty | grep -oP '(?<="host": ")[^"]*') + adminhostname=$(gosu iobroker iob object get "$admininstance" --pretty | grep -oP '(?<="host": ")[^"]*') if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected admin hostname is:" "$adminhostname"; fi else echo "There was a problem detecting the admin instance of your iobroker." @@ -381,7 +381,7 @@ else if [[ "$adminhostname" != "" && "$adminhostname" != "$(hostname)" ]]; then echo "Hostname in ioBroker does not match the hostname of this container." echo -n "Updating hostname to \"""$(hostname)""\"... " - bash iobroker host "$adminhostname" + gosu iobroker iob host "$adminhostname" echo "Done." echo " " elif [[ "$adminhostname" = "$(hostname)" ]]; then @@ -439,13 +439,13 @@ echo " " # Checking ENV for Adminport if [[ "$adminport" != "" && "$multihost" != "slave" ]]; then - adminportold=$(bash iobroker object get "$admininstance" --pretty | grep -oP '(?<="port": )[^,]*') + adminportold=$(gosu iobroker iob object get "$admininstance" --pretty | grep -oP '(?<="port": )[^,]*') admininstanceshort=$(echo "$admininstance" | grep -m 1 -o 'admin..') if [[ "$adminport" != "$adminportold" ]]; then echo "IOB_ADMINPORT is set and does not match port configured in ioBroker." if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected Admin Port in ioBroker: " "$adminportold"; fi echo "Setting Adminport to \"""$adminport""\"... " - bash iobroker set "$admininstanceshort" --port "$adminport" + gosu iobroker iob set "$admininstanceshort" --port "$adminport" echo "Done." echo " " fi From 760a36f72a9d659d39a5979bb7247d3c22f5b960 Mon Sep 17 00:00:00 2001 From: buanet Date: Wed, 11 Oct 2023 00:08:14 +0200 Subject: [PATCH 09/10] add error handling for user scripts --- .VERSION | 2 +- CHANGELOG.md | 4 ++++ debian12/scripts/iobroker_startup.sh | 28 +++++++++++++--------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.VERSION b/.VERSION index 8f80905..6c9bb72 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v9.0.1 \ No newline at end of file +v9.1.0-beta.1 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a15126..3becbd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog +### v9.1.0-beta.1 +* 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 diff --git a/debian12/scripts/iobroker_startup.sh b/debian12/scripts/iobroker_startup.sh index 52da59f..eb401d2 100644 --- a/debian12/scripts/iobroker_startup.sh +++ b/debian12/scripts/iobroker_startup.sh @@ -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,11 +141,7 @@ 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 @@ -505,17 +497,23 @@ 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 - echo "Done." + 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 - echo "Done." + if ! bash /opt/userscripts/userscript_everystart.sh; then + echo "Failed." + else + echo "Done." + fi fi + echo " " fi -echo " " # 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 From 10de4b1a550d3c2776da2e26cf2b5a95ba639067 Mon Sep 17 00:00:00 2001 From: buanet Date: Wed, 11 Oct 2023 00:18:38 +0200 Subject: [PATCH 10/10] Revert "add error handling for user scripts" This reverts commit 760a36f72a9d659d39a5979bb7247d3c22f5b960. --- .VERSION | 2 +- CHANGELOG.md | 4 ---- debian12/scripts/iobroker_startup.sh | 28 +++++++++++++++------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.VERSION b/.VERSION index 6c9bb72..8f80905 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v9.1.0-beta.1 \ No newline at end of file +v9.0.1 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3becbd8..9a15126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,5 @@ ## Changelog -### v9.1.0-beta.1 -* 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 diff --git a/debian12/scripts/iobroker_startup.sh b/debian12/scripts/iobroker_startup.sh index eb401d2..52da59f 100644 --- a/debian12/scripts/iobroker_startup.sh +++ b/debian12/scripts/iobroker_startup.sh @@ -133,7 +133,11 @@ 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 "Failed."; fi + if bash /opt/scripts/setup_packages.sh -update; then + echo " " + else + echo "Error: Updating failed." + fi fi echo " " # Installing packages from ENV @@ -141,7 +145,11 @@ 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 "Failed."; fi + if bash /opt/scripts/setup_packages.sh -install; then + echo " " + else + echo "Error: Installation failed." + fi fi echo " " # Register maintenance script @@ -497,23 +505,17 @@ 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 - if ! bash /opt/userscripts/userscript_firststart.sh; then - echo "Failed." - else - echo "Done." - fi + bash /opt/userscripts/userscript_firststart.sh + echo "Done." 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 - if ! bash /opt/userscripts/userscript_everystart.sh; then - echo "Failed." - else - echo "Done." - fi + bash /opt/userscripts/userscript_everystart.sh + echo "Done." fi - echo " " fi +echo " " # 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