From ae0fa2f06c6864316e00d972c082c0f8f2aab847 Mon Sep 17 00:00:00 2001 From: Andre Date: Fri, 25 Oct 2019 22:06:36 +0200 Subject: [PATCH 01/43] Update .VERSION --- .VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.VERSION b/.VERSION index 857572f..ecdba1c 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v4.0.0 +v4.0.1beta From 747edf98fe9666462fe8ed147a72a7cac885e1b2 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 28 Oct 2019 10:12:46 +0100 Subject: [PATCH 02/43] updating prerequisites --- amd64/Dockerfile | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index bc1b165..01cd5b5 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -4,7 +4,7 @@ MAINTAINER Andre Germann ENV DEBIAN_FRONTEND noninteractive -# Install prerequisites +# Install prerequisites (as listed in iobroker installer.sh) RUN apt-get update && apt-get upgrade -y && apt-get install -y \ acl \ apt-utils \ @@ -12,17 +12,20 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \ curl \ git \ gnupg2 \ + gosu \ + libavahi-compat-libdnssd-dev \ libcap2-bin \ libpam0g-dev \ libudev-dev \ locales \ - procps \ + pkg-config \ python \ - gosu \ + python-dev \ + sudo \ unzip \ wget \ && rm -rf /var/lib/apt/lists/* - + # Install node10 RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ && apt-get update && apt-get install -y \ @@ -61,8 +64,9 @@ RUN npm install -g node-gyp # Backup initial ioBroker-folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker -# Setting up iobroker-user -RUN chsh -s /bin/bash iobroker +# Setting up iobroker-user (shell and home directory) +RUN chsh -s /bin/bash iobroker \ + && usermod --home /opt/iobroker iobroker # Setting up ENVs ENV DEBIAN_FRONTEND="teletype" \ @@ -70,10 +74,10 @@ ENV DEBIAN_FRONTEND="teletype" \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ TZ="Europe/Berlin" \ - PACKAGES="nano" \ + PACKAGES="vi" \ AVAHI="false" \ - SETUID=1000 \ - SETGID=1000 \ + SETUID=1000 \ + SETGID=1000 \ ZWAVE="false" # Setting up EXPOSE for Admin From 3f976baad75b3c9a78442eac3ce619664d85b629 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 28 Oct 2019 12:53:10 +0100 Subject: [PATCH 03/43] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6cd582c..c5fbb4d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # ioBroker for Docker + +[![Build Status](https://travis-ci.org/buanet/docker-iobroker.svg?branch=master)](https://travis-ci.org/buanet/docker-iobroker) + Source: https://github.com/buanet/docker-iobroker IoBroker for Docker is an Dockerimage for ioBroker (http://iobroker.net) smarthome software. From 063b21a0d137f379bbf482286f650bad0a839b45 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 11 Nov 2019 10:43:04 +0100 Subject: [PATCH 04/43] added env "adminport" --- amd64/Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 01cd5b5..5c6d7d7 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -75,13 +75,11 @@ ENV DEBIAN_FRONTEND="teletype" \ LC_ALL="de_DE.UTF-8" \ TZ="Europe/Berlin" \ PACKAGES="vi" \ - AVAHI="false" \ + ADMINPORT=8081 \ SETUID=1000 \ SETGID=1000 \ + AVAHI="false" \ ZWAVE="false" - -# Setting up EXPOSE for Admin -EXPOSE 8081/tcp # Run startup-script ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] From d30bd1de4760c414ea24c17e29cf34b2b3a4d0c1 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 11 Nov 2019 11:36:28 +0100 Subject: [PATCH 05/43] adding adminport --- amd64/scripts/iobroker_startup.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 68e9537..c05a65d 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -2,10 +2,11 @@ # Reading ENV packages=$PACKAGES -avahi=$AVAHI +adminport=$ADMINPORT uid=$SETUID gid=$SETGID zwave=$ZWAVE +avahi=$AVAHI # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` @@ -34,8 +35,10 @@ echo -n "----- " && echo -n "$(printf "%-10s %-23s" node: $(node - echo -n "----- " && echo -n "$(printf "%-10s %-23s" npm: $(npm -v))" && echo " -----" echo "----- -----" echo "----- ENV -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ADMINPORT: $ADMINPORT)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETGID: $SETGID)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETUID: $SETUID)" && echo " -----" echo "$(printf -- '-%.0s' {1..60})" @@ -125,8 +128,8 @@ if [ -f /opt/iobroker/.install_host ] then echo "Looks like this is a new and empty installation of ioBroker." echo "Hostname needs to be updated to " $(hostname)"..." - sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) - rm -f /opt/iobroker/.install_host + sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) + rm -f /opt/iobroker/.install_host echo 'Done.' echo ' ' fi @@ -141,6 +144,16 @@ echo "Some adapters have special requirements which can be activated by the use echo "For more information take a look at readme.md" echo ' ' +# Checking ENV for Adminport +if [ "$adminport" != "8081" ] +then + echo "Adminport is set by ENV." + echo "Setting Adminport to" $(adminport)"..." + iobroker set admin.0 --port $adminport + echo 'Done.' + echo ' ' +fi + # Checking for and setting up avahi-daemon if [ "$avahi" = "true" ] then From 2175f9a4fa1a52b096e4ee7988d58d8303586d2e Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 11 Nov 2019 14:32:11 +0100 Subject: [PATCH 06/43] fixing adminport script --- amd64/scripts/iobroker_startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index c05a65d..6467a2b 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -148,7 +148,7 @@ echo ' ' if [ "$adminport" != "8081" ] then echo "Adminport is set by ENV." - echo "Setting Adminport to" $(adminport)"..." + echo "Setting Adminport to" $adminport"..." iobroker set admin.0 --port $adminport echo 'Done.' echo ' ' From 64a6c358656e497e37753c1b1044ac1186a401b6 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 11 Nov 2019 14:50:27 +0100 Subject: [PATCH 07/43] fixing avahi setup --- amd64/scripts/setup_avahi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd64/scripts/setup_avahi.sh b/amd64/scripts/setup_avahi.sh index 2f64a72..3e1a2f0 100644 --- a/amd64/scripts/setup_avahi.sh +++ b/amd64/scripts/setup_avahi.sh @@ -2,7 +2,7 @@ echo "Checking avahi-daemon installation state..." -if [ -f /usr/sbin/avahi-daemon ] +if [ -f /usr/sbin/avahi-daemon ] && [ -f /var/run/dbus ] then echo "Avahi is already installed..." else From b7cdabe4271767045acee21a500b1f6dd91a14f2 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 25 Nov 2019 13:03:39 +0100 Subject: [PATCH 08/43] added ENV for usb devices --- amd64/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 5c6d7d7..65f3ee8 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -79,7 +79,8 @@ ENV DEBIAN_FRONTEND="teletype" \ SETUID=1000 \ SETGID=1000 \ AVAHI="false" \ - ZWAVE="false" + ZWAVE="false" \ + USBDEVICES="none" # Run startup-script ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] From eda7d5ba9579231bd5a700c5d749b27438701062 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 25 Nov 2019 13:09:59 +0100 Subject: [PATCH 09/43] added env for usb-device-support --- amd64/scripts/iobroker_startup.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 6467a2b..651227b 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -7,6 +7,7 @@ uid=$SETUID gid=$SETGID zwave=$ZWAVE avahi=$AVAHI +usbdevices=$USBDEVICES # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` @@ -154,7 +155,7 @@ then echo ' ' fi -# Checking for and setting up avahi-daemon +# Checking for enabled avahi-daemon if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." @@ -164,6 +165,7 @@ then echo ' ' fi +# Checking for enabled zwave-support if [ "$zwave" = "true" ] then echo "ZWave is activated by ENV." @@ -173,6 +175,16 @@ then echo ' ' fi +# checking enabled usb-devices + +if [ "$usbdevices" != "none" ] +then + echo "Usb-device-support is activated by ENV." + #testing + echo "Done." + echo ' ' +fi + sleep 5 # Starting ioBroker From cd7beb515681860a54e7d936e5bdbc82783f6c32 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 25 Nov 2019 15:55:16 +0100 Subject: [PATCH 10/43] setting permissions for devices --- amd64/scripts/iobroker_startup.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 651227b..7d8a7ad 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -180,7 +180,15 @@ fi if [ "$usbdevices" != "none" ] then echo "Usb-device-support is activated by ENV." - #testing + + deviceslist="$usbdevices" + IFS=';' read -ra devicearray <<< "$deviceslist" + for i in "${devicearray[@]}" + do + echo "Setting permissions for" $i"..." + chown root:dialout $i + chmod g+rw $i + done echo "Done." echo ' ' fi From 4db534ef62e72b21d9c9bb5af3d1f586d5d03068 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 25 Nov 2019 15:57:26 +0100 Subject: [PATCH 11/43] testing --- amd64/scripts/iobroker_startup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 7d8a7ad..de85bed 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -181,8 +181,7 @@ if [ "$usbdevices" != "none" ] then echo "Usb-device-support is activated by ENV." - deviceslist="$usbdevices" - IFS=';' read -ra devicearray <<< "$deviceslist" + IFS=';' read -ra devicearray <<< "$usbdevices" for i in "${devicearray[@]}" do echo "Setting permissions for" $i"..." From e23b64627086d0a7f364f2724857eb259c6fb436 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 25 Nov 2019 17:28:44 +0100 Subject: [PATCH 12/43] Update Dockerfile --- amd64/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 65f3ee8..f36ceb6 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -19,6 +19,7 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \ libudev-dev \ locales \ pkg-config \ + procps \ python \ python-dev \ sudo \ From 983b16d4615cc835088521532edb91e4644c3967 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 25 Nov 2019 17:55:56 +0100 Subject: [PATCH 13/43] Update setup_avahi.sh --- amd64/scripts/setup_avahi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd64/scripts/setup_avahi.sh b/amd64/scripts/setup_avahi.sh index 3e1a2f0..4fd1ab1 100644 --- a/amd64/scripts/setup_avahi.sh +++ b/amd64/scripts/setup_avahi.sh @@ -2,7 +2,7 @@ echo "Checking avahi-daemon installation state..." -if [ -f /usr/sbin/avahi-daemon ] && [ -f /var/run/dbus ] +if [ -e /usr/sbin/avahi-daemon ] && [ -e /var/run/dbus ] then echo "Avahi is already installed..." else From 63b4c7edf59c1e126647ac12aee3d8cbad0691fb Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 25 Nov 2019 17:56:32 +0100 Subject: [PATCH 14/43] Update iobroker_startup.sh --- amd64/scripts/iobroker_startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index de85bed..4e40f6f 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -168,7 +168,7 @@ fi # Checking for enabled zwave-support if [ "$zwave" = "true" ] then - echo "ZWave is activated by ENV." + echo "Z-Wave is activated by ENV." chmod 764 /opt/scripts/setup_zwave.sh sh /opt/scripts/setup_zwave.sh echo "Done." From 5592da421566509aec56cfcc6b6df617007ea19b Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 25 Nov 2019 17:57:02 +0100 Subject: [PATCH 15/43] Update setup_zwave.sh --- amd64/scripts/setup_zwave.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amd64/scripts/setup_zwave.sh b/amd64/scripts/setup_zwave.sh index ff1b82f..e9710d0 100644 --- a/amd64/scripts/setup_zwave.sh +++ b/amd64/scripts/setup_zwave.sh @@ -2,7 +2,7 @@ echo "Checking openzwave installation state..." -if [ -f /usr/local/lib64 ] +if [ -e /usr/local/lib64 ] then echo "Openzwave is already installed..." else @@ -16,4 +16,4 @@ else # echo "Openzwave is now installed..." fi -exit 0 \ No newline at end of file +exit 0 From 320717d8bc179bf631e87d9d6358abd113f445b4 Mon Sep 17 00:00:00 2001 From: andre <> Date: Mon, 25 Nov 2019 23:15:24 +0100 Subject: [PATCH 16/43] Update README.md --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c5fbb4d..7798035 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,14 @@ Feel free to ask for more architectures by opening an github-issue. The new v4 comes again with a new major node-version (node10)! If you are updating an existing Installation you have to perform some additional steps inside ioBroker! -After upgrading your iobroker-container you have to call "reinstall.sh" for recompiling your installation for the use with node10! +After upgrading your iobroker-container you have to call "reinstall.sh" for recompileing your installation for the use with node10! For Details see official ioBroker-documentation (http://www.iobroker.net/docu/?page_id=8323&lang=de). Make backup first! ## Installation & usage A detailed tutorial (german, based on v3.0.0) can be found here: [https://buanet.de](https://buanet.de/2019/05/iobroker-unter-docker-auf-der-synology-diskstation-v3/). Please notice that the old tutorial is outdated and does no longer work! -For discussion and support please visit [ioBroker-forum-thread](http://forum.iobroker.net/viewtopic.php?f=17&t=5089) or use the comments section at the linked tutorial. Please do not contact me directly for any support-reasons. Every support-question should be answered in a public place. Thank you. +For discussion and support please visit [ioBroker-forum-thread](http://forum.iobroker.net/viewtopic.php?f=17&t=5089) or use the comments section at the linked tutorial. Please do not contact me directly for any support-reasons. Every support question should be answered in a public place. Thank you. ## Special settings and features @@ -43,6 +43,8 @@ Since v3 is possible to set some environment variables to configure a new contai |SETUID|1000|for security reasons it might be useful to specify the uid of the containers iobroker user to match an existing user on the docker host| |SETGID|1000|for security reasons it might be useful to specify the gid of the containers iobroker user to match an existing group on the docker host| |ZWAVE|false|will install openzwave to support zwave-adapter| +|ADMINPORT|8081|for setting iobroker adminport (beta feature!)| +|USBDEVICES|none|for automatically setting permissions on mounted devices like "/dev/ttyACM0". For more than one device separate with ";" (beta feature!)| ### Mounting Folder/ Volume @@ -58,6 +60,12 @@ After some issues with permissions related to the use of a dedicated user for io ## Changelog +### v4.0.1beta (2019-11-25) +* added env for iobroker admin port +* added env for usb-devices (setting permissions) +* updateing prerequisites for iobroker installation +* some small codefixes + ### v4.0.0 (2019-10-25) * v3.1.4beta (2019-10-23) * added env for zwave support From 95af2c3acfc39862d6f3acdb228912a535288730 Mon Sep 17 00:00:00 2001 From: andre <> Date: Wed, 27 Nov 2019 21:47:51 +0100 Subject: [PATCH 17/43] moving changes to different architectures --- aarch64/Dockerfile | 55 +++++++++++++++------------- aarch64/scripts/iobroker_startup.sh | 44 +++++++++++++++++++--- aarch64/scripts/setup_avahi.sh | 2 +- aarch64/scripts/setup_zwave.sh | 4 +- amd64/Dockerfile | 28 +++++++------- armv7hf/Dockerfile | 57 +++++++++++++++-------------- armv7hf/scripts/iobroker_startup.sh | 44 +++++++++++++++++++--- armv7hf/scripts/setup_avahi.sh | 2 +- armv7hf/scripts/setup_zwave.sh | 4 +- 9 files changed, 155 insertions(+), 85 deletions(-) diff --git a/aarch64/Dockerfile b/aarch64/Dockerfile index 69f7db8..4551331 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -4,23 +4,27 @@ MAINTAINER Andre Germann ENV DEBIAN_FRONTEND noninteractive -# Install prerequisites +# Install prerequisites (as listed in iobroker installer.sh) RUN apt-get update && apt-get upgrade -y && apt-get install -y \ - acl \ - apt-utils \ - build-essential \ - curl \ - git \ - gnupg2 \ - libcap2-bin \ - libpam0g-dev \ - libudev-dev \ - locales \ - procps \ - python \ - gosu \ - unzip \ - wget \ + acl \ + apt-utils \ + build-essential \ + curl \ + git \ + gnupg2 \ + gosu \ + libavahi-compat-libdnssd-dev \ + libcap2-bin \ + libpam0g-dev \ + libudev-dev \ + locales \ + pkg-config \ + procps \ + python \ + python-dev \ + sudo \ + unzip \ + wget \ && rm -rf /var/lib/apt/lists/* # Install node10 @@ -56,14 +60,14 @@ RUN apt-get update \ # Install node-gyp WORKDIR /opt/iobroker/ -RUN npm config set unsafe-perm true # To fix "Error: could not get uid/gid" RUN npm install -g node-gyp # Backup initial ioBroker-folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker -# Setting up iobroker-user -RUN chsh -s /bin/bash iobroker +# Setting up iobroker-user (shell and home directory) +RUN chsh -s /bin/bash iobroker \ + && usermod --home /opt/iobroker iobroker # Setting up ENVs ENV DEBIAN_FRONTEND="teletype" \ @@ -71,14 +75,13 @@ ENV DEBIAN_FRONTEND="teletype" \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ TZ="Europe/Berlin" \ - PACKAGES="nano" \ + PACKAGES="vi" \ + ADMINPORT=8081 \ + SETUID=1000 \ + SETGID=1000 \ AVAHI="false" \ - SETUID=1000 \ - SETGID=1000 \ - ZWAVE="false" - -# Setting up EXPOSE for Admin -EXPOSE 8081/tcp + ZWAVE="false" \ + USBDEVICES="none" # Run startup-script ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 68e9537..4e40f6f 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -2,10 +2,12 @@ # Reading ENV packages=$PACKAGES -avahi=$AVAHI +adminport=$ADMINPORT uid=$SETUID gid=$SETGID zwave=$ZWAVE +avahi=$AVAHI +usbdevices=$USBDEVICES # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` @@ -34,8 +36,10 @@ echo -n "----- " && echo -n "$(printf "%-10s %-23s" node: $(node - echo -n "----- " && echo -n "$(printf "%-10s %-23s" npm: $(npm -v))" && echo " -----" echo "----- -----" echo "----- ENV -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ADMINPORT: $ADMINPORT)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETGID: $SETGID)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETUID: $SETUID)" && echo " -----" echo "$(printf -- '-%.0s' {1..60})" @@ -125,8 +129,8 @@ if [ -f /opt/iobroker/.install_host ] then echo "Looks like this is a new and empty installation of ioBroker." echo "Hostname needs to be updated to " $(hostname)"..." - sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) - rm -f /opt/iobroker/.install_host + sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) + rm -f /opt/iobroker/.install_host echo 'Done.' echo ' ' fi @@ -141,7 +145,17 @@ echo "Some adapters have special requirements which can be activated by the use echo "For more information take a look at readme.md" echo ' ' -# Checking for and setting up avahi-daemon +# Checking ENV for Adminport +if [ "$adminport" != "8081" ] +then + echo "Adminport is set by ENV." + echo "Setting Adminport to" $adminport"..." + iobroker set admin.0 --port $adminport + echo 'Done.' + echo ' ' +fi + +# Checking for enabled avahi-daemon if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." @@ -151,15 +165,33 @@ then echo ' ' fi +# Checking for enabled zwave-support if [ "$zwave" = "true" ] then - echo "ZWave is activated by ENV." + echo "Z-Wave is activated by ENV." chmod 764 /opt/scripts/setup_zwave.sh sh /opt/scripts/setup_zwave.sh echo "Done." echo ' ' fi +# checking enabled usb-devices + +if [ "$usbdevices" != "none" ] +then + echo "Usb-device-support is activated by ENV." + + IFS=';' read -ra devicearray <<< "$usbdevices" + for i in "${devicearray[@]}" + do + echo "Setting permissions for" $i"..." + chown root:dialout $i + chmod g+rw $i + done + echo "Done." + echo ' ' +fi + sleep 5 # Starting ioBroker diff --git a/aarch64/scripts/setup_avahi.sh b/aarch64/scripts/setup_avahi.sh index 2f64a72..4fd1ab1 100644 --- a/aarch64/scripts/setup_avahi.sh +++ b/aarch64/scripts/setup_avahi.sh @@ -2,7 +2,7 @@ echo "Checking avahi-daemon installation state..." -if [ -f /usr/sbin/avahi-daemon ] +if [ -e /usr/sbin/avahi-daemon ] && [ -e /var/run/dbus ] then echo "Avahi is already installed..." else diff --git a/aarch64/scripts/setup_zwave.sh b/aarch64/scripts/setup_zwave.sh index ff1b82f..e9710d0 100644 --- a/aarch64/scripts/setup_zwave.sh +++ b/aarch64/scripts/setup_zwave.sh @@ -2,7 +2,7 @@ echo "Checking openzwave installation state..." -if [ -f /usr/local/lib64 ] +if [ -e /usr/local/lib64 ] then echo "Openzwave is already installed..." else @@ -16,4 +16,4 @@ else # echo "Openzwave is now installed..." fi -exit 0 \ No newline at end of file +exit 0 diff --git a/amd64/Dockerfile b/amd64/Dockerfile index f36ceb6..8141a3b 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -6,27 +6,27 @@ ENV DEBIAN_FRONTEND noninteractive # Install prerequisites (as listed in iobroker installer.sh) RUN apt-get update && apt-get upgrade -y && apt-get install -y \ - acl \ - apt-utils \ - build-essential \ - curl \ - git \ - gnupg2 \ + acl \ + apt-utils \ + build-essential \ + curl \ + git \ + gnupg2 \ gosu \ libavahi-compat-libdnssd-dev \ - libcap2-bin \ - libpam0g-dev \ - libudev-dev \ - locales \ + libcap2-bin \ + libpam0g-dev \ + libudev-dev \ + locales \ pkg-config \ procps \ - python \ + python \ python-dev \ sudo \ - unzip \ - wget \ + unzip \ + wget \ && rm -rf /var/lib/apt/lists/* - + # Install node10 RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ && apt-get update && apt-get install -y \ diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index 293db80..120093a 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -4,26 +4,30 @@ MAINTAINER Andre Germann ENV DEBIAN_FRONTEND noninteractive -# Install prerequisites +# Install prerequisites (as listed in iobroker installer.sh) RUN apt-get update && apt-get upgrade -y && apt-get install -y \ - acl \ - apt-utils \ - build-essential \ - curl \ - git \ - gnupg2 \ - libcap2-bin \ - libpam0g-dev \ - libudev-dev \ - locales \ - procps \ - python \ - gosu \ - unzip \ - wget \ + acl \ + apt-utils \ + build-essential \ + curl \ + git \ + gnupg2 \ + gosu \ + libavahi-compat-libdnssd-dev \ + libcap2-bin \ + libpam0g-dev \ + libudev-dev \ + locales \ + pkg-config \ + procps \ + python \ + python-dev \ + sudo \ + unzip \ + wget \ && rm -rf /var/lib/apt/lists/* -# Install node8 +# Install node10 RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ && apt-get update && apt-get install -y \ nodejs \ @@ -56,14 +60,14 @@ RUN apt-get update \ # Install node-gyp WORKDIR /opt/iobroker/ -RUN npm config set unsafe-perm true # To fix "Error: could not get uid/gid" RUN npm install -g node-gyp # Backup initial ioBroker-folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker -# Setting up iobroker-user -RUN chsh -s /bin/bash iobroker +# Setting up iobroker-user (shell and home directory) +RUN chsh -s /bin/bash iobroker \ + && usermod --home /opt/iobroker iobroker # Setting up ENVs ENV DEBIAN_FRONTEND="teletype" \ @@ -71,14 +75,13 @@ ENV DEBIAN_FRONTEND="teletype" \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ TZ="Europe/Berlin" \ - PACKAGES="nano" \ + PACKAGES="vi" \ + ADMINPORT=8081 \ + SETUID=1000 \ + SETGID=1000 \ AVAHI="false" \ - SETUID=1000 \ - SETGID=1000 \ - ZWAVE="false" - -# Setting up EXPOSE for Admin -EXPOSE 8081/tcp + ZWAVE="false" \ + USBDEVICES="none" # Run startup-script ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 68e9537..4e40f6f 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -2,10 +2,12 @@ # Reading ENV packages=$PACKAGES -avahi=$AVAHI +adminport=$ADMINPORT uid=$SETUID gid=$SETGID zwave=$ZWAVE +avahi=$AVAHI +usbdevices=$USBDEVICES # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` @@ -34,8 +36,10 @@ echo -n "----- " && echo -n "$(printf "%-10s %-23s" node: $(node - echo -n "----- " && echo -n "$(printf "%-10s %-23s" npm: $(npm -v))" && echo " -----" echo "----- -----" echo "----- ENV -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ADMINPORT: $ADMINPORT)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETGID: $SETGID)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETUID: $SETUID)" && echo " -----" echo "$(printf -- '-%.0s' {1..60})" @@ -125,8 +129,8 @@ if [ -f /opt/iobroker/.install_host ] then echo "Looks like this is a new and empty installation of ioBroker." echo "Hostname needs to be updated to " $(hostname)"..." - sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) - rm -f /opt/iobroker/.install_host + sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) + rm -f /opt/iobroker/.install_host echo 'Done.' echo ' ' fi @@ -141,7 +145,17 @@ echo "Some adapters have special requirements which can be activated by the use echo "For more information take a look at readme.md" echo ' ' -# Checking for and setting up avahi-daemon +# Checking ENV for Adminport +if [ "$adminport" != "8081" ] +then + echo "Adminport is set by ENV." + echo "Setting Adminport to" $adminport"..." + iobroker set admin.0 --port $adminport + echo 'Done.' + echo ' ' +fi + +# Checking for enabled avahi-daemon if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." @@ -151,15 +165,33 @@ then echo ' ' fi +# Checking for enabled zwave-support if [ "$zwave" = "true" ] then - echo "ZWave is activated by ENV." + echo "Z-Wave is activated by ENV." chmod 764 /opt/scripts/setup_zwave.sh sh /opt/scripts/setup_zwave.sh echo "Done." echo ' ' fi +# checking enabled usb-devices + +if [ "$usbdevices" != "none" ] +then + echo "Usb-device-support is activated by ENV." + + IFS=';' read -ra devicearray <<< "$usbdevices" + for i in "${devicearray[@]}" + do + echo "Setting permissions for" $i"..." + chown root:dialout $i + chmod g+rw $i + done + echo "Done." + echo ' ' +fi + sleep 5 # Starting ioBroker diff --git a/armv7hf/scripts/setup_avahi.sh b/armv7hf/scripts/setup_avahi.sh index 2f64a72..4fd1ab1 100644 --- a/armv7hf/scripts/setup_avahi.sh +++ b/armv7hf/scripts/setup_avahi.sh @@ -2,7 +2,7 @@ echo "Checking avahi-daemon installation state..." -if [ -f /usr/sbin/avahi-daemon ] +if [ -e /usr/sbin/avahi-daemon ] && [ -e /var/run/dbus ] then echo "Avahi is already installed..." else diff --git a/armv7hf/scripts/setup_zwave.sh b/armv7hf/scripts/setup_zwave.sh index ff1b82f..e9710d0 100644 --- a/armv7hf/scripts/setup_zwave.sh +++ b/armv7hf/scripts/setup_zwave.sh @@ -2,7 +2,7 @@ echo "Checking openzwave installation state..." -if [ -f /usr/local/lib64 ] +if [ -e /usr/local/lib64 ] then echo "Openzwave is already installed..." else @@ -16,4 +16,4 @@ else # echo "Openzwave is now installed..." fi -exit 0 \ No newline at end of file +exit 0 From 6afd8a3f5d19670215629e55c296e89502499097 Mon Sep 17 00:00:00 2001 From: andre <> Date: Sun, 1 Dec 2019 21:46:17 +0100 Subject: [PATCH 18/43] testing --- amd64/Dockerfile | 47 ++++++++++++++++--------------- amd64/scripts/iobroker_startup.sh | 15 ++++++---- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 8141a3b..32fc010 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -12,31 +12,31 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \ curl \ git \ gnupg2 \ - gosu \ - libavahi-compat-libdnssd-dev \ + gosu \ + libavahi-compat-libdnssd-dev \ libcap2-bin \ libpam0g-dev \ libudev-dev \ locales \ - pkg-config \ - procps \ + pkg-config \ + procps \ python \ - python-dev \ - sudo \ + python-dev \ + sudo \ + udev \ unzip \ wget \ && rm -rf /var/lib/apt/lists/* # Install node10 RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ - && apt-get update && apt-get install -y \ - nodejs \ + && apt-get update && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* # Generating locales RUN sed -i 's/^# *\(de_DE.UTF-8\)/\1/' /etc/locale.gen \ - && sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \ - && locale-gen + && sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \ + && locale-gen # Create scripts directory and copy scripts RUN mkdir -p /opt/scripts/ \ @@ -47,7 +47,7 @@ COPY scripts/setup_avahi.sh setup_avahi.sh COPY scripts/setup_packages.sh setup_packages.sh COPY scripts/setup_zwave.sh setup_zwave.sh RUN chmod +x iobroker_startup.sh \ - && chmod +x setup_avahi.sh \ + && chmod +x setup_avahi.sh \ && chmod +x setup_packages.sh # Install ioBroker @@ -70,18 +70,19 @@ RUN chsh -s /bin/bash iobroker \ && usermod --home /opt/iobroker iobroker # Setting up ENVs -ENV DEBIAN_FRONTEND="teletype" \ - LANG="de_DE.UTF-8" \ - LANGUAGE="de_DE:de" \ - LC_ALL="de_DE.UTF-8" \ - TZ="Europe/Berlin" \ - PACKAGES="vi" \ - ADMINPORT=8081 \ - SETUID=1000 \ - SETGID=1000 \ - AVAHI="false" \ - ZWAVE="false" \ - USBDEVICES="none" +ENV ADMINPORT=8081 \ + AVAHI="false" \ + DEBIAN_FRONTEND="teletype" \ + LANG="de_DE.UTF-8" \ + LANGUAGE="de_DE:de" \ + LC_ALL="de_DE.UTF-8" \ + PACKAGES="vi" \ + REDIS="false" + SETGID=1000 \ + SETUID=1000 \ + TZ="Europe/Berlin" \ + USBDEVICES="none" \ + ZWAVE="false" # Run startup-script ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 4e40f6f..6b8407e 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -1,13 +1,14 @@ #!/bin/bash # Reading ENV -packages=$PACKAGES adminport=$ADMINPORT -uid=$SETUID -gid=$SETGID -zwave=$ZWAVE avahi=$AVAHI +gid=$SETGID +packages=$PACKAGES +redis=$REDIS +uid=$SETUID usbdevices=$USBDEVICES +zwave=$ZWAVE # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` @@ -36,12 +37,14 @@ echo -n "----- " && echo -n "$(printf "%-10s %-23s" node: $(node - echo -n "----- " && echo -n "$(printf "%-10s %-23s" npm: $(npm -v))" && echo " -----" echo "----- -----" echo "----- ENV -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" ADMINPORT: $ADMINPORT)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" REDIS: $REDIS)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETGID: $SETGID)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETUID: $SETUID)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" USBDEVICES: $USBDEVICES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' From cb1fc55235f206f82909ed6aa9951480a9c75bfa Mon Sep 17 00:00:00 2001 From: Andre Date: Sun, 1 Dec 2019 21:55:09 +0100 Subject: [PATCH 19/43] testing --- amd64/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 32fc010..1da5a9f 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -77,7 +77,7 @@ ENV ADMINPORT=8081 \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ PACKAGES="vi" \ - REDIS="false" + REDIS="false" \ SETGID=1000 \ SETUID=1000 \ TZ="Europe/Berlin" \ From 4376b6398152629b85cff3e16dc66627e792d637 Mon Sep 17 00:00:00 2001 From: buanet Date: Mon, 2 Dec 2019 11:48:14 +0100 Subject: [PATCH 20/43] testing --- amd64/scripts/iobroker_startup.sh | 65 ++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 6b8407e..f0359a7 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -13,7 +13,7 @@ zwave=$ZWAVE # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` -# Header +# Logging header echo ' ' echo "$(printf -- '-%.0s' {1..60})" echo -n "$(printf -- '-%.0s' {1..15})" && echo -n " "$dati" " && echo "$(printf -- '-%.0s' {1..15})" @@ -48,14 +48,24 @@ echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE) echo "$(printf -- '-%.0s' {1..60})" echo ' ' -# Checking and installing additional packages + +# Not in use +# if [ -f /opt/.firstrun ] +# rm -f /opt/.firstrun + + +##### +# STEP 1 - Preparing container +##### echo "$(printf -- '-%.0s' {1..60})" -echo "----- Step 1 of 5: Installing additional packages -----" +echo "----- Step 1 of 5: Preparing container -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' +# Installing additional packages if [ "$packages" != "" ] then + echo "Installing additional packages is set by ENV." echo "The following packages will be installed:" $packages"..." echo $packages > /opt/scripts/.packages sh /opt/scripts/setup_packages.sh > /opt/scripts/setup_packages.log 2>&1 @@ -65,10 +75,26 @@ else fi echo ' ' +# Checking and setting uid/gid +gidold=`cat /etc/group | grep "iobroker:" | cut -d":" -f3` +uidold=`cat /etc/passwd | grep "iobroker:" | cut -d":" -f3` +if [ $gidold != $gid || $uidold != $uid ] +then + echo "Different UID and/ or GID is set by ENV." + echo "Changing UID to "$uid" and GID to "$gid"..." + usermod -u $uid iobroker + groupmod -g $gid iobroker + echo "Done." + echo ' ' +fi + # Change directory for next steps cd /opt/iobroker + +##### # Detecting ioBroker-Installation +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 2 of 5: Detecting ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" @@ -91,27 +117,15 @@ else fi echo ' ' + +##### # Checking ioBroker-Installation +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 3 of 5: Checking ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -# Checking for first run and set uid/gid -if [ -f /opt/.firstrun ] -then - echo "This is the first run of a new container. Time for some preparation." - echo ' ' - echo "Changing UID to "$uid" and GID to "$gid"..." - usermod -u $uid iobroker - groupmod -g $gid iobroker - rm -f /opt/.firstrun - echo "Done." -else - echo "This is NOT the first run of the container. Some Steps will be skipped." -fi -echo ' ' - # (Re)Setting permissions to "/opt/iobroker" and "/opt/scripts" echo "(Re)Setting folder permissions (This might take a while! Please be patient!)..." chown -R $uid:$gid /opt/iobroker @@ -138,7 +152,10 @@ then echo ' ' fi + +##### # Setting up prerequisites for some ioBroker-adapters +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 4 of 5: Applying special settings -----" echo "$(printf -- '-%.0s' {1..60})" @@ -158,7 +175,7 @@ then echo ' ' fi -# Checking for enabled avahi-daemon +# Checking ENV for AVAHI if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." @@ -168,7 +185,7 @@ then echo ' ' fi -# Checking for enabled zwave-support +# Checking ENV for Z-WAVE if [ "$zwave" = "true" ] then echo "Z-Wave is activated by ENV." @@ -178,8 +195,7 @@ then echo ' ' fi -# checking enabled usb-devices - +# checking ENV for USBDEVICES if [ "$usbdevices" != "none" ] then echo "Usb-device-support is activated by ENV." @@ -197,14 +213,17 @@ fi sleep 5 + +##### # Starting ioBroker +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 5 of 5: ioBroker startup -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' echo "Starting ioBroker..." echo ' ' -#gosu iobroker node --trace-warnings node_modules/iobroker.js-controller/controller.js > /opt/iobroker/iobroker.log 2>&1 & + gosu iobroker node node_modules/iobroker.js-controller/controller.js # Preventing container restart by keeping a process alive even if iobroker will be stopped From f6f056d0b33bd5c4a797fa254298508f8b2ce053 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 9 Dec 2019 09:00:02 +0100 Subject: [PATCH 21/43] testing --- amd64/scripts/iobroker_startup.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index f0359a7..028b158 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -76,9 +76,7 @@ fi echo ' ' # Checking and setting uid/gid -gidold=`cat /etc/group | grep "iobroker:" | cut -d":" -f3` -uidold=`cat /etc/passwd | grep "iobroker:" | cut -d":" -f3` -if [ $gidold != $gid || $uidold != $uid ] +if [ $(cat /etc/group | grep 'iobroker:' | cut -d':' -f3) != $gid ] || [ $(cat /etc/passwd | grep 'iobroker:' | cut -d':' -f3) != $uid ] then echo "Different UID and/ or GID is set by ENV." echo "Changing UID to "$uid" and GID to "$gid"..." From 840e35d922bd9349a8ad09d6968c613c1167c8e7 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 9 Dec 2019 12:03:04 +0100 Subject: [PATCH 22/43] testing --- amd64/scripts/iobroker_startup.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 028b158..36f6ccb 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -83,8 +83,10 @@ then usermod -u $uid iobroker groupmod -g $gid iobroker echo "Done." - echo ' ' +else + echo "There are no changes in UID/ GID needed." fi +echo ' ' # Change directory for next steps cd /opt/iobroker @@ -100,16 +102,16 @@ echo ' ' if [ `ls -1a|wc -l` -lt 3 ] then - echo "There is no data detected in /opt/iobroker. Restoring..." + echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..." tar -xf /opt/initial_iobroker.tar -C / echo "Done." else if [ -f /opt/iobroker/iobroker ] then - echo "Installation of ioBroker detected in /opt/iobroker." + echo "Existing installation of ioBroker detected in /opt/iobroker." else echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." exit 1 fi fi @@ -132,7 +134,7 @@ echo "Done." echo ' ' # Backing up original iobroker-file and changing sudo to gosu -echo "Fixing \"sudo-bug\" by replacing sudo with gosu..." +echo "Fixing \"sudo-bug\" by replacing sudo in iobroker with gosu..." cp -a /opt/iobroker/iobroker /opt/iobroker/iobroker.bak chmod 755 /opt/iobroker/iobroker sed -i 's/sudo -H -u/gosu/g' /opt/iobroker/iobroker @@ -148,6 +150,12 @@ then rm -f /opt/iobroker/.install_host echo 'Done.' echo ' ' +else if [ $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ] + echo "Hostname in ioBroker does not match the hostname of this container." + echo "Updating hostname to " $(hostname)"..." + sh /opt/iobroker/iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + echo 'Done.' + echo ' ' fi @@ -159,14 +167,14 @@ echo "----- Step 4 of 5: Applying special settings -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -echo "Some adapters have special requirements which can be activated by the use of environment variables." -echo "For more information take a look at readme.md" +echo "Some adapters have special requirements/ settings which can be activated by the use of environment variables." +echo "For more information take a look at readme.md on Github!" echo ' ' # Checking ENV for Adminport -if [ "$adminport" != "8081" ] +if [ "$adminport" != $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="port": )[^,]*') ] then - echo "Adminport is set by ENV." + echo "Adminport set by ENV does not match port configured in ioBroker installation." echo "Setting Adminport to" $adminport"..." iobroker set admin.0 --port $adminport echo 'Done.' From 5319305d0bc7c7baf6ee5bf984e3f94a5b999f1e Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 9 Dec 2019 12:20:50 +0100 Subject: [PATCH 23/43] testing --- amd64/scripts/iobroker_startup.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 36f6ccb..936170f 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -217,6 +217,18 @@ then echo ' ' fi +# Checking ENV for REDIS +if [ "$redis" != "false" ] +then + echo "Connection to Redis is configured by ENV." + echo "Installing prerequisites..." + apt-get update 2>&1> /dev/null && apt-get install -y jq 2>&1> /dev/null && rm -rf /var/lib/apt/lists/* + echo "Setting configuration for Redis in ioBroker..." + # missing + echo "Done." + echo ' ' +fi + sleep 5 From 44de2a1ec5209060024e7b789c413930647229c1 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 9 Dec 2019 14:48:00 +0100 Subject: [PATCH 24/43] testing --- amd64/scripts/iobroker_startup.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 936170f..dfa131c 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -150,7 +150,8 @@ then rm -f /opt/iobroker/.install_host echo 'Done.' echo ' ' -else if [ $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ] +elif [ $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ] +then echo "Hostname in ioBroker does not match the hostname of this container." echo "Updating hostname to " $(hostname)"..." sh /opt/iobroker/iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') @@ -222,9 +223,13 @@ if [ "$redis" != "false" ] then echo "Connection to Redis is configured by ENV." echo "Installing prerequisites..." - apt-get update 2>&1> /dev/null && apt-get install -y jq 2>&1> /dev/null && rm -rf /var/lib/apt/lists/* - echo "Setting configuration for Redis in ioBroker..." - # missing + apt-get update 2>&1> /dev/null && apt-get install -y jq 2>&1> /dev/null && rm -rf /var/lib/apt/lists/* 2>&1> /dev/null + redisserver=$(echo $redis | sed -E 's/(.*):(.*)/\1/') + redisport=$(echo $redis | sed -E 's/(.*):(.*)/\2/') + echo "Setting configuration for Redis (Server: "$redisserver", Port: "$redisport") in ioBroker..." + cd /opt/iobroker/iobroker-data + jq '.states.type = "redis" | .states.host = "$redisserver" | .states.port = "$redisport"' iobroker.json > iobroker.json.tmp && mv iobroker.json.tmp iobroker.json + cd /opt/iobroker echo "Done." echo ' ' fi From b560dfa84032d9607ecee6b09c1986cd37f6b0b7 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 9 Dec 2019 15:14:39 +0100 Subject: [PATCH 25/43] testing --- amd64/scripts/iobroker_startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index dfa131c..9805355 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -228,7 +228,7 @@ then redisport=$(echo $redis | sed -E 's/(.*):(.*)/\2/') echo "Setting configuration for Redis (Server: "$redisserver", Port: "$redisport") in ioBroker..." cd /opt/iobroker/iobroker-data - jq '.states.type = "redis" | .states.host = "$redisserver" | .states.port = "$redisport"' iobroker.json > iobroker.json.tmp && mv iobroker.json.tmp iobroker.json + jq --arg redisserver "$redisserver" --arg redisport "$redisport" '.states.type = "redis" | .states.host = $redisserver | .states.port = $redisport' iobroker.json > iobroker.json.tmp && mv iobroker.json.tmp iobroker.json cd /opt/iobroker echo "Done." echo ' ' From bc85322275802efd5f75c7a3792442b3145c94f1 Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 10 Dec 2019 13:27:30 +0100 Subject: [PATCH 26/43] beta preparation --- .VERSION | 2 +- README.md | 40 +++++----- aarch64/Dockerfile | 47 +++++------ aarch64/scripts/iobroker_startup.sh | 119 +++++++++++++++++++--------- armv7hf/Dockerfile | 47 +++++------ armv7hf/scripts/iobroker_startup.sh | 119 +++++++++++++++++++--------- 6 files changed, 235 insertions(+), 139 deletions(-) diff --git a/.VERSION b/.VERSION index ecdba1c..97a50b0 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v4.0.1beta +v4.0.2beta diff --git a/README.md b/README.md index 7798035..5d1af31 100644 --- a/README.md +++ b/README.md @@ -32,19 +32,20 @@ The following will give a short overview. Since v3 is possible to set some environment variables to configure a new container. -|env|value|description| -|---|---|---| -|PACKAGES|package1 package2 package2|seperateed by whitespace; will install the listed packages on startup
(be paitient, this may take some time!)| -|AVAHI|true|will install and activate avahi-daemon for supporting yahka-adapter| -|LANGUAGE|de_DE:de|following locales are pre-generated: de_DE:de, en_US:en| -|LANG|de_DE.UTF-8|following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| -|LC_ALL|de_DE|following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| -|TZ|Europe/Berlin|all valid Linux-timezones| -|SETUID|1000|for security reasons it might be useful to specify the uid of the containers iobroker user to match an existing user on the docker host| -|SETGID|1000|for security reasons it might be useful to specify the gid of the containers iobroker user to match an existing group on the docker host| -|ZWAVE|false|will install openzwave to support zwave-adapter| -|ADMINPORT|8081|for setting iobroker adminport (beta feature!)| -|USBDEVICES|none|for automatically setting permissions on mounted devices like "/dev/ttyACM0". For more than one device separate with ";" (beta feature!)| +|env|default|values|description| +|---|---|---|---| +|ADMINPORT|8081|portnumber|Sets ioBroker-adminport on startup (beta)| +|AVAHI|false|true/false|Installs and activates avahi-daemon for supporting yahka-adapter| +|LANG|de_DE.UTF-8|locales|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| +|LANGUAGE|de_DE:de|locales|The following locales are pre-generated: de_DE:de, en_US:en| +|LC_ALL|de_DE|locales|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| +|PACKAGES|vi|package1 package2 package2|Installs additional packages to your container, needed by some adapters, packages should be seperated by whitespace| +|REDIS|false|false/hostname:port|Activates redis as states-db on startup, fill with "hostname:port" to set redis connection (beta)| +|SETGID|1000|idnumber|For security reasons it might be useful to specify the gid of the containers iobroker user to match an existing group on the docker host| +|SETUID|1000|idnumber|For security reasons it might be useful to specify the uid of the containers iobroker user to match an existing user on the docker host| +|TZ|Europe/Berlin|timezone|All valid Linux-timezones| +|USBDEVICES|none|none/device-path|Sets relevant permissions on mounted devices like "/dev/ttyACM0", for more than one device separate with ";" (beta)| +|ZWAVE|false|true/false|will install openzwave to support zwave-adapter| ### Mounting Folder/ Volume @@ -60,11 +61,14 @@ After some issues with permissions related to the use of a dedicated user for io ## Changelog -### v4.0.1beta (2019-11-25) -* added env for iobroker admin port -* added env for usb-devices (setting permissions) -* updateing prerequisites for iobroker installation -* some small codefixes +### v4.0.2beta (2019-12-10) +* added env for activating redis +* enhancements in startupscript and dockerfile +* v4.0.1beta (2019-11-25) + * added env for iobroker admin port + * added env for usb-devices (setting permissions) + * updateing prerequisites for iobroker installation + * some small codefixes ### v4.0.0 (2019-10-25) * v3.1.4beta (2019-10-23) diff --git a/aarch64/Dockerfile b/aarch64/Dockerfile index 4551331..8dc774e 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -12,31 +12,31 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \ curl \ git \ gnupg2 \ - gosu \ - libavahi-compat-libdnssd-dev \ + gosu \ + libavahi-compat-libdnssd-dev \ libcap2-bin \ libpam0g-dev \ libudev-dev \ locales \ - pkg-config \ - procps \ + pkg-config \ + procps \ python \ - python-dev \ - sudo \ + python-dev \ + sudo \ + udev \ unzip \ wget \ && rm -rf /var/lib/apt/lists/* # Install node10 RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ - && apt-get update && apt-get install -y \ - nodejs \ + && apt-get update && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* # Generating locales RUN sed -i 's/^# *\(de_DE.UTF-8\)/\1/' /etc/locale.gen \ - && sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \ - && locale-gen + && sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \ + && locale-gen # Create scripts directory and copy scripts RUN mkdir -p /opt/scripts/ \ @@ -47,7 +47,7 @@ COPY scripts/setup_avahi.sh setup_avahi.sh COPY scripts/setup_packages.sh setup_packages.sh COPY scripts/setup_zwave.sh setup_zwave.sh RUN chmod +x iobroker_startup.sh \ - && chmod +x setup_avahi.sh \ + && chmod +x setup_avahi.sh \ && chmod +x setup_packages.sh # Install ioBroker @@ -70,18 +70,19 @@ RUN chsh -s /bin/bash iobroker \ && usermod --home /opt/iobroker iobroker # Setting up ENVs -ENV DEBIAN_FRONTEND="teletype" \ - LANG="de_DE.UTF-8" \ - LANGUAGE="de_DE:de" \ - LC_ALL="de_DE.UTF-8" \ - TZ="Europe/Berlin" \ - PACKAGES="vi" \ - ADMINPORT=8081 \ - SETUID=1000 \ - SETGID=1000 \ - AVAHI="false" \ - ZWAVE="false" \ - USBDEVICES="none" +ENV ADMINPORT=8081 \ + AVAHI="false" \ + DEBIAN_FRONTEND="teletype" \ + LANG="de_DE.UTF-8" \ + LANGUAGE="de_DE:de" \ + LC_ALL="de_DE.UTF-8" \ + PACKAGES="vi" \ + REDIS="false" \ + SETGID=1000 \ + SETUID=1000 \ + TZ="Europe/Berlin" \ + USBDEVICES="none" \ + ZWAVE="false" # Run startup-script ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 4e40f6f..9805355 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -1,18 +1,19 @@ #!/bin/bash # Reading ENV -packages=$PACKAGES adminport=$ADMINPORT -uid=$SETUID -gid=$SETGID -zwave=$ZWAVE avahi=$AVAHI +gid=$SETGID +packages=$PACKAGES +redis=$REDIS +uid=$SETUID usbdevices=$USBDEVICES +zwave=$ZWAVE # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` -# Header +# Logging header echo ' ' echo "$(printf -- '-%.0s' {1..60})" echo -n "$(printf -- '-%.0s' {1..15})" && echo -n " "$dati" " && echo "$(printf -- '-%.0s' {1..15})" @@ -36,23 +37,35 @@ echo -n "----- " && echo -n "$(printf "%-10s %-23s" node: $(node - echo -n "----- " && echo -n "$(printf "%-10s %-23s" npm: $(npm -v))" && echo " -----" echo "----- -----" echo "----- ENV -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" ADMINPORT: $ADMINPORT)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" REDIS: $REDIS)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETGID: $SETGID)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETUID: $SETUID)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" USBDEVICES: $USBDEVICES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -# Checking and installing additional packages + +# Not in use +# if [ -f /opt/.firstrun ] +# rm -f /opt/.firstrun + + +##### +# STEP 1 - Preparing container +##### echo "$(printf -- '-%.0s' {1..60})" -echo "----- Step 1 of 5: Installing additional packages -----" +echo "----- Step 1 of 5: Preparing container -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' +# Installing additional packages if [ "$packages" != "" ] then + echo "Installing additional packages is set by ENV." echo "The following packages will be installed:" $packages"..." echo $packages > /opt/scripts/.packages sh /opt/scripts/setup_packages.sh > /opt/scripts/setup_packages.log 2>&1 @@ -62,10 +75,26 @@ else fi echo ' ' +# Checking and setting uid/gid +if [ $(cat /etc/group | grep 'iobroker:' | cut -d':' -f3) != $gid ] || [ $(cat /etc/passwd | grep 'iobroker:' | cut -d':' -f3) != $uid ] +then + echo "Different UID and/ or GID is set by ENV." + echo "Changing UID to "$uid" and GID to "$gid"..." + usermod -u $uid iobroker + groupmod -g $gid iobroker + echo "Done." +else + echo "There are no changes in UID/ GID needed." +fi +echo ' ' + # Change directory for next steps cd /opt/iobroker + +##### # Detecting ioBroker-Installation +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 2 of 5: Detecting ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" @@ -73,42 +102,30 @@ echo ' ' if [ `ls -1a|wc -l` -lt 3 ] then - echo "There is no data detected in /opt/iobroker. Restoring..." + echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..." tar -xf /opt/initial_iobroker.tar -C / echo "Done." else if [ -f /opt/iobroker/iobroker ] then - echo "Installation of ioBroker detected in /opt/iobroker." + echo "Existing installation of ioBroker detected in /opt/iobroker." else echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." exit 1 fi fi echo ' ' + +##### # Checking ioBroker-Installation +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 3 of 5: Checking ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -# Checking for first run and set uid/gid -if [ -f /opt/.firstrun ] -then - echo "This is the first run of a new container. Time for some preparation." - echo ' ' - echo "Changing UID to "$uid" and GID to "$gid"..." - usermod -u $uid iobroker - groupmod -g $gid iobroker - rm -f /opt/.firstrun - echo "Done." -else - echo "This is NOT the first run of the container. Some Steps will be skipped." -fi -echo ' ' - # (Re)Setting permissions to "/opt/iobroker" and "/opt/scripts" echo "(Re)Setting folder permissions (This might take a while! Please be patient!)..." chown -R $uid:$gid /opt/iobroker @@ -117,7 +134,7 @@ echo "Done." echo ' ' # Backing up original iobroker-file and changing sudo to gosu -echo "Fixing \"sudo-bug\" by replacing sudo with gosu..." +echo "Fixing \"sudo-bug\" by replacing sudo in iobroker with gosu..." cp -a /opt/iobroker/iobroker /opt/iobroker/iobroker.bak chmod 755 /opt/iobroker/iobroker sed -i 's/sudo -H -u/gosu/g' /opt/iobroker/iobroker @@ -133,29 +150,39 @@ then rm -f /opt/iobroker/.install_host echo 'Done.' echo ' ' +elif [ $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ] +then + echo "Hostname in ioBroker does not match the hostname of this container." + echo "Updating hostname to " $(hostname)"..." + sh /opt/iobroker/iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + echo 'Done.' + echo ' ' fi + +##### # Setting up prerequisites for some ioBroker-adapters +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 4 of 5: Applying special settings -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -echo "Some adapters have special requirements which can be activated by the use of environment variables." -echo "For more information take a look at readme.md" +echo "Some adapters have special requirements/ settings which can be activated by the use of environment variables." +echo "For more information take a look at readme.md on Github!" echo ' ' # Checking ENV for Adminport -if [ "$adminport" != "8081" ] +if [ "$adminport" != $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="port": )[^,]*') ] then - echo "Adminport is set by ENV." + echo "Adminport set by ENV does not match port configured in ioBroker installation." echo "Setting Adminport to" $adminport"..." iobroker set admin.0 --port $adminport echo 'Done.' echo ' ' fi -# Checking for enabled avahi-daemon +# Checking ENV for AVAHI if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." @@ -165,7 +192,7 @@ then echo ' ' fi -# Checking for enabled zwave-support +# Checking ENV for Z-WAVE if [ "$zwave" = "true" ] then echo "Z-Wave is activated by ENV." @@ -175,8 +202,7 @@ then echo ' ' fi -# checking enabled usb-devices - +# checking ENV for USBDEVICES if [ "$usbdevices" != "none" ] then echo "Usb-device-support is activated by ENV." @@ -192,16 +218,35 @@ then echo ' ' fi +# Checking ENV for REDIS +if [ "$redis" != "false" ] +then + echo "Connection to Redis is configured by ENV." + echo "Installing prerequisites..." + apt-get update 2>&1> /dev/null && apt-get install -y jq 2>&1> /dev/null && rm -rf /var/lib/apt/lists/* 2>&1> /dev/null + redisserver=$(echo $redis | sed -E 's/(.*):(.*)/\1/') + redisport=$(echo $redis | sed -E 's/(.*):(.*)/\2/') + echo "Setting configuration for Redis (Server: "$redisserver", Port: "$redisport") in ioBroker..." + cd /opt/iobroker/iobroker-data + jq --arg redisserver "$redisserver" --arg redisport "$redisport" '.states.type = "redis" | .states.host = $redisserver | .states.port = $redisport' iobroker.json > iobroker.json.tmp && mv iobroker.json.tmp iobroker.json + cd /opt/iobroker + echo "Done." + echo ' ' +fi + sleep 5 + +##### # Starting ioBroker +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 5 of 5: ioBroker startup -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' echo "Starting ioBroker..." echo ' ' -#gosu iobroker node --trace-warnings node_modules/iobroker.js-controller/controller.js > /opt/iobroker/iobroker.log 2>&1 & + gosu iobroker node node_modules/iobroker.js-controller/controller.js # Preventing container restart by keeping a process alive even if iobroker will be stopped diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index 120093a..83e3f4a 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -12,31 +12,31 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \ curl \ git \ gnupg2 \ - gosu \ - libavahi-compat-libdnssd-dev \ + gosu \ + libavahi-compat-libdnssd-dev \ libcap2-bin \ libpam0g-dev \ libudev-dev \ locales \ - pkg-config \ - procps \ + pkg-config \ + procps \ python \ - python-dev \ - sudo \ + python-dev \ + sudo \ + udev \ unzip \ wget \ && rm -rf /var/lib/apt/lists/* # Install node10 RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ - && apt-get update && apt-get install -y \ - nodejs \ + && apt-get update && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* # Generating locales RUN sed -i 's/^# *\(de_DE.UTF-8\)/\1/' /etc/locale.gen \ - && sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \ - && locale-gen + && sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \ + && locale-gen # Create scripts directory and copy scripts RUN mkdir -p /opt/scripts/ \ @@ -47,7 +47,7 @@ COPY scripts/setup_avahi.sh setup_avahi.sh COPY scripts/setup_packages.sh setup_packages.sh COPY scripts/setup_zwave.sh setup_zwave.sh RUN chmod +x iobroker_startup.sh \ - && chmod +x setup_avahi.sh \ + && chmod +x setup_avahi.sh \ && chmod +x setup_packages.sh # Install ioBroker @@ -70,18 +70,19 @@ RUN chsh -s /bin/bash iobroker \ && usermod --home /opt/iobroker iobroker # Setting up ENVs -ENV DEBIAN_FRONTEND="teletype" \ - LANG="de_DE.UTF-8" \ - LANGUAGE="de_DE:de" \ - LC_ALL="de_DE.UTF-8" \ - TZ="Europe/Berlin" \ - PACKAGES="vi" \ - ADMINPORT=8081 \ - SETUID=1000 \ - SETGID=1000 \ - AVAHI="false" \ - ZWAVE="false" \ - USBDEVICES="none" +ENV ADMINPORT=8081 \ + AVAHI="false" \ + DEBIAN_FRONTEND="teletype" \ + LANG="de_DE.UTF-8" \ + LANGUAGE="de_DE:de" \ + LC_ALL="de_DE.UTF-8" \ + PACKAGES="vi" \ + REDIS="false" \ + SETGID=1000 \ + SETUID=1000 \ + TZ="Europe/Berlin" \ + USBDEVICES="none" \ + ZWAVE="false" # Run startup-script ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 4e40f6f..9805355 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -1,18 +1,19 @@ #!/bin/bash # Reading ENV -packages=$PACKAGES adminport=$ADMINPORT -uid=$SETUID -gid=$SETGID -zwave=$ZWAVE avahi=$AVAHI +gid=$SETGID +packages=$PACKAGES +redis=$REDIS +uid=$SETUID usbdevices=$USBDEVICES +zwave=$ZWAVE # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` -# Header +# Logging header echo ' ' echo "$(printf -- '-%.0s' {1..60})" echo -n "$(printf -- '-%.0s' {1..15})" && echo -n " "$dati" " && echo "$(printf -- '-%.0s' {1..15})" @@ -36,23 +37,35 @@ echo -n "----- " && echo -n "$(printf "%-10s %-23s" node: $(node - echo -n "----- " && echo -n "$(printf "%-10s %-23s" npm: $(npm -v))" && echo " -----" echo "----- -----" echo "----- ENV -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" ADMINPORT: $ADMINPORT)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" REDIS: $REDIS)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETGID: $SETGID)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETUID: $SETUID)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" USBDEVICES: $USBDEVICES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -# Checking and installing additional packages + +# Not in use +# if [ -f /opt/.firstrun ] +# rm -f /opt/.firstrun + + +##### +# STEP 1 - Preparing container +##### echo "$(printf -- '-%.0s' {1..60})" -echo "----- Step 1 of 5: Installing additional packages -----" +echo "----- Step 1 of 5: Preparing container -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' +# Installing additional packages if [ "$packages" != "" ] then + echo "Installing additional packages is set by ENV." echo "The following packages will be installed:" $packages"..." echo $packages > /opt/scripts/.packages sh /opt/scripts/setup_packages.sh > /opt/scripts/setup_packages.log 2>&1 @@ -62,10 +75,26 @@ else fi echo ' ' +# Checking and setting uid/gid +if [ $(cat /etc/group | grep 'iobroker:' | cut -d':' -f3) != $gid ] || [ $(cat /etc/passwd | grep 'iobroker:' | cut -d':' -f3) != $uid ] +then + echo "Different UID and/ or GID is set by ENV." + echo "Changing UID to "$uid" and GID to "$gid"..." + usermod -u $uid iobroker + groupmod -g $gid iobroker + echo "Done." +else + echo "There are no changes in UID/ GID needed." +fi +echo ' ' + # Change directory for next steps cd /opt/iobroker + +##### # Detecting ioBroker-Installation +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 2 of 5: Detecting ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" @@ -73,42 +102,30 @@ echo ' ' if [ `ls -1a|wc -l` -lt 3 ] then - echo "There is no data detected in /opt/iobroker. Restoring..." + echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..." tar -xf /opt/initial_iobroker.tar -C / echo "Done." else if [ -f /opt/iobroker/iobroker ] then - echo "Installation of ioBroker detected in /opt/iobroker." + echo "Existing installation of ioBroker detected in /opt/iobroker." else echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." exit 1 fi fi echo ' ' + +##### # Checking ioBroker-Installation +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 3 of 5: Checking ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -# Checking for first run and set uid/gid -if [ -f /opt/.firstrun ] -then - echo "This is the first run of a new container. Time for some preparation." - echo ' ' - echo "Changing UID to "$uid" and GID to "$gid"..." - usermod -u $uid iobroker - groupmod -g $gid iobroker - rm -f /opt/.firstrun - echo "Done." -else - echo "This is NOT the first run of the container. Some Steps will be skipped." -fi -echo ' ' - # (Re)Setting permissions to "/opt/iobroker" and "/opt/scripts" echo "(Re)Setting folder permissions (This might take a while! Please be patient!)..." chown -R $uid:$gid /opt/iobroker @@ -117,7 +134,7 @@ echo "Done." echo ' ' # Backing up original iobroker-file and changing sudo to gosu -echo "Fixing \"sudo-bug\" by replacing sudo with gosu..." +echo "Fixing \"sudo-bug\" by replacing sudo in iobroker with gosu..." cp -a /opt/iobroker/iobroker /opt/iobroker/iobroker.bak chmod 755 /opt/iobroker/iobroker sed -i 's/sudo -H -u/gosu/g' /opt/iobroker/iobroker @@ -133,29 +150,39 @@ then rm -f /opt/iobroker/.install_host echo 'Done.' echo ' ' +elif [ $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ] +then + echo "Hostname in ioBroker does not match the hostname of this container." + echo "Updating hostname to " $(hostname)"..." + sh /opt/iobroker/iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + echo 'Done.' + echo ' ' fi + +##### # Setting up prerequisites for some ioBroker-adapters +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 4 of 5: Applying special settings -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -echo "Some adapters have special requirements which can be activated by the use of environment variables." -echo "For more information take a look at readme.md" +echo "Some adapters have special requirements/ settings which can be activated by the use of environment variables." +echo "For more information take a look at readme.md on Github!" echo ' ' # Checking ENV for Adminport -if [ "$adminport" != "8081" ] +if [ "$adminport" != $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="port": )[^,]*') ] then - echo "Adminport is set by ENV." + echo "Adminport set by ENV does not match port configured in ioBroker installation." echo "Setting Adminport to" $adminport"..." iobroker set admin.0 --port $adminport echo 'Done.' echo ' ' fi -# Checking for enabled avahi-daemon +# Checking ENV for AVAHI if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." @@ -165,7 +192,7 @@ then echo ' ' fi -# Checking for enabled zwave-support +# Checking ENV for Z-WAVE if [ "$zwave" = "true" ] then echo "Z-Wave is activated by ENV." @@ -175,8 +202,7 @@ then echo ' ' fi -# checking enabled usb-devices - +# checking ENV for USBDEVICES if [ "$usbdevices" != "none" ] then echo "Usb-device-support is activated by ENV." @@ -192,16 +218,35 @@ then echo ' ' fi +# Checking ENV for REDIS +if [ "$redis" != "false" ] +then + echo "Connection to Redis is configured by ENV." + echo "Installing prerequisites..." + apt-get update 2>&1> /dev/null && apt-get install -y jq 2>&1> /dev/null && rm -rf /var/lib/apt/lists/* 2>&1> /dev/null + redisserver=$(echo $redis | sed -E 's/(.*):(.*)/\1/') + redisport=$(echo $redis | sed -E 's/(.*):(.*)/\2/') + echo "Setting configuration for Redis (Server: "$redisserver", Port: "$redisport") in ioBroker..." + cd /opt/iobroker/iobroker-data + jq --arg redisserver "$redisserver" --arg redisport "$redisport" '.states.type = "redis" | .states.host = $redisserver | .states.port = $redisport' iobroker.json > iobroker.json.tmp && mv iobroker.json.tmp iobroker.json + cd /opt/iobroker + echo "Done." + echo ' ' +fi + sleep 5 + +##### # Starting ioBroker +##### echo "$(printf -- '-%.0s' {1..60})" echo "----- Step 5 of 5: ioBroker startup -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' echo "Starting ioBroker..." echo ' ' -#gosu iobroker node --trace-warnings node_modules/iobroker.js-controller/controller.js > /opt/iobroker/iobroker.log 2>&1 & + gosu iobroker node node_modules/iobroker.js-controller/controller.js # Preventing container restart by keeping a process alive even if iobroker will be stopped From 027e67747144442dc1135f095d3ad169e6f93990 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 12 Dec 2019 07:37:33 +0100 Subject: [PATCH 27/43] Update README.md --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5d1af31..0cb14ea 100644 --- a/README.md +++ b/README.md @@ -32,20 +32,20 @@ The following will give a short overview. Since v3 is possible to set some environment variables to configure a new container. -|env|default|values|description| -|---|---|---|---| -|ADMINPORT|8081|portnumber|Sets ioBroker-adminport on startup (beta)| -|AVAHI|false|true/false|Installs and activates avahi-daemon for supporting yahka-adapter| -|LANG|de_DE.UTF-8|locales|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| -|LANGUAGE|de_DE:de|locales|The following locales are pre-generated: de_DE:de, en_US:en| -|LC_ALL|de_DE|locales|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| -|PACKAGES|vi|package1 package2 package2|Installs additional packages to your container, needed by some adapters, packages should be seperated by whitespace| -|REDIS|false|false/hostname:port|Activates redis as states-db on startup, fill with "hostname:port" to set redis connection (beta)| -|SETGID|1000|idnumber|For security reasons it might be useful to specify the gid of the containers iobroker user to match an existing group on the docker host| -|SETUID|1000|idnumber|For security reasons it might be useful to specify the uid of the containers iobroker user to match an existing user on the docker host| -|TZ|Europe/Berlin|timezone|All valid Linux-timezones| -|USBDEVICES|none|none/device-path|Sets relevant permissions on mounted devices like "/dev/ttyACM0", for more than one device separate with ";" (beta)| -|ZWAVE|false|true/false|will install openzwave to support zwave-adapter| +|env|default|description| +|---|---|---| +|ADMINPORT|8081|Sets ioBroker-adminport on startup (beta)| +|AVAHI|false|Installs and activates avahi-daemon for supporting yahka-adapter, can be "true" or "false"| +|LANG|de_DE.UTF-8|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| +|LANGUAGE|de_DE:de|The following locales are pre-generated: de_DE:de, en_US:en| +|LC_ALL|de_DE|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| +|PACKAGES|vi|Installs additional packages to your container, needed by some adapters, packages should be seperated by whitespace like "package1 package2 package3"| +|REDIS|false|Activates redis as states-db on startup, fill with "hostname:port" to set redis connection otherwise use "false"(beta)| +|SETGID|1000|For security reasons it might be useful to specify the gid of the containers iobroker user to match an existing group on the docker host| +|SETUID|1000|For security reasons it might be useful to specify the uid of the containers iobroker user to match an existing user on the docker host| +|TZ|Europe/Berlin|All valid Linux-timezones| +|USBDEVICES|none|Sets relevant permissions on mounted devices like "/dev/ttyACM0", for more than one device separate with ";" like "/dev/ttyACM0;/dev/ttyACM01" (beta)| +|ZWAVE|false|Will install openzwave to support zwave-adapter, can be "true" or "false"| ### Mounting Folder/ Volume From e270a46ee707a79f3161f79e9d4ed257b9990e86 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 12 Dec 2019 07:39:42 +0100 Subject: [PATCH 28/43] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0cb14ea..febfbff 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Since v3 is possible to set some environment variables to configure a new contai |---|---|---| |ADMINPORT|8081|Sets ioBroker-adminport on startup (beta)| |AVAHI|false|Installs and activates avahi-daemon for supporting yahka-adapter, can be "true" or "false"| -|LANG|de_DE.UTF-8|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| +|LANG|de_DE.UTF‑8|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| |LANGUAGE|de_DE:de|The following locales are pre-generated: de_DE:de, en_US:en| |LC_ALL|de_DE|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| |PACKAGES|vi|Installs additional packages to your container, needed by some adapters, packages should be seperated by whitespace like "package1 package2 package3"| From 84c31002f45817f30ff74af97150e6af2b996b2b Mon Sep 17 00:00:00 2001 From: duffbeer2000 Date: Fri, 27 Dec 2019 14:23:58 +0100 Subject: [PATCH 29/43] Update README.md Correct the default value of LC_ALL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index febfbff..0fd2c8a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Since v3 is possible to set some environment variables to configure a new contai |AVAHI|false|Installs and activates avahi-daemon for supporting yahka-adapter, can be "true" or "false"| |LANG|de_DE.UTF‑8|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| |LANGUAGE|de_DE:de|The following locales are pre-generated: de_DE:de, en_US:en| -|LC_ALL|de_DE|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| +|LC_ALL|de_DE.UTF-8|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| |PACKAGES|vi|Installs additional packages to your container, needed by some adapters, packages should be seperated by whitespace like "package1 package2 package3"| |REDIS|false|Activates redis as states-db on startup, fill with "hostname:port" to set redis connection otherwise use "false"(beta)| |SETGID|1000|For security reasons it might be useful to specify the gid of the containers iobroker user to match an existing group on the docker host| From 1492a15871ba1314096db10e69b5d702dfb8bcff Mon Sep 17 00:00:00 2001 From: duffbeer2000 Date: Fri, 27 Dec 2019 14:40:26 +0100 Subject: [PATCH 30/43] Include automatic restore to iobroker_startup.sh Integration of automatic restore of an iobroker backup file. It detects if /opt/iobroker contains a single file and if so if it contains a "backup.json" and restores it. --- aarch64/scripts/iobroker_startup.sh | 24 +++++++++++++++++++++--- amd64/scripts/iobroker_startup.sh | 24 +++++++++++++++++++++--- armv7hf/scripts/iobroker_startup.sh | 24 +++++++++++++++++++++--- 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 9805355..359f110 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -110,9 +110,27 @@ else then echo "Existing installation of ioBroker detected in /opt/iobroker." else - echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." - exit 1 + files=(/opt/iobroker/*) + if [ ${#files[@]} -lt 2 ]; then + if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null; then + echo "ioBroker Backup detected in /opt/iobroker. Restoring ioBroker..." + mv /opt/iobroker/iobroker_20*.tar.gz /opt/ + tar -xf /opt/initial_iobroker.tar -C / + mkdir /opt/iobroker/backups + rm -r /opt/iobroker/backups/* + mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ + iobroker restore 0 + echo "Done." + else + echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker or a valid backup file!" + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + exit 1 + fi + else + echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + exit 1 + fi fi fi echo ' ' diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 9805355..359f110 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -110,9 +110,27 @@ else then echo "Existing installation of ioBroker detected in /opt/iobroker." else - echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." - exit 1 + files=(/opt/iobroker/*) + if [ ${#files[@]} -lt 2 ]; then + if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null; then + echo "ioBroker Backup detected in /opt/iobroker. Restoring ioBroker..." + mv /opt/iobroker/iobroker_20*.tar.gz /opt/ + tar -xf /opt/initial_iobroker.tar -C / + mkdir /opt/iobroker/backups + rm -r /opt/iobroker/backups/* + mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ + iobroker restore 0 + echo "Done." + else + echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker or a valid backup file!" + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + exit 1 + fi + else + echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + exit 1 + fi fi fi echo ' ' diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 9805355..359f110 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -110,9 +110,27 @@ else then echo "Existing installation of ioBroker detected in /opt/iobroker." else - echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." - exit 1 + files=(/opt/iobroker/*) + if [ ${#files[@]} -lt 2 ]; then + if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null; then + echo "ioBroker Backup detected in /opt/iobroker. Restoring ioBroker..." + mv /opt/iobroker/iobroker_20*.tar.gz /opt/ + tar -xf /opt/initial_iobroker.tar -C / + mkdir /opt/iobroker/backups + rm -r /opt/iobroker/backups/* + mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ + iobroker restore 0 + echo "Done." + else + echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker or a valid backup file!" + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + exit 1 + fi + else + echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + exit 1 + fi fi fi echo ' ' From 0c1f8ed867d202eb55f0966f8b5deb7a9bc74ea2 Mon Sep 17 00:00:00 2001 From: duffbeer2000 Date: Fri, 27 Dec 2019 15:01:53 +0100 Subject: [PATCH 31/43] MAINTAINER is deprecated, switch to LABEL instead As https://docs.docker.com/engine/reference/builder/ says MAINTAINER instruction is deprecated. Switching to LABEL instruction. --- aarch64/Dockerfile | 3 ++- amd64/Dockerfile | 3 ++- armv7hf/Dockerfile | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/aarch64/Dockerfile b/aarch64/Dockerfile index 8dc774e..abd1720 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -1,6 +1,7 @@ FROM balenalib/aarch64-debian:stretch -MAINTAINER Andre Germann +LABEL maintainer="Andre Germann" \ + url="" ENV DEBIAN_FRONTEND noninteractive diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 1da5a9f..9eec8a6 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -1,6 +1,7 @@ FROM debian:stretch -MAINTAINER Andre Germann +LABEL maintainer="Andre Germann" \ + url="" ENV DEBIAN_FRONTEND noninteractive diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index 83e3f4a..9ce6797 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -1,7 +1,8 @@ FROM balenalib/armv7hf-debian:stretch -MAINTAINER Andre Germann - +LABEL maintainer="Andre Germann" \ + url="" + ENV DEBIAN_FRONTEND noninteractive # Install prerequisites (as listed in iobroker installer.sh) From f1b1360264f7f3e4400268e15211bff9c0c94fc1 Mon Sep 17 00:00:00 2001 From: duffbeer2000 Date: Fri, 27 Dec 2019 15:03:21 +0100 Subject: [PATCH 32/43] removed apt-get upgrade -y apt-get upgrade -y shouldn't be used in a Dockerfile --- aarch64/Dockerfile | 2 +- amd64/Dockerfile | 2 +- armv7hf/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aarch64/Dockerfile b/aarch64/Dockerfile index abd1720..a8cde0f 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -6,7 +6,7 @@ LABEL maintainer="Andre Germann" \ ENV DEBIAN_FRONTEND noninteractive # Install prerequisites (as listed in iobroker installer.sh) -RUN apt-get update && apt-get upgrade -y && apt-get install -y \ +RUN apt-get update && apt-get install -y \ acl \ apt-utils \ build-essential \ diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 9eec8a6..43dd2fe 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -6,7 +6,7 @@ LABEL maintainer="Andre Germann" \ ENV DEBIAN_FRONTEND noninteractive # Install prerequisites (as listed in iobroker installer.sh) -RUN apt-get update && apt-get upgrade -y && apt-get install -y \ +RUN apt-get update && apt-get install -y \ acl \ apt-utils \ build-essential \ diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index 9ce6797..3a159a9 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -6,7 +6,7 @@ LABEL maintainer="Andre Germann" \ ENV DEBIAN_FRONTEND noninteractive # Install prerequisites (as listed in iobroker installer.sh) -RUN apt-get update && apt-get upgrade -y && apt-get install -y \ +RUN apt-get update && apt-get install -y \ acl \ apt-utils \ build-essential \ From 37c9046077808f3332dbf9c8764dc9ad8efc9406 Mon Sep 17 00:00:00 2001 From: duffbeer2000 Date: Fri, 27 Dec 2019 15:13:46 +0100 Subject: [PATCH 33/43] Small Bugfix for restore --- aarch64/scripts/iobroker_startup.sh | 2 +- amd64/scripts/iobroker_startup.sh | 2 +- armv7hf/scripts/iobroker_startup.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 359f110..8b60eca 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -117,7 +117,7 @@ else mv /opt/iobroker/iobroker_20*.tar.gz /opt/ tar -xf /opt/initial_iobroker.tar -C / mkdir /opt/iobroker/backups - rm -r /opt/iobroker/backups/* + rm -r /opt/iobroker/backups/* &> /dev/null mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ iobroker restore 0 echo "Done." diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 359f110..8b60eca 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -117,7 +117,7 @@ else mv /opt/iobroker/iobroker_20*.tar.gz /opt/ tar -xf /opt/initial_iobroker.tar -C / mkdir /opt/iobroker/backups - rm -r /opt/iobroker/backups/* + rm -r /opt/iobroker/backups/* &> /dev/null mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ iobroker restore 0 echo "Done." diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 359f110..8b60eca 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -117,7 +117,7 @@ else mv /opt/iobroker/iobroker_20*.tar.gz /opt/ tar -xf /opt/initial_iobroker.tar -C / mkdir /opt/iobroker/backups - rm -r /opt/iobroker/backups/* + rm -r /opt/iobroker/backups/* &> /dev/null mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ iobroker restore 0 echo "Done." From 22d6b0158c4383c37d62f9e6ae80ff441e7abcac Mon Sep 17 00:00:00 2001 From: duffbeer2000 Date: Sun, 29 Dec 2019 19:56:21 +0100 Subject: [PATCH 34/43] Small fix backup folder is always empty in this if case so not necessary to empty it --- aarch64/scripts/iobroker_startup.sh | 1 - amd64/scripts/iobroker_startup.sh | 1 - armv7hf/scripts/iobroker_startup.sh | 1 - 3 files changed, 3 deletions(-) diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 8b60eca..93b690f 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -117,7 +117,6 @@ else mv /opt/iobroker/iobroker_20*.tar.gz /opt/ tar -xf /opt/initial_iobroker.tar -C / mkdir /opt/iobroker/backups - rm -r /opt/iobroker/backups/* &> /dev/null mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ iobroker restore 0 echo "Done." diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 8b60eca..93b690f 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -117,7 +117,6 @@ else mv /opt/iobroker/iobroker_20*.tar.gz /opt/ tar -xf /opt/initial_iobroker.tar -C / mkdir /opt/iobroker/backups - rm -r /opt/iobroker/backups/* &> /dev/null mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ iobroker restore 0 echo "Done." diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 8b60eca..93b690f 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -117,7 +117,6 @@ else mv /opt/iobroker/iobroker_20*.tar.gz /opt/ tar -xf /opt/initial_iobroker.tar -C / mkdir /opt/iobroker/backups - rm -r /opt/iobroker/backups/* &> /dev/null mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ iobroker restore 0 echo "Done." From fef9271eb4a7c94f8d6a9545164637cc046b5cbe Mon Sep 17 00:00:00 2001 From: Andre Date: Tue, 31 Dec 2019 18:31:58 +0100 Subject: [PATCH 35/43] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index febfbff..8a7dd84 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Feel free to ask for more architectures by opening an github-issue. The new v4 comes again with a new major node-version (node10)! If you are updating an existing Installation you have to perform some additional steps inside ioBroker! After upgrading your iobroker-container you have to call "reinstall.sh" for recompileing your installation for the use with node10! -For Details see official ioBroker-documentation (http://www.iobroker.net/docu/?page_id=8323&lang=de). Make backup first! +For Details see official ioBroker-documentation: [EN](https://www.iobroker.net/#en/documentation/install/updatenode.md) | [DE](https://www.iobroker.net/#de/documentation/install/updatenode.md). Make backup first! ## Installation & usage From c3f901f04e1410b3c94b846911334ba48437131a Mon Sep 17 00:00:00 2001 From: Andre Date: Tue, 31 Dec 2019 18:36:46 +0100 Subject: [PATCH 36/43] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a7dd84..9a9fcaa 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Feel free to ask for more architectures by opening an github-issue. The new v4 comes again with a new major node-version (node10)! If you are updating an existing Installation you have to perform some additional steps inside ioBroker! -After upgrading your iobroker-container you have to call "reinstall.sh" for recompileing your installation for the use with node10! +After upgrading your iobroker-container you have to call "npm rebuild" or "reinstall.sh" (when js-controller > v1.5 "reinstall.js") for recompileing your installation for the use with node10! For Details see official ioBroker-documentation: [EN](https://www.iobroker.net/#en/documentation/install/updatenode.md) | [DE](https://www.iobroker.net/#de/documentation/install/updatenode.md). Make backup first! ## Installation & usage From d5a1bda9b4599d56dd971c4a34931242110f767e Mon Sep 17 00:00:00 2001 From: buanet Date: Sat, 4 Jan 2020 21:00:23 +0100 Subject: [PATCH 37/43] improve restore and logging --- amd64/scripts/iobroker_startup.sh | 50 +++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 93b690f..a55c9f6 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -100,37 +100,37 @@ echo "----- Step 2 of 5: Detecting ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -if [ `ls -1a|wc -l` -lt 3 ] +files=(/opt/iobroker/*) +if [ ${#files[@]} -lt 1 ] then echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..." tar -xf /opt/initial_iobroker.tar -C / echo "Done." -else - if [ -f /opt/iobroker/iobroker ] +elif [ -f /opt/iobroker/iobroker ] +then + echo "Existing installation of ioBroker detected in /opt/iobroker." +elif [ ${#files[@]} -lt 2 ] +then + if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null then - echo "Existing installation of ioBroker detected in /opt/iobroker." - else - files=(/opt/iobroker/*) - if [ ${#files[@]} -lt 2 ]; then - if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null; then - echo "ioBroker Backup detected in /opt/iobroker. Restoring ioBroker..." - mv /opt/iobroker/iobroker_20*.tar.gz /opt/ - tar -xf /opt/initial_iobroker.tar -C / - mkdir /opt/iobroker/backups - mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ - iobroker restore 0 - echo "Done." - else - echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker or a valid backup file!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." - exit 1 - fi - else - echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." - exit 1 - fi + echo "ioBroker backup file detected in /opt/iobroker. Restoring ioBroker..." + mv /opt/iobroker/iobroker_20*.tar.gz /opt/ + tar -xf /opt/initial_iobroker.tar -C / + mkdir /opt/iobroker/backups + mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ + iobroker restore 0 + echo "Done." + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "!!!!! Please note: The sartup script restored iobroker from a backup file. !!!!!" + echo "!!!!! When ioBroker will be started it will reinstall all Adapters automatically. !!!!!" + echo "!!!!! This might be take a looooong time! Please be patient! !!!!!" + echo "!!!!! You can view installation process by taking a look at ioBroker log. !!!!!" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" fi +else + echo "There is data detected in /opt/iobroker but it looks like it is no instance of iobroker or a valid backup file!" + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + exit 1 fi echo ' ' From 27b6c93a172a7ef8b80aaaa09169c03f405bcd63 Mon Sep 17 00:00:00 2001 From: Andre Date: Sun, 5 Jan 2020 03:05:13 +0100 Subject: [PATCH 38/43] testing --- amd64/scripts/iobroker_startup.sh | 34 ++++++++++++++----------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index a55c9f6..1cc7045 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -100,8 +100,7 @@ echo "----- Step 2 of 5: Detecting ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -files=(/opt/iobroker/*) -if [ ${#files[@]} -lt 1 ] +if [ `ls -1a|wc -l` -lt 1 ] then echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..." tar -xf /opt/initial_iobroker.tar -C / @@ -109,24 +108,21 @@ then elif [ -f /opt/iobroker/iobroker ] then echo "Existing installation of ioBroker detected in /opt/iobroker." -elif [ ${#files[@]} -lt 2 ] +elif [ -f /opt/iobroker/*.tar.gz ] && [ tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null ] #ACTUALLY BROKEN!!! then - if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null - then - echo "ioBroker backup file detected in /opt/iobroker. Restoring ioBroker..." - mv /opt/iobroker/iobroker_20*.tar.gz /opt/ - tar -xf /opt/initial_iobroker.tar -C / - mkdir /opt/iobroker/backups - mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ - iobroker restore 0 - echo "Done." - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "!!!!! Please note: The sartup script restored iobroker from a backup file. !!!!!" - echo "!!!!! When ioBroker will be started it will reinstall all Adapters automatically. !!!!!" - echo "!!!!! This might be take a looooong time! Please be patient! !!!!!" - echo "!!!!! You can view installation process by taking a look at ioBroker log. !!!!!" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - fi + echo "ioBroker backup file detected in /opt/iobroker. Restoring ioBroker..." + mv /opt/iobroker/*.tar.gz /opt/ + tar -xf /opt/initial_iobroker.tar -C / + mkdir /opt/iobroker/backups + mv /opt/*.tar.gz /opt/iobroker/backups/ + iobroker restore 0 + echo "Done." + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "!!!!! Please note: The sartup script restored iobroker from a backup file. !!!!!" + echo "!!!!! When ioBroker will be started it will reinstall all Adapters automatically. !!!!!" + echo "!!!!! This might be take a looooong time! Please be patient! !!!!!" + echo "!!!!! You can view installation process by taking a look at ioBroker log. !!!!!" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" else echo "There is data detected in /opt/iobroker but it looks like it is no instance of iobroker or a valid backup file!" echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." From 4101fc1cab84f0de76e4d02ec8469edb0652f309 Mon Sep 17 00:00:00 2001 From: buanet Date: Sun, 5 Jan 2020 16:06:10 +0100 Subject: [PATCH 39/43] fixing restore --- amd64/scripts/iobroker_startup.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 1cc7045..5653468 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -100,7 +100,7 @@ echo "----- Step 2 of 5: Detecting ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -if [ `ls -1a|wc -l` -lt 1 ] +if [ `find /opt/iobroker -type f | wc -l` -lt 1 ] then echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..." tar -xf /opt/initial_iobroker.tar -C / @@ -108,21 +108,24 @@ then elif [ -f /opt/iobroker/iobroker ] then echo "Existing installation of ioBroker detected in /opt/iobroker." -elif [ -f /opt/iobroker/*.tar.gz ] && [ tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null ] #ACTUALLY BROKEN!!! +elif [ $(ls iobroker_20* 2> /dev/null | wc -l) != "0" ] && [ $(tar -ztvf /opt/iobroker/iobroker_20*.tar.gz "backup/backup.json" 2> /dev/null | wc -l) != "0" ] then echo "ioBroker backup file detected in /opt/iobroker. Restoring ioBroker..." mv /opt/iobroker/*.tar.gz /opt/ tar -xf /opt/initial_iobroker.tar -C / mkdir /opt/iobroker/backups mv /opt/*.tar.gz /opt/iobroker/backups/ - iobroker restore 0 + iobroker restore 0 > /opt/iobroker/log/restore.log 2>&1 echo "Done." - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "!!!!! Please note: The sartup script restored iobroker from a backup file. !!!!!" - echo "!!!!! When ioBroker will be started it will reinstall all Adapters automatically. !!!!!" - echo "!!!!! This might be take a looooong time! Please be patient! !!!!!" - echo "!!!!! You can view installation process by taking a look at ioBroker log. !!!!!" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo ' ' + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "!!!!! IMPORTANT NOTE !!!!!" + echo "!!!!! The sartup script restored iobroker from a backup file. !!!!!" + echo "!!!!! Check /opt/iobroker/log/restore.log to see if restore was successful. !!!!!" + echo "!!!!! When ioBroker now starts it will reinstall all Adapters automatically. !!!!!" + echo "!!!!! This might be take a looooong time! Please be patient! !!!!!" + echo "!!!!! You can view installation process by taking a look at ioBroker log. !!!!!" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" else echo "There is data detected in /opt/iobroker but it looks like it is no instance of iobroker or a valid backup file!" echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." From 7d4eba91a125eb90cc4c9535b4c7e3124dbc3d73 Mon Sep 17 00:00:00 2001 From: buanet Date: Mon, 6 Jan 2020 00:36:46 +0100 Subject: [PATCH 40/43] preparing new beta --- README.md | 15 ++++++--- aarch64/scripts/iobroker_startup.sh | 51 ++++++++++++++--------------- armv7hf/scripts/iobroker_startup.sh | 51 ++++++++++++++--------------- 3 files changed, 60 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 794aeb8..395ba37 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,13 @@ Since v3 is possible to set some environment variables to configure a new contai ### Mounting Folder/ Volume -It is now possible to mount an empty folder to /opt/iobroker during first startup of the container. The Startupscript will check this folder and restore content if it is empty. +It is possible to mount an empty folder to /opt/iobroker during first startup of the container. The Startupscript will check this folder and restore content if it is empty. +In actual beta (v4.0.3beta) it is also possible mount a folder with an iobroker backup (created with backitup-adapter) named like this: "iobroker_2020_01_06-01_09_10_backupiobroker.tar.gz". +The startup script will then detect this backup and restore it during the start of the container. Plese see logs when starting the container for more details. It is absolutely recommended to use a mounted folder or persistent volume for /opt/iobroker folder! -This also works with mounting a folder containing an existing ioBroker-installation (e.g. when moving an existing installation to docker). +You can also mount a folder containing an existing ioBroker-installation (e.g. when moving an existing installation to docker). ### Permission Fixer @@ -61,9 +63,12 @@ After some issues with permissions related to the use of a dedicated user for io ## Changelog -### v4.0.2beta (2019-12-10) -* added env for activating redis -* enhancements in startupscript and dockerfile +### v4.0.3beta (2020-01-06) +* added support to restore backup on startup +* small fixes according to "docker best practices" +* v4.0.2beta (2019-12-10) + * added env for activating redis + * enhancements in startupscript and dockerfile * v4.0.1beta (2019-11-25) * added env for iobroker admin port * added env for usb-devices (setting permissions) diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 93b690f..5653468 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -100,37 +100,36 @@ echo "----- Step 2 of 5: Detecting ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -if [ `ls -1a|wc -l` -lt 3 ] +if [ `find /opt/iobroker -type f | wc -l` -lt 1 ] then echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..." tar -xf /opt/initial_iobroker.tar -C / echo "Done." +elif [ -f /opt/iobroker/iobroker ] +then + echo "Existing installation of ioBroker detected in /opt/iobroker." +elif [ $(ls iobroker_20* 2> /dev/null | wc -l) != "0" ] && [ $(tar -ztvf /opt/iobroker/iobroker_20*.tar.gz "backup/backup.json" 2> /dev/null | wc -l) != "0" ] +then + echo "ioBroker backup file detected in /opt/iobroker. Restoring ioBroker..." + mv /opt/iobroker/*.tar.gz /opt/ + tar -xf /opt/initial_iobroker.tar -C / + mkdir /opt/iobroker/backups + mv /opt/*.tar.gz /opt/iobroker/backups/ + iobroker restore 0 > /opt/iobroker/log/restore.log 2>&1 + echo "Done." + echo ' ' + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "!!!!! IMPORTANT NOTE !!!!!" + echo "!!!!! The sartup script restored iobroker from a backup file. !!!!!" + echo "!!!!! Check /opt/iobroker/log/restore.log to see if restore was successful. !!!!!" + echo "!!!!! When ioBroker now starts it will reinstall all Adapters automatically. !!!!!" + echo "!!!!! This might be take a looooong time! Please be patient! !!!!!" + echo "!!!!! You can view installation process by taking a look at ioBroker log. !!!!!" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" else - if [ -f /opt/iobroker/iobroker ] - then - echo "Existing installation of ioBroker detected in /opt/iobroker." - else - files=(/opt/iobroker/*) - if [ ${#files[@]} -lt 2 ]; then - if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null; then - echo "ioBroker Backup detected in /opt/iobroker. Restoring ioBroker..." - mv /opt/iobroker/iobroker_20*.tar.gz /opt/ - tar -xf /opt/initial_iobroker.tar -C / - mkdir /opt/iobroker/backups - mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ - iobroker restore 0 - echo "Done." - else - echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker or a valid backup file!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." - exit 1 - fi - else - echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." - exit 1 - fi - fi + echo "There is data detected in /opt/iobroker but it looks like it is no instance of iobroker or a valid backup file!" + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + exit 1 fi echo ' ' diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 93b690f..5653468 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -100,37 +100,36 @@ echo "----- Step 2 of 5: Detecting ioBroker installation -----" echo "$(printf -- '-%.0s' {1..60})" echo ' ' -if [ `ls -1a|wc -l` -lt 3 ] +if [ `find /opt/iobroker -type f | wc -l` -lt 1 ] then echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..." tar -xf /opt/initial_iobroker.tar -C / echo "Done." +elif [ -f /opt/iobroker/iobroker ] +then + echo "Existing installation of ioBroker detected in /opt/iobroker." +elif [ $(ls iobroker_20* 2> /dev/null | wc -l) != "0" ] && [ $(tar -ztvf /opt/iobroker/iobroker_20*.tar.gz "backup/backup.json" 2> /dev/null | wc -l) != "0" ] +then + echo "ioBroker backup file detected in /opt/iobroker. Restoring ioBroker..." + mv /opt/iobroker/*.tar.gz /opt/ + tar -xf /opt/initial_iobroker.tar -C / + mkdir /opt/iobroker/backups + mv /opt/*.tar.gz /opt/iobroker/backups/ + iobroker restore 0 > /opt/iobroker/log/restore.log 2>&1 + echo "Done." + echo ' ' + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "!!!!! IMPORTANT NOTE !!!!!" + echo "!!!!! The sartup script restored iobroker from a backup file. !!!!!" + echo "!!!!! Check /opt/iobroker/log/restore.log to see if restore was successful. !!!!!" + echo "!!!!! When ioBroker now starts it will reinstall all Adapters automatically. !!!!!" + echo "!!!!! This might be take a looooong time! Please be patient! !!!!!" + echo "!!!!! You can view installation process by taking a look at ioBroker log. !!!!!" + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" else - if [ -f /opt/iobroker/iobroker ] - then - echo "Existing installation of ioBroker detected in /opt/iobroker." - else - files=(/opt/iobroker/*) - if [ ${#files[@]} -lt 2 ]; then - if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null; then - echo "ioBroker Backup detected in /opt/iobroker. Restoring ioBroker..." - mv /opt/iobroker/iobroker_20*.tar.gz /opt/ - tar -xf /opt/initial_iobroker.tar -C / - mkdir /opt/iobroker/backups - mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ - iobroker restore 0 - echo "Done." - else - echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker or a valid backup file!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." - exit 1 - fi - else - echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" - echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." - exit 1 - fi - fi + echo "There is data detected in /opt/iobroker but it looks like it is no instance of iobroker or a valid backup file!" + echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." + exit 1 fi echo ' ' From e9481bae9ff4a0ae4fffe08ff5d38a6e37ed05cc Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 6 Jan 2020 00:38:48 +0100 Subject: [PATCH 41/43] Update .VERSION --- .VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.VERSION b/.VERSION index 97a50b0..d4b18a1 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v4.0.2beta +v4.0.3beta From a9af03edc97c24372b122f92c61eff7d428899a9 Mon Sep 17 00:00:00 2001 From: Andre Date: Fri, 17 Jan 2020 11:01:55 +0100 Subject: [PATCH 42/43] Update README.md --- README.md | 80 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 395ba37..53b3409 100644 --- a/README.md +++ b/README.md @@ -4,25 +4,56 @@ Source: https://github.com/buanet/docker-iobroker -IoBroker for Docker is an Dockerimage for ioBroker (http://iobroker.net) smarthome software. +IoBroker for Docker is an Dockerimage for ioBroker IoT platform (http://www.iobroker.net). -It is originally made for, and tested on a Synology Disk Station 1515+ with DSM 6 and Docker-package installed. But it should also work on other systems with Docker installed! +It is originally made for and always tested on a Synology Disk Station 1515+ with DSM 6 and official Docker package installed. But it also works on other systems with Docker installed! Version 4 now supports running the Image in Docker on the following architectures: amd64, armv7hf, aarch64. -Feel free to ask for more architectures by opening an github-issue. +Feel free to ask for more architectures by opening an github issue. -## Important +## Important notice -The new v4 comes again with a new major node-version (node10)! -If you are updating an existing Installation you have to perform some additional steps inside ioBroker! -After upgrading your iobroker-container you have to call "npm rebuild" or "reinstall.sh" (when js-controller > v1.5 "reinstall.js") for recompileing your installation for the use with node10! -For Details see official ioBroker-documentation: [EN](https://www.iobroker.net/#en/documentation/install/updatenode.md) | [DE](https://www.iobroker.net/#de/documentation/install/updatenode.md). Make backup first! +The new v4 comes again with a new major node version (node10)! +If you are updating an existing installation you have to perform some additional steps inside ioBroker! +After upgrading your iobroker container you have to call "npm rebuild" or "reinstall.sh" (when js-controller > v1.5 "reinstall.js") for recompileing your installation for the use with node10! +For more details please see official ioBroker documentation: [EN](https://www.iobroker.net/#en/documentation/install/updatenode.md) | [DE](https://www.iobroker.net/#de/documentation/install/updatenode.md). +Make backup first! -## Installation & usage +## Getting started A detailed tutorial (german, based on v3.0.0) can be found here: [https://buanet.de](https://buanet.de/2019/05/iobroker-unter-docker-auf-der-synology-diskstation-v3/). Please notice that the old tutorial is outdated and does no longer work! -For discussion and support please visit [ioBroker-forum-thread](http://forum.iobroker.net/viewtopic.php?f=17&t=5089) or use the comments section at the linked tutorial. Please do not contact me directly for any support-reasons. Every support question should be answered in a public place. Thank you. +For discussion and support please visit [ioBroker forum thread](http://forum.iobroker.net/viewtopic.php?f=17&t=5089) or use the comments section at the linked tutorial. Please do not contact me directly for any support-reasons. Every support question should be answered in a public place. Thank you. + +The following ways to geht iobroker-container running are only examples. Maybe you have to change, add or replace parameters to configure ioBroker for your environment. + +### Running from commandline + +For taking a first look at the iobroker docker container it would be enough to simply run the following basic docker run command: + +``` +docker run -p 8081:8081 --name iobroker -v /opt/iobroker:/iobroker buanet/iobroker:latest +``` + +### Running with docker-compose + +You can also run iobroker by using docker-compose. Here is an example: + +``` +version: '2' + +services: + iobroker: + restart: always + image: buanet/iobroker:latest + container_name: iobroker + hostname: iobroker + ports: + - "8081:8081" + volumes: + - iobrokerdata:/opt/iobroker + mem_swappiness: -1 # temp workaround! +``` ## Special settings and features @@ -30,42 +61,45 @@ The following will give a short overview. ### Environment variables -Since v3 is possible to set some environment variables to configure a new container. +To configure the ioBroker container on startup it is possible to set some environment variables. |env|default|description| |---|---|---| -|ADMINPORT|8081|Sets ioBroker-adminport on startup (beta)| +|ADMINPORT|8081|Sets ioBroker adminport on startup| |AVAHI|false|Installs and activates avahi-daemon for supporting yahka-adapter, can be "true" or "false"| |LANG|de_DE.UTF‑8|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| |LANGUAGE|de_DE:de|The following locales are pre-generated: de_DE:de, en_US:en| |LC_ALL|de_DE.UTF-8|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8| -|PACKAGES|vi|Installs additional packages to your container, needed by some adapters, packages should be seperated by whitespace like "package1 package2 package3"| -|REDIS|false|Activates redis as states-db on startup, fill with "hostname:port" to set redis connection otherwise use "false"(beta)| +|PACKAGES|vi|Installs additional packages to your container needed by some adapters, packages should be seperated by whitespace like "package1 package2 package3"| +|REDIS|false|Activates the uses of redis as states-db on startup, fill with "hostname:port" to set redis connection, redis db has to be set up seperately (e.g. in another container)| |SETGID|1000|For security reasons it might be useful to specify the gid of the containers iobroker user to match an existing group on the docker host| |SETUID|1000|For security reasons it might be useful to specify the uid of the containers iobroker user to match an existing user on the docker host| |TZ|Europe/Berlin|All valid Linux-timezones| -|USBDEVICES|none|Sets relevant permissions on mounted devices like "/dev/ttyACM0", for more than one device separate with ";" like "/dev/ttyACM0;/dev/ttyACM01" (beta)| +|USBDEVICES|none|Sets relevant permissions on mounted devices like "/dev/ttyACM0", for more than one device separate with ";" like "/dev/ttyACM0;/dev/ttyACM1"| |ZWAVE|false|Will install openzwave to support zwave-adapter, can be "true" or "false"| ### Mounting Folder/ Volume It is possible to mount an empty folder to /opt/iobroker during first startup of the container. The Startupscript will check this folder and restore content if it is empty. -In actual beta (v4.0.3beta) it is also possible mount a folder with an iobroker backup (created with backitup-adapter) named like this: "iobroker_2020_01_06-01_09_10_backupiobroker.tar.gz". -The startup script will then detect this backup and restore it during the start of the container. Plese see logs when starting the container for more details. +Since v4.1.0 it is also possible mount a folder filled up with an iobroker backup file (created with backitup adapter) named like this: "iobroker_2020_01_06-01_09_10_backupiobroker.tar.gz". +The startup script will detect this backup and restore it during the start of the container. Plese see container logs when starting the container for more details! -It is absolutely recommended to use a mounted folder or persistent volume for /opt/iobroker folder! +Note: It is absolutely recommended to use a mounted folder or persistent volume for /opt/iobroker folder! -You can also mount a folder containing an existing ioBroker-installation (e.g. when moving an existing installation to docker). +You can also mount a folder containing an existing ioBroker-installation (e.g. when moving an existing installation to docker). +But watch for the used node version. If the existing installation runs with another major version of node you have do perform additional steps. For more Details see the "Important notice" on top. ### Permission Fixer -After some issues with permissions related to the use of a dedicated user for ioBroker, I added some code for fixing permissions on container startup. This might take a few minutes on first startup. Please take a look at the logs and be patient! +After some issues with permissions related to the use of a dedicated user for ioBroker, I added some code for fixing permissions on container startup. This might take a few minutes on first startup. Please take a look at the container logs and be patient! ## Changelog -### v4.0.3beta (2020-01-06) -* added support to restore backup on startup -* small fixes according to "docker best practices" +### v4.1.0 (2020-01-17) +* improved readme.md +* v4.0.3beta (2020-01-06) + * added support to restore backup on startup + * small fixes according to "docker best practices" * v4.0.2beta (2019-12-10) * added env for activating redis * enhancements in startupscript and dockerfile From c054ab4dc0495c4d9fc833c698fad1741cb1ab5b Mon Sep 17 00:00:00 2001 From: Andre Date: Fri, 17 Jan 2020 11:02:23 +0100 Subject: [PATCH 43/43] Update .VERSION --- .VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.VERSION b/.VERSION index d4b18a1..b913b7c 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v4.0.3beta +v4.1.0