From e21dfb9af82a98663b08f09905ab49d87fb9b37f Mon Sep 17 00:00:00 2001 From: Andre Date: Wed, 15 Apr 2020 00:02:55 +0200 Subject: [PATCH 01/27] Update .VERSION --- .VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.VERSION b/.VERSION index 51be872..819609f 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v4.2.0 +v4.2.1beta From ac6709982cab1d5dfc847323be3f86fa77b97792 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 16 Apr 2020 11:38:13 +0200 Subject: [PATCH 02/27] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb21684..36b043a 100644 --- a/README.md +++ b/README.md @@ -211,7 +211,7 @@ Thank you! ### v1.2.0 (2018-08-21) * v1.1.3beta (2018-08-21) - * added ffmpeg-package for yahka to support webcams + * ~~added ffmpeg-package for yahka to support webcams~~ * v1.1.2beta (2018-04-04) * added ENV for timezone issue * v1.1.1beta (2018-03-29) @@ -234,7 +234,7 @@ Thank you! * added some maintenance scripts ### v0.2.1 (2017-08-16) -* added libfontconfig package (for iobroker.phantomjs) +* ~~added libfontconfig package (for iobroker.phantomjs)~~ * added gnupg2 package as prerequisite for installing node version 6 ### v0.2.0 (2017-06-04) @@ -242,7 +242,7 @@ Thank you! * changed node version from 4 to 6 ### v0.1.2 (2017-03-14) -* added libpcap-dev package (for iobroker.amazon-dash) +* ~~added libpcap-dev package (for iobroker.amazon-dash)~~ ### v0.1.1 (2017-03-10) * added git package From c81da456934e12aa675bad09df91030d7cec13a5 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 16 Apr 2020 11:38:53 +0200 Subject: [PATCH 03/27] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb21684..36b043a 100644 --- a/README.md +++ b/README.md @@ -211,7 +211,7 @@ Thank you! ### v1.2.0 (2018-08-21) * v1.1.3beta (2018-08-21) - * added ffmpeg-package for yahka to support webcams + * ~~added ffmpeg-package for yahka to support webcams~~ * v1.1.2beta (2018-04-04) * added ENV for timezone issue * v1.1.1beta (2018-03-29) @@ -234,7 +234,7 @@ Thank you! * added some maintenance scripts ### v0.2.1 (2017-08-16) -* added libfontconfig package (for iobroker.phantomjs) +* ~~added libfontconfig package (for iobroker.phantomjs)~~ * added gnupg2 package as prerequisite for installing node version 6 ### v0.2.0 (2017-06-04) @@ -242,7 +242,7 @@ Thank you! * changed node version from 4 to 6 ### v0.1.2 (2017-03-14) -* added libpcap-dev package (for iobroker.amazon-dash) +* ~~added libpcap-dev package (for iobroker.amazon-dash)~~ ### v0.1.1 (2017-03-10) * added git package From 5a0dd59c3c2f2c21071d7919448411d3ce41c915 Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 20 Apr 2020 22:32:26 +0200 Subject: [PATCH 04/27] Update README.md --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 36b043a..d66e5c5 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,8 @@ Source: https://github.com/buanet/docker-iobroker IoBroker for Docker is an Dockerimage for ioBroker IoT platform (http://www.iobroker.net). -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. +Since version 4 it is available for the following architectures: amd64, armv7hf, aarch64. +You need another architecture? Let me know by opening an github issue. Thx. ## Important notice @@ -19,13 +17,16 @@ After upgrading your iobroker container you have to call "npm rebuild" or "reins 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! +By the way, a more comfortable way is to use "iobroker backup" to create a full backup of your existing installation and copy it into a empty folder which you will mount to /opt/iobroker when setting up a new container. The startup script will automatically detect the backup file and restore it to the new container. For more details see "Mounting folder/ volume" section of this readme.md file. + ## 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. Thanks in advance. +If you think you found a bug or simply want to request a new feature please open an issue on Github. -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. +The following ways to get iobroker-container running are only examples. Maybe you have to change, add or replace parameters to configure ioBroker for fitting your needs. ### Running from commandline @@ -88,21 +89,21 @@ You do not have to declare every single variable when stting up your container. ### 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. -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". +Since v4.1.0 it is also possible mount a folder filled up with an iobroker backup file (for example 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! 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). -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. +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 of this readme.md file. **Important: If the folder you mount to /opt/iobroker in your container is placed on a mounted device, partition or other storage, the mountpoint on your host should NOT have the "noexec" flag activated. Otherwise you may get problems executing ioBroker inside the container!** -### Permission fixer +### Mounting USB device -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! +If you want to use a USB device within ioBroker inside your container don´t forget to [mount the device](https://docs.docker.com/engine/reference/commandline/run/#add-host-device-to-container---device) on container startup and use the environment variable "USBDEVICES". -### Userdefined startup scripts (advanced setting/ beta status) +### Userdefined startup scripts In some cases it migth be helpful to add some script code to the startup script of the container. This is now possible by mounting an additional folder to the container and place a userscript in there. The folder containing your userscripts must be mounted under /opt/userscripts inside the container. If you mount an empty folder you will get two example scripts to be restored in that folder. Just try it out. From c3cd27fe34eeb4f12d074d643f1c29a38395b59e Mon Sep 17 00:00:00 2001 From: buanet Date: Mon, 4 May 2020 10:17:58 +0200 Subject: [PATCH 05/27] node 12 testing --- amd64/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 9f15b1d..f0a3d33 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -30,8 +30,8 @@ RUN apt-get update && apt-get install -y \ wget \ && rm -rf /var/lib/apt/lists/* -# Install node10 -RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ +# Install node +RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ && apt-get update && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* From b35b6c17ad05ca40d86f78040b477ed454081af8 Mon Sep 17 00:00:00 2001 From: buanet Date: Mon, 4 May 2020 10:23:43 +0200 Subject: [PATCH 06/27] back to node 10 --- amd64/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index f0a3d33..290fb8d 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -31,7 +31,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Install node -RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ && apt-get update && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* From 66433c414f3b03dbc465b05bcb8559abaeec2bb4 Mon Sep 17 00:00:00 2001 From: buanet Date: Mon, 4 May 2020 10:25:14 +0200 Subject: [PATCH 07/27] testing node 12 --- amd64/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 9f15b1d..f0a3d33 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -30,8 +30,8 @@ RUN apt-get update && apt-get install -y \ wget \ && rm -rf /var/lib/apt/lists/* -# Install node10 -RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ +# Install node +RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ && apt-get update && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* From d15e392acdd80babf32e8e5261a9775a1c6038d5 Mon Sep 17 00:00:00 2001 From: buanet Date: Sun, 10 May 2020 00:45:22 +0200 Subject: [PATCH 08/27] preparing v4.2.1beta --- README.md | 62 ++++++++++++++++++++++++++-------------------- aarch64/Dockerfile | 4 +-- armv7hf/Dockerfile | 4 +-- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 8604b45..f51b81f 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ [![License](https://img.shields.io/github/license/buanet/docker-iobroker)](https://github.com/buanet/docker-iobroker/blob/master/LICENSE.md) [![Donate](https://img.shields.io/badge/donate-paypal-blue)](https://paypal.me/buanet) -IoBroker for Docker is a Dockerimage for ioBroker IoT platform (http://www.iobroker.net). +IoBroker for Docker is a Docker image for ioBroker IoT platform (http://www.iobroker.net). -It was originally created for a Synology Disk Station 1515+ with DSM 6 and official Docker package installed. After more than three years of development it might be the best documented and still maintained Dockrimage for running ioBroker ioT platform with Docker. +It was originally created for a Synology Disk Station 1515+ with DSM 6 and official Docker package installed. After more than three years of development it might be the best documented and still maintained Docker image for running ioBroker IoT platform with Docker. Since v4.0.0 the image is available for the following architectures: amd64, armv7hf, aarch64.
If you need more please let me know by opening a Github issue. @@ -20,21 +20,21 @@ If you need more please let me know by opening a Github issue. Normally a new major version (e.g. v2, v4 and upcoming v5) of the image comes with a new, preinstalled major node version! If you are updating an existing installation to a new major version (e.g. from v4 to v5) you have to perform some additional steps inside ioBroker! 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).
-You might avoid these procedure if you use my "Best practise" hint for "upgrading your ioBroker container". +You might avoid these procedure if you use my "Best practice" hint for "upgrading your ioBroker container".
In any case make a backup first! By the way, a more comfortable way is to use "iobroker backup" to create a full backup of your existing installation and copy it into a empty folder which you will mount to /opt/iobroker when setting up a new container. The startup script will automatically detect the backup file and restore it to the new container. For more details see "Mounting folder/ volume" section of this readme.md file. ## 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! +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. Thanks in advance. If you think you found a bug or simply want to request a new feature please open an issue on Github. The following ways to get iobroker-container running are only examples. Maybe you have to change, add or replace parameters to configure ioBroker for fitting your needs. -### Running from commandline +### Running from command line For taking a first look at the iobroker docker container it would be enough to simply run the following basic docker run command: @@ -68,7 +68,7 @@ The following will give a short overview. ### Environment variables To configure the ioBroker container on startup it is possible to set some environment variables. -You do not have to declare every single variable when stting up your container. Variables you do not set will come up with their default value. +You do not have to declare every single variable when setting up your container. Variables you do not set will come up with their default value. **Important: In v4.2.0 the ENVs "ADMINPORT" and "REDIS" were renamed/ reorganized. For Details see the following table!** @@ -94,9 +94,9 @@ You do not have to declare every single variable when stting up your container. ### 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. +It is possible to mount an empty folder to /opt/iobroker during first startup of the container. The startup script will check this folder and restore content if it is empty. Since v4.1.0 it is also possible mount a folder filled up with an iobroker backup file (for example 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! +The startup script will detect this backup and restore it during the start of the container. Please see container logs when starting the container for more details! Note: It is absolutely recommended to use a mounted folder or persistent volume for /opt/iobroker folder! @@ -105,13 +105,13 @@ But watch for the used node version. If the existing installation runs with anot **Important: If the folder you mount to /opt/iobroker in your container is placed on a mounted device, partition or other storage, the mountpoint on your host should NOT have the "noexec" flag activated. Otherwise you may get problems executing ioBroker inside the container!** -### Mounting USB device +### Mounting USB device If you want to use a USB device within ioBroker inside your container don´t forget to [mount the device](https://docs.docker.com/engine/reference/commandline/run/#add-host-device-to-container---device) on container startup and use the environment variable "USBDEVICES". ### Userdefined startup scripts -In some cases it migth be helpful to add some script code to the startup script of the container. This is now possible by mounting an additional folder to the container and place a userscript in there. +In some cases it might be helpful to add some script code to the startup script of the container. This is now possible by mounting an additional folder to the container and place a userscript in there. The folder containing your userscripts must be mounted under /opt/userscripts inside the container. If you mount an empty folder you will get two example scripts to be restored in that folder. Just try it out. Basically there are two different scripts which will be read and called by the startup script. One that will only be called once at the first start of the container (userscript_firststart.sh) and one which will be called for every start of the container (userscript_everystart.sh). @@ -123,36 +123,44 @@ To get familiar with that feature try the following: Create a Container, mount a ### Avoid using "latest" tag -To avoid conflicts when upgrading your container or getting in trouble when accedentially upgrading your container to a new major version I prefer using the version tag like "V4.2.0" instead of "latest" for creating yor container. Just think about when I tell you it is not possible to download a new image version of a specific tag as long as a conrainer depends on it.
+To avoid conflicts when upgrading your container or getting in trouble when accidentally upgrading your container to a new major version I prefer using the version tag like "V4.2.0" instead of "latest" for creating your container. Just think about when I tell you it is not possible to download a new image version of a specific tag as long as a container depends on it.
By the way it also makes it more safe to keep your image up to date by using "watchtower" or something like that. ### Upgrading you container -If you want to upgrade your ioBroker container to a new major version (e.g. from v4 to v5) I would prefer to do that by creating a bockup in ioBroker (by "iobroker backup" or backitup adapter) and restoring it to a completely new container. All you need is time an the following steps: -* make a backup by Commandline ("iobroker backup") or backitup adapter +If you want to upgrade your ioBroker container to a new major version (e.g. from v4 to v5) I would prefer to do that by creating a backup in ioBroker (by "iobroker backup" or backitup adapter) and restoring it to a completely new container. All you need is time an the following steps: +* make a backup by command line ("iobroker backup") or backitup adapter * stop the old container -* create a new and empty data folder or volume and place your backupfile in it -* create a new container as your old or as you need it and use the new data folder/ volume for the /opt/iobroke mountpoint +* create a new and empty data folder or volume and place your backup file in it +* create a new container as your old or as you need it and use the new data folder/ volume for the /opt/iobroker mount point * follow the log output of the container and be patient -After this the startupscript inside the container will automatically detect and restore your backup to a new ioBroker instance. When iobroker is started after the restore it will install your adapters to the new ioBroker instance by itself. This might take some time but will get you the best and cleanest results... +After this the startup script inside the container will automatically detect and restore your backup to a new ioBroker instance. When iobroker is started after the restore it will install your adapters to the new ioBroker instance by itself. This might take some time but will get you the best and cleanest results... ## Miscellaneous +### Beta testing + +If you want to get the newest features and changes feel free to use/ test the beta version of the Docker image. You can find the readme.md file for beta versions [here](https://github.com/buanet/docker-iobroker/blob/beta/README.md). + ### Subscribe to updates -If you want the newest updates about the image and my tutorials at https://buanet.de/tutorials you can simply subscribe to my new "news and updates" channel (only in german) on Telegram. +If you want the newest updates about the image and my tutorials at https://buanet.de/tutorials you can simply subscribe to my new "news and updates" channel (only in German) on Telegram. You will find the channel here: https://t.me/buanet_tutorials ### Support the project -The easiest way to support this project is to leave me some likes/ stars on github and docker hub!
+The easiest way to support this project is to leave me some likes/ stars on Github and Docker hub!
If you want to give something back, feel free to take a look into the [open issues](https://github.com/buanet/docker-iobroker/issues) or the [ioBroker forum thread](http://forum.iobroker.net/viewtopic.php?f=17&t=5089) and helping me answering questions, fixing bugs or adding new features!
And if you want to buy me a beer instead, you can do this here:
Thank you! ## Changelog +### v4.2.1beta (2020-05-10) +* using node 12 instead of 10 +* updated documentation in readme.md + ### v4.2.0 (2020-04-14) * v4.1.4beta (2020-04-07) * switching base image to buster @@ -160,9 +168,9 @@ Thank you! * v4.1.3beta (2020-02-08) * renamed ENV for adminport (new "IOB_ADMINPORT)") * added new ENVs for "iobroker setup custom" (replacing "REDIS") - * enhancements in startupscript logging + * enhancements in startup script logging * v4.1.2beta (2020-02-02) - * added feature for running userdefined scripts on startup + * added feature for running user defined scripts on startup * small fix for permissions issues on some systems * v4.1.1beta (2020-01-17) * updated openzwave to version 1.6.1007 @@ -174,19 +182,19 @@ Thank you! * small fixes according to "docker best practices" * v4.0.2beta (2019-12-10) * ~~added env for activating redis~~ - * enhancements in startupscript and dockerfile + * enhancements in startup script and docker file * 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 + * some small code fixes ### v4.0.0 (2019-10-25) * v3.1.4beta (2019-10-23) * added env for zwave support * v3.1.3beta (2019-10-17) * enhanced logging of startup-script - * multiarch support (amd64, aarch64, armv7hf) + * multi arch support (amd64, aarch64, armv7hf) * v3.1.2beta (2019-09-03) * using node 10 instead of node 8 * v3.1.1beta (2019-09-02) @@ -204,10 +212,10 @@ Thank you! ### v3.0.0 (2019-05-09) * v2.0.6beta (2019-04-14) * added some additional logging - * fixing some issues for languag env + * fixing some issues for language env * added permission fixing on first start * v2.0.5beta (2019-02-09) - * added ENV to dockerfile + * added ENV to docker file * added EXPOSE for admin * final testing * v2.0.4beta (2019-01-28) @@ -220,7 +228,7 @@ Thank you! * optimizing logging output * optimizing scripts * v2.0.2beta (2019-01-23) - * optimizing and rearraged dockerfile + * optimizing and rearranged docker file * changes for new ioBroker install script * added restoring for empty mounted /opt/iobroker folder * some more small fixes @@ -255,7 +263,7 @@ Thank you! ### v1.0.0 (2017-08-22) * moved and renamed iobroker startup script -* disabled iobroker deamon to (hopefully) fix restart issue +* disabled iobroker daemon to (hopefully) fix restart issue * added some maintenance scripts ### v0.2.1 (2017-08-16) diff --git a/aarch64/Dockerfile b/aarch64/Dockerfile index 0c85450..e11bd09 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -30,8 +30,8 @@ RUN apt-get update && apt-get install -y \ wget \ && rm -rf /var/lib/apt/lists/* -# Install node10 -RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ +# Install node +RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ && apt-get update && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index 54df7f9..a550df3 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -30,8 +30,8 @@ RUN apt-get update && apt-get install -y \ wget \ && rm -rf /var/lib/apt/lists/* -# Install node10 -RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ +# Install node +RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ && apt-get update && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* From b16440963d84881b25db956a816baceb525159f8 Mon Sep 17 00:00:00 2001 From: andre <> Date: Thu, 21 May 2020 00:22:29 +0200 Subject: [PATCH 09/27] fix download of iobroker install.sh --- 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 e11bd09..3a22f81 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -61,7 +61,7 @@ COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh # Install ioBroker WORKDIR / RUN apt-get update \ - && curl -sL https://raw.githubusercontent.com/ioBroker/ioBroker/stable-installer/installer.sh | bash - \ + && curl -sL https://iobroker.net/install.sh | bash - \ && echo $(hostname) > /opt/iobroker/.install_host \ && echo $(hostname) > /opt/.firstrun \ && rm -rf /var/lib/apt/lists/* diff --git a/amd64/Dockerfile b/amd64/Dockerfile index f0a3d33..fc300d5 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -61,7 +61,7 @@ COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh # Install ioBroker WORKDIR / RUN apt-get update \ - && curl -sL https://raw.githubusercontent.com/ioBroker/ioBroker/stable-installer/installer.sh | bash - \ + && curl -sL https://iobroker.net/install.sh | bash - \ && echo $(hostname) > /opt/iobroker/.install_host \ && echo $(hostname) > /opt/.firstrun \ && rm -rf /var/lib/apt/lists/* diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index a550df3..73f0434 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -61,7 +61,7 @@ COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh # Install ioBroker WORKDIR / RUN apt-get update \ - && curl -sL https://raw.githubusercontent.com/ioBroker/ioBroker/stable-installer/installer.sh | bash - \ + && curl -sL https://iobroker.net/install.sh | bash - \ && echo $(hostname) > /opt/iobroker/.install_host \ && echo $(hostname) > /opt/.firstrun \ && rm -rf /var/lib/apt/lists/* From 3a39f16e32a8b2a61ceee8106fc53462e05b5e56 Mon Sep 17 00:00:00 2001 From: andre <> Date: Thu, 21 May 2020 00:23:40 +0200 Subject: [PATCH 10/27] fix download of iobroker install.sh --- 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 e11bd09..3a22f81 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -61,7 +61,7 @@ COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh # Install ioBroker WORKDIR / RUN apt-get update \ - && curl -sL https://raw.githubusercontent.com/ioBroker/ioBroker/stable-installer/installer.sh | bash - \ + && curl -sL https://iobroker.net/install.sh | bash - \ && echo $(hostname) > /opt/iobroker/.install_host \ && echo $(hostname) > /opt/.firstrun \ && rm -rf /var/lib/apt/lists/* diff --git a/amd64/Dockerfile b/amd64/Dockerfile index f0a3d33..fc300d5 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -61,7 +61,7 @@ COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh # Install ioBroker WORKDIR / RUN apt-get update \ - && curl -sL https://raw.githubusercontent.com/ioBroker/ioBroker/stable-installer/installer.sh | bash - \ + && curl -sL https://iobroker.net/install.sh | bash - \ && echo $(hostname) > /opt/iobroker/.install_host \ && echo $(hostname) > /opt/.firstrun \ && rm -rf /var/lib/apt/lists/* diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index a550df3..73f0434 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -61,7 +61,7 @@ COPY scripts/userscript_everystart_example.sh userscript_everystart_example.sh # Install ioBroker WORKDIR / RUN apt-get update \ - && curl -sL https://raw.githubusercontent.com/ioBroker/ioBroker/stable-installer/installer.sh | bash - \ + && curl -sL https://iobroker.net/install.sh | bash - \ && echo $(hostname) > /opt/iobroker/.install_host \ && echo $(hostname) > /opt/.firstrun \ && rm -rf /var/lib/apt/lists/* From 3a4ae3ec5574c2daf187052dbcd6fdf4e1de960e Mon Sep 17 00:00:00 2001 From: buanet Date: Wed, 3 Jun 2020 21:52:28 +0200 Subject: [PATCH 11/27] testing to fix "iobroker host" issue --- amd64/scripts/iobroker_startup.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 1e9b430..f8626bc 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -166,16 +166,20 @@ 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)"..." - bash iobroker host $(cat /opt/iobroker/.install_host) + oldhostname=$(cat /opt/iobroker/.install_host) + newhostname=$(hostname) + sed -i 's/$oldhostname/$newhostname/g' /opt/iobroker/iobroker-data/states.json + sed -i 's/$oldhostname/$newhostname/g' /opt/iobroker/iobroker-data/objects.json + # bash iobroker host $(cat /opt/iobroker/.install_host) rm -f /opt/iobroker/.install_host - echo 'Done.' + echo "Done." echo ' ' elif [ $(bash 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)"..." bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') - echo 'Done.' + echo "Done." echo ' ' fi @@ -201,7 +205,7 @@ then echo "Adminport set by ENV does not match port configured in ioBroker installation." echo "Setting Adminport to \""$adminport"\"..." bash iobroker set admin.0 --port $adminport - echo 'Done.' + echo "Done." echo ' ' fi fi From a86082e09748db9cd8b1953cbc2894eaa12ca73b Mon Sep 17 00:00:00 2001 From: buanet Date: Wed, 3 Jun 2020 22:34:09 +0200 Subject: [PATCH 12/27] testing --- amd64/scripts/iobroker_startup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index f8626bc..1022561 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -168,8 +168,8 @@ then echo "Hostname needs to be updated to " $(hostname)"..." oldhostname=$(cat /opt/iobroker/.install_host) newhostname=$(hostname) - sed -i 's/$oldhostname/$newhostname/g' /opt/iobroker/iobroker-data/states.json - sed -i 's/$oldhostname/$newhostname/g' /opt/iobroker/iobroker-data/objects.json + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json # bash iobroker host $(cat /opt/iobroker/.install_host) rm -f /opt/iobroker/.install_host echo "Done." From 0b143cca5a663855b68726976feeb360d63b5e86 Mon Sep 17 00:00:00 2001 From: buanet Date: Wed, 3 Jun 2020 23:52:57 +0200 Subject: [PATCH 13/27] workaround for renaming issues, preparing beta status --- .VERSION | 2 +- README.md | 10 ++++++---- aarch64/scripts/iobroker_startup.sh | 18 +++++++++++++----- amd64/scripts/iobroker_startup.sh | 6 +++++- armv7hf/scripts/iobroker_startup.sh | 18 +++++++++++++----- 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/.VERSION b/.VERSION index 819609f..2551808 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v4.2.1beta +v4.2.2beta diff --git a/README.md b/README.md index f51b81f..71363e5 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ After this the startup script inside the container will automatically detect and ### Beta testing -If you want to get the newest features and changes feel free to use/ test the beta version of the Docker image. You can find the readme.md file for beta versions [here](https://github.com/buanet/docker-iobroker/blob/beta/README.md). +If you want to get the newest features and changes feel free to use/ test the beta version of the Docker image. You can find the readme.md file for beta versions [here](https://github.com/buanet/docker-iobroker/blob/beta/README.md). Please make sure to read the changelog before testing beta versions. ### Subscribe to updates @@ -157,9 +157,11 @@ Thank you! ## Changelog -### v4.2.1beta (2020-05-10) -* using node 12 instead of 10 -* updated documentation in readme.md +### v4.2.2beta (2020-06-03) +* workaround for renaming issues on startup +* v4.2.1beta (2020-05-10) + * using node 12 instead of 10 + * updated documentation in readme.md ### v4.2.0 (2020-04-14) * v4.1.4beta (2020-04-07) diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 1e9b430..892b84b 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -166,16 +166,24 @@ 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)"..." - bash iobroker host $(cat /opt/iobroker/.install_host) + oldhostname=$(cat /opt/iobroker/.install_host) + newhostname=$(hostname) + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json + # bash iobroker host $(cat /opt/iobroker/.install_host) rm -f /opt/iobroker/.install_host - echo 'Done.' + echo "Done." echo ' ' elif [ $(bash 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)"..." - bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') - echo 'Done.' + oldhostname=$(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + newhostname=$(hostname) + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json + # bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + echo "Done." echo ' ' fi @@ -201,7 +209,7 @@ then echo "Adminport set by ENV does not match port configured in ioBroker installation." echo "Setting Adminport to \""$adminport"\"..." bash iobroker set admin.0 --port $adminport - echo 'Done.' + echo "Done." echo ' ' fi fi diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 1022561..892b84b 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -178,7 +178,11 @@ elif [ $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(? then echo "Hostname in ioBroker does not match the hostname of this container." echo "Updating hostname to " $(hostname)"..." - bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + oldhostname=$(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + newhostname=$(hostname) + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json + # bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') echo "Done." echo ' ' fi diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 1e9b430..892b84b 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -166,16 +166,24 @@ 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)"..." - bash iobroker host $(cat /opt/iobroker/.install_host) + oldhostname=$(cat /opt/iobroker/.install_host) + newhostname=$(hostname) + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json + # bash iobroker host $(cat /opt/iobroker/.install_host) rm -f /opt/iobroker/.install_host - echo 'Done.' + echo "Done." echo ' ' elif [ $(bash 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)"..." - bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') - echo 'Done.' + oldhostname=$(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + newhostname=$(hostname) + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json + sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json + # bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + echo "Done." echo ' ' fi @@ -201,7 +209,7 @@ then echo "Adminport set by ENV does not match port configured in ioBroker installation." echo "Setting Adminport to \""$adminport"\"..." bash iobroker set admin.0 --port $adminport - echo 'Done.' + echo "Done." echo ' ' fi fi From 5db7206b6ec7b28d3f96eb336e3b41eb1be4eb78 Mon Sep 17 00:00:00 2001 From: andre <> Date: Fri, 5 Jun 2020 21:28:29 +0200 Subject: [PATCH 14/27] Testing --- amd64/Dockerfile | 3 +++ amd64/scripts/iobroker_startup.sh | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index fc300d5..0b02751 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -70,6 +70,9 @@ RUN apt-get update \ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp +# Testing new js-controller version +RUN npm install ioBroker/ioBroker.js-controller#3.1.x + # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ && tar -cf /opt/initial_userscripts.tar /opt/userscripts diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 892b84b..ae30e16 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -166,11 +166,11 @@ 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)"..." - oldhostname=$(cat /opt/iobroker/.install_host) - newhostname=$(hostname) - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json - # bash iobroker host $(cat /opt/iobroker/.install_host) + # oldhostname=$(cat /opt/iobroker/.install_host) + # newhostname=$(hostname) + # sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json + # sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json + bash iobroker host $(cat /opt/iobroker/.install_host) rm -f /opt/iobroker/.install_host echo "Done." echo ' ' @@ -178,11 +178,11 @@ elif [ $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(? then echo "Hostname in ioBroker does not match the hostname of this container." echo "Updating hostname to " $(hostname)"..." - oldhostname=$(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') - newhostname=$(hostname) - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json - # bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + # oldhostname=$(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + # newhostname=$(hostname) + # sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json + # sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json + bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') echo "Done." echo ' ' fi From 773ad90893328e35f70dfb767e0e9d49c7696523 Mon Sep 17 00:00:00 2001 From: andre <> Date: Fri, 5 Jun 2020 22:08:27 +0200 Subject: [PATCH 15/27] reverting --- README.md | 2 +- aarch64/scripts/iobroker_startup.sh | 12 ++---------- amd64/Dockerfile | 2 +- amd64/scripts/iobroker_startup.sh | 8 -------- armv7hf/scripts/iobroker_startup.sh | 12 ++---------- 5 files changed, 6 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 71363e5..4606143 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ Thank you! ## Changelog ### v4.2.2beta (2020-06-03) -* workaround for renaming issues on startup +* ~~workaround for renaming issues on startup~~ (fixed in js-controller) * v4.2.1beta (2020-05-10) * using node 12 instead of 10 * updated documentation in readme.md diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 892b84b..4c2b690 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -166,11 +166,7 @@ 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)"..." - oldhostname=$(cat /opt/iobroker/.install_host) - newhostname=$(hostname) - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json - # bash iobroker host $(cat /opt/iobroker/.install_host) + bash iobroker host $(cat /opt/iobroker/.install_host) rm -f /opt/iobroker/.install_host echo "Done." echo ' ' @@ -178,11 +174,7 @@ elif [ $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(? then echo "Hostname in ioBroker does not match the hostname of this container." echo "Updating hostname to " $(hostname)"..." - oldhostname=$(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') - newhostname=$(hostname) - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json - # bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') echo "Done." echo ' ' fi diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 0b02751..92f168b 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -70,7 +70,7 @@ RUN apt-get update \ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp -# Testing new js-controller version +# Temporary testing new js-controller version RUN npm install ioBroker/ioBroker.js-controller#3.1.x # Backup initial ioBroker and userscript folder diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index ae30e16..4c2b690 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -166,10 +166,6 @@ 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)"..." - # oldhostname=$(cat /opt/iobroker/.install_host) - # newhostname=$(hostname) - # sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json - # sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json bash iobroker host $(cat /opt/iobroker/.install_host) rm -f /opt/iobroker/.install_host echo "Done." @@ -178,10 +174,6 @@ elif [ $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(? then echo "Hostname in ioBroker does not match the hostname of this container." echo "Updating hostname to " $(hostname)"..." - # oldhostname=$(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') - # newhostname=$(hostname) - # sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json - # sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') echo "Done." echo ' ' diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 892b84b..4c2b690 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -166,11 +166,7 @@ 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)"..." - oldhostname=$(cat /opt/iobroker/.install_host) - newhostname=$(hostname) - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json - # bash iobroker host $(cat /opt/iobroker/.install_host) + bash iobroker host $(cat /opt/iobroker/.install_host) rm -f /opt/iobroker/.install_host echo "Done." echo ' ' @@ -178,11 +174,7 @@ elif [ $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(? then echo "Hostname in ioBroker does not match the hostname of this container." echo "Updating hostname to " $(hostname)"..." - oldhostname=$(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') - newhostname=$(hostname) - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/states.json - sed -i "s/$oldhostname/$newhostname/g" /opt/iobroker/iobroker-data/objects.json - # bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') + bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') echo "Done." echo ' ' fi From d00d734a3a5308f4ecd3ed476edb6bdc6cb86731 Mon Sep 17 00:00:00 2001 From: andre <> Date: Fri, 5 Jun 2020 23:15:33 +0200 Subject: [PATCH 16/27] prepare new beta --- .VERSION | 2 +- README.md | 6 ++++-- aarch64/Dockerfile | 3 +++ amd64/Dockerfile | 4 ++-- armv7hf/Dockerfile | 3 +++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.VERSION b/.VERSION index 2551808..58d9f45 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v4.2.2beta +v4.2.3beta diff --git a/README.md b/README.md index 4606143..82adb8a 100644 --- a/README.md +++ b/README.md @@ -157,8 +157,10 @@ Thank you! ## Changelog -### v4.2.2beta (2020-06-03) -* ~~workaround for renaming issues on startup~~ (fixed in js-controller) +### v4.2.3beta (2020-06-05) +* updating js-controller to not stable version 3.1.5 to fix renaming issue +* v4.2.2beta (2020-06-03) + * ~~workaround for renaming issues on startup~~ (fixed in js-controller) * v4.2.1beta (2020-05-10) * using node 12 instead of 10 * updated documentation in readme.md diff --git a/aarch64/Dockerfile b/aarch64/Dockerfile index 3a22f81..8fcb57f 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -70,6 +70,9 @@ RUN apt-get update \ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp +# Temporary updating js-controller to not stable version +RUN npm install js-controller@3.1.5 + # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ && tar -cf /opt/initial_userscripts.tar /opt/userscripts diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 92f168b..f56cefd 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -70,8 +70,8 @@ RUN apt-get update \ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp -# Temporary testing new js-controller version -RUN npm install ioBroker/ioBroker.js-controller#3.1.x +# Temporary updating js-controller to not stable version +RUN npm install js-controller@3.1.5 # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index 73f0434..7b491f0 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -70,6 +70,9 @@ RUN apt-get update \ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp +# Temporary updating js-controller to not stable version +RUN npm install js-controller@3.1.5 + # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ && tar -cf /opt/initial_userscripts.tar /opt/userscripts From c0804b8a7d1867e4330a566d4f0f570960eb9953 Mon Sep 17 00:00:00 2001 From: andre <> Date: Fri, 5 Jun 2020 23:51:23 +0200 Subject: [PATCH 17/27] has been late --- 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 8fcb57f..d4e3e90 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -71,7 +71,7 @@ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp # Temporary updating js-controller to not stable version -RUN npm install js-controller@3.1.5 +RUN npm install iobroker.js-controller@3.1.5 # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ diff --git a/amd64/Dockerfile b/amd64/Dockerfile index f56cefd..55f9309 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -71,7 +71,7 @@ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp # Temporary updating js-controller to not stable version -RUN npm install js-controller@3.1.5 +RUN npm install iobroker.js-controller@3.1.5 # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index 7b491f0..ce66351 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -71,7 +71,7 @@ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp # Temporary updating js-controller to not stable version -RUN npm install js-controller@3.1.5 +RUN npm install iobroker.js-controller@3.1.5 # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ From b8bddc55d4d18998b6661cd54b16e6f5f2a1cc41 Mon Sep 17 00:00:00 2001 From: buanet Date: Mon, 8 Jun 2020 11:13:35 +0200 Subject: [PATCH 18/27] testing for multihost support --- amd64/scripts/iobroker_startup.sh | 84 +++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 4c2b690..a796ea4 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -3,6 +3,7 @@ # Reading ENV adminport=$IOB_ADMINPORT avahi=$AVAHI +multihost=$IOB_MULTIHOST objectsdbhost=$IOB_OBJECTSDB_HOST objectsdbport=$IOB_OBJECTSDB_PORT objectsdbtype=$IOB_OBJECTSDB_TYPE @@ -254,6 +255,89 @@ then fi +# Checking ENV for multihost setup +# Configuring objects db host +if [ "$multihost" = "master" ] && [ "$objectsdbtype" = "" ] && [ "$objectsdbhost" = "" ] && [ "$objectsdbport" = "" ] +then + echo "Multihost is set as \"master\" by ENV and no external objects db is set." + echo "Setting host of objects db to \"0.0.0.0\" to allow external communication..." + jq --arg objectsdbhost "0.0.0.0" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + echo "Done." + echo ' ' +elif [ "$multihost" = "master" ] && [ "$objectsdbhost" = "127.0.0.1" ] +then + echo "Multihost is set as \"master\" by ENV. But objects db host is set to \"127.0.0.1\" by ENV too." + echo "This configuration will not work! Please change or remove ENV \"IOB_OBJECTSDB_HOST\" and start over!" + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "master" ] && [ "$objectsdbtype" != "" ] && [ "$objectsdbhost" != "" ] && [ "$objectsdbport" != "" ] +then + echo "Multihost is set as \"master\" by ENV and external objects db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif [[ "$multihost" = "slave" ] && [ "$objectsdbtype" = "" ]] || [[ "$multihost" = "slave" ] && [ "$objectsdbhost" = "" ]] || [[ "$multihost" = "slave" ] && [ "$objectsdbport" = "" ]] +then + echo "Multihost is set as \"slave\" by ENV. But no external objects db is set." + echo "You have to configure ENVs \"IOB_OBJECTSDB_TYPE\", \"IOB_OBJECTSDB_HOST\" and \"IOB_OBJECTSDB_PORT\" to connect to a maser objects db." + echo "Please check your settings and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "slave" ] && [ "$objectsdbtype" != "" ] && [ "$objectsdbhost" != "" ] && [ "$objectsdbport" != "" ] +then + echo "Multihost is set as \"slave\" by ENV and external objects db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif [ "$multihost" != "" ] +then + echo "Multihost is set but it seems like some configuration is missing." + echo "Please checke if you have configured the ENVs \"MULTIHOST\", \"IOB_OBJECTSDB_TYPE\", \"IOB_OBJECTSDB_HOST\" and \"IOB_OBJECTSDB_PORT\" correctly and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +fi +#Configuring states db host +if [ "$multihost" = "master" ] && [ "$statesdbtype" = "" ] && [ "$statesdbhost" = "" ] && [ "$statesdbport" = "" ] +then + echo "Multihost is set as \"master\" by ENV and no external states db is set." + echo "Setting host of states db to \"0.0.0.0\" to allow external communication..." + jq --arg statesdbhost "0.0.0.0" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + echo "Done." + echo ' ' +elif [ "$multihost" = "master" ] && [ "$statesdbhost" = "127.0.0.1" ] +then + echo "Multihost is set as \"master\" by ENV. But states db host is set to \"127.0.0.1\" by ENV too." + echo "This configuration will not work! Please change or remove ENV \"IOB_STATESDB_HOST\" and start over!" + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "master" ] && [ "$statesdbtype" != "" ] && [ "$statesdbhost" != "" ] && [ "$statesdbport" != "" ] +then + echo "Multihost is set as \"master\" by ENV and external states db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif [[ "$multihost" = "slave" ] && [ "$statesdbtype" = "" ]] || [[ "$multihost" = "slave" ] && [ "$statesdbhost" = "" ]] || [[ "$multihost" = "slave" ] && [ "$statesdbport" = "" ]] +then + echo "Multihost is set as \"slave\" by ENV. But no external states db is set." + echo "You have to configure ENVs \"IOB_STATESDB_TYPE\", \"IOB_STATESDB_HOST\" and \"IOB_STATESDB_PORT\" to connect to a maser states db." + echo "Please check your settings and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "slave" ] && [ "$statesdbtype" != "" ] && [ "$statesdbhost" != "" ] && [ "$statesdbport" != "" ] +then + echo "Multihost is set as \"slave\" by ENV and external states db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif [ "$multihost" != "" ] +then + echo "Multihost is set but it seems like some configuration is missing." + echo "Please checke if you have configured the ENVs \"MULTIHOST\", \"IOB_STATESDB_TYPE\", \"IOB_STATESDB_HOST\" and \"IOB_STATESTDB_PORT\" correctly and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +fi + + # Checking ENVs for custom setup of objects db if [ "$objectsdbtype" != "" ] || [ "$objectsdbhost" != "" ] || [ "$objectsdbport" != "" ] then From 1c7d8925662775c028a703c6ec71dc2aa79abd9b Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 9 Jun 2020 11:40:09 +0200 Subject: [PATCH 19/27] testing --- amd64/scripts/iobroker_startup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index a796ea4..ca1d5f1 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -276,7 +276,7 @@ then echo "Skipping this step..." echo "Done." echo ' ' -elif [[ "$multihost" = "slave" ] && [ "$objectsdbtype" = "" ]] || [[ "$multihost" = "slave" ] && [ "$objectsdbhost" = "" ]] || [[ "$multihost" = "slave" ] && [ "$objectsdbport" = "" ]] +elif ([ "$multihost" = "slave" ] && [ "$objectsdbtype" = "" ]) || ([ "$multihost" = "slave" ] && [ "$objectsdbhost" = "" ]) || ([ "$multihost" = "slave" ] && [ "$objectsdbport" = "" ]) then echo "Multihost is set as \"slave\" by ENV. But no external objects db is set." echo "You have to configure ENVs \"IOB_OBJECTSDB_TYPE\", \"IOB_OBJECTSDB_HOST\" and \"IOB_OBJECTSDB_PORT\" to connect to a maser objects db." @@ -316,7 +316,7 @@ then echo "Skipping this step..." echo "Done." echo ' ' -elif [[ "$multihost" = "slave" ] && [ "$statesdbtype" = "" ]] || [[ "$multihost" = "slave" ] && [ "$statesdbhost" = "" ]] || [[ "$multihost" = "slave" ] && [ "$statesdbport" = "" ]] +elif ([ "$multihost" = "slave" ] && [ "$statesdbtype" = "" ]) || ([ "$multihost" = "slave" ] && [ "$statesdbhost" = "" ]) || ([ "$multihost" = "slave" ] && [ "$statesdbport" = "" ]) then echo "Multihost is set as \"slave\" by ENV. But no external states db is set." echo "You have to configure ENVs \"IOB_STATESDB_TYPE\", \"IOB_STATESDB_HOST\" and \"IOB_STATESDB_PORT\" to connect to a maser states db." From 52a247603443526a1167d50ce587ad125891316a Mon Sep 17 00:00:00 2001 From: andre <> Date: Sun, 21 Jun 2020 21:42:47 +0200 Subject: [PATCH 20/27] some testing --- amd64/Dockerfile | 4 +++- amd64/scripts/iobroker_startup.sh | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 55f9309..32f416c 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -92,4 +92,6 @@ ENV DEBIAN_FRONTEND="teletype" \ TZ="Europe/Berlin" # Run startup-script -ENTRYPOINT ["/bin/bash", "-c", "/opt/scripts/iobroker_startup.sh"] +# ENTRYPOINT ["/bin/bash", "-c", "/opt/scripts/iobroker_startup.sh"] +ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] +CMD ["gosu iobroker node node_modules/iobroker.js-controller/controller.js"] diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index ca1d5f1..6227836 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -451,7 +451,7 @@ echo ' ' echo "Starting ioBroker..." echo ' ' -gosu iobroker node node_modules/iobroker.js-controller/controller.js +# gosu iobroker node node_modules/iobroker.js-controller/controller.js # Preventing container restart by keeping a process alive even if iobroker will be stopped -tail -f /dev/null +# tail -f /dev/null From c80b5f9c8b56fec1ddf1041bab05f4add9112fe4 Mon Sep 17 00:00:00 2001 From: andre <> Date: Sun, 21 Jun 2020 22:21:11 +0200 Subject: [PATCH 21/27] some testing --- amd64/Dockerfile | 2 +- amd64/scripts/iobroker_startup.sh | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 32f416c..39d1f2b 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -94,4 +94,4 @@ ENV DEBIAN_FRONTEND="teletype" \ # Run startup-script # ENTRYPOINT ["/bin/bash", "-c", "/opt/scripts/iobroker_startup.sh"] ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] -CMD ["gosu iobroker node node_modules/iobroker.js-controller/controller.js"] +CMD ["iob"] diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 6227836..5b335a3 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -e +if [ "$1" = 'iob' ]; +then # Reading ENV adminport=$IOB_ADMINPORT avahi=$AVAHI @@ -451,7 +454,11 @@ echo ' ' echo "Starting ioBroker..." echo ' ' -# gosu iobroker node node_modules/iobroker.js-controller/controller.js +exec gosu iobroker node node_modules/iobroker.js-controller/controller.js "$@" + +fi + +exec "$@" # Preventing container restart by keeping a process alive even if iobroker will be stopped # tail -f /dev/null From 4b3f57b06314ab016025792a5f3626b85c46c2d5 Mon Sep 17 00:00:00 2001 From: andre <> Date: Sun, 21 Jun 2020 23:55:51 +0200 Subject: [PATCH 22/27] some testing --- amd64/Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 39d1f2b..ddb8699 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -79,7 +79,9 @@ RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ # Setting up iobroker-user (shell and home directory) RUN chsh -s /bin/bash iobroker \ - && usermod --home /opt/iobroker iobroker + && usermod --home /opt/iobroker iobroker \ + && usermod -u 901 iobroker \ + && groupmod -g 901 iobroker # Setting up ENVs ENV DEBIAN_FRONTEND="teletype" \ @@ -87,8 +89,8 @@ ENV DEBIAN_FRONTEND="teletype" \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ PACKAGES="vi" \ - SETGID=1000 \ - SETUID=1000 \ + SETGID=901 \ + SETUID=901 \ TZ="Europe/Berlin" # Run startup-script From 397b4ea536fa0264f8e1172df0a7e14247b04cdd Mon Sep 17 00:00:00 2001 From: buanet Date: Mon, 22 Jun 2020 16:24:30 +0200 Subject: [PATCH 23/27] some testing --- amd64/Dockerfile | 13 +++--- amd64/scripts/iobroker_startup.sh | 72 ++++++++++++++----------------- 2 files changed, 38 insertions(+), 47 deletions(-) diff --git a/amd64/Dockerfile b/amd64/Dockerfile index ddb8699..597c0f0 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -80,20 +80,17 @@ RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ # Setting up iobroker-user (shell and home directory) RUN chsh -s /bin/bash iobroker \ && usermod --home /opt/iobroker iobroker \ - && usermod -u 901 iobroker \ - && groupmod -g 901 iobroker + && usermod -u 1000 iobroker \ + && groupmod -g 1000 iobroker # Setting up ENVs ENV DEBIAN_FRONTEND="teletype" \ LANG="de_DE.UTF-8" \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ - PACKAGES="vi" \ - SETGID=901 \ - SETUID=901 \ + SETGID=1000 \ + SETUID=1000 \ TZ="Europe/Berlin" # Run startup-script -# ENTRYPOINT ["/bin/bash", "-c", "/opt/scripts/iobroker_startup.sh"] -ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] -CMD ["iob"] +ENTRYPOINT ["/bin/bash", "-c", "/opt/scripts/iobroker_startup.sh"] diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 5b335a3..9916a81 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -1,8 +1,5 @@ #!/bin/bash -set -e -if [ "$1" = 'iob' ]; -then # Reading ENV adminport=$IOB_ADMINPORT avahi=$AVAHI @@ -79,7 +76,7 @@ then echo "Installing additional packages is set by ENV." echo "The following packages will be installed:" $packages"..." echo $packages > /opt/scripts/.packages - bash /opt/scripts/setup_packages.sh + bash /opt/scripts/setup_packages.sh echo "Done." echo ' ' fi @@ -87,13 +84,14 @@ then then echo "Different UID and/ or GID is set by ENV." echo "Changing UID to "$setuid" and GID to "$setgid"..." - usermod -u $setuid iobroker - groupmod -g $setgid iobroker + usermod -u $setuid iobroker + groupmod -g $setgid iobroker echo "Done." echo ' ' fi else echo "Nothing to do here." + echo ' ' fi # Change directory for next steps @@ -111,7 +109,7 @@ echo ' ' 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 / + tar -xf /opt/initial_iobroker.tar -C / echo "Done." elif [ -f /opt/iobroker/iobroker ] then @@ -119,11 +117,11 @@ then 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 + 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 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" @@ -204,7 +202,7 @@ then then echo "Adminport set by ENV does not match port configured in ioBroker installation." echo "Setting Adminport to \""$adminport"\"..." - bash iobroker set admin.0 --port $adminport + bash iobroker set admin.0 --port $adminport echo "Done." echo ' ' fi @@ -217,8 +215,8 @@ then if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." - chmod 755 /opt/scripts/setup_avahi.sh - bash /opt/scripts/setup_avahi.sh + chmod 755 /opt/scripts/setup_avahi.sh + bash /opt/scripts/setup_avahi.sh echo "Done." echo ' ' fi @@ -231,8 +229,8 @@ then if [ "$zwave" = "true" ] then echo "Z-Wave is activated by ENV." - chmod 755 /opt/scripts/setup_zwave.sh - bash /opt/scripts/setup_zwave.sh + chmod 755 /opt/scripts/setup_zwave.sh + bash /opt/scripts/setup_zwave.sh echo "Done." echo ' ' fi @@ -264,7 +262,7 @@ if [ "$multihost" = "master" ] && [ "$objectsdbtype" = "" ] && [ "$objectsdbhost then echo "Multihost is set as \"master\" by ENV and no external objects db is set." echo "Setting host of objects db to \"0.0.0.0\" to allow external communication..." - jq --arg objectsdbhost "0.0.0.0" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbhost "0.0.0.0" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." echo ' ' elif [ "$multihost" = "master" ] && [ "$objectsdbhost" = "127.0.0.1" ] @@ -304,7 +302,7 @@ if [ "$multihost" = "master" ] && [ "$statesdbtype" = "" ] && [ "$statesdbhost" then echo "Multihost is set as \"master\" by ENV and no external states db is set." echo "Setting host of states db to \"0.0.0.0\" to allow external communication..." - jq --arg statesdbhost "0.0.0.0" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbhost "0.0.0.0" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." echo ' ' elif [ "$multihost" = "master" ] && [ "$statesdbhost" = "127.0.0.1" ] @@ -348,7 +346,7 @@ then then echo "ENV IOB_OBJECTSDB_TYPE is set and value is different from detected ioBroker installation." echo "Setting type of objects db to \""$objectsdbtype"\"..." - jq --arg objectsdbtype "$objectsdbtype" '.objects.type = $objectsdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbtype "$objectsdbtype" '.objects.type = $objectsdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_OBJECTSDB_TYPE is set and value meets detected ioBroker installation. Nothing to do here." @@ -357,7 +355,7 @@ then then echo "ENV IOB_OBJECTSDB_HOST is set and value is different from detected ioBroker installation." echo "Setting host of objects db to \""$objectsdbhost"\"..." - jq --arg objectsdbhost "$objectsdbhost" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbhost "$objectsdbhost" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_OBJECTSDB_HOST is set and value meets detected ioBroker installation. Nothing to do here." @@ -366,7 +364,7 @@ then then echo "ENV IOB_OBJECTSDB_PORT is set and value is different from detected ioBroker installation." echo "Setting port of objects db to \""$objectsdbport"\"..." - jq --arg objectsdbport "$objectsdbport" '.objects.port = $objectsdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbport "$objectsdbport" '.objects.port = $objectsdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_OBJECTSDB_PORT is set and value meets detected ioBroker installation. Nothing to do here." @@ -382,7 +380,7 @@ then then echo "ENV IOB_STATESDB_TYPE is set and value is different from detected ioBroker installation." echo "Setting type of states db to \""$statesdbtype"\"..." - jq --arg statesdbtype "$statesdbtype" '.states.type = $statesdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbtype "$statesdbtype" '.states.type = $statesdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_STATESDB_TYPE is set and value meets detected ioBroker installation. Nothing to do here." @@ -391,7 +389,7 @@ then then echo "ENV IOB_STATESDB_HOST is set and value is different from detected ioBroker installation." echo "Setting host of states db to \""$statesdbhost"\"..." - jq --arg statesdbhost "$statesdbhost" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbhost "$statesdbhost" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_STATESDB_HOST is set and value meets detected ioBroker installation. Nothing to do here." @@ -400,7 +398,7 @@ then then echo "ENV IOB_STATESDB_PORT is set and value is different from detected ioBroker installation." echo "Setting port of states db to \""$statesdbport"\"..." - jq --arg statesdbport "$statesdbport" '.states.port = $statesdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbport "$statesdbport" '.states.port = $statesdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_STATESDB_PORT is set and value meets detected ioBroker installation. Nothing to do here." @@ -413,9 +411,9 @@ fi if [ `find /opt/userscripts -type f | wc -l` -lt 1 ] then echo "There is no data detected in /opt/userscripts. Restoring exapmple userscripts..." - tar -xf /opt/initial_userscripts.tar -C / - chmod 755 /opt/userscripts/userscript_firststart_example.sh - chmod 755 /opt/userscripts/userscript_everystart_example.sh + tar -xf /opt/initial_userscripts.tar -C / + chmod 755 /opt/userscripts/userscript_firststart_example.sh + chmod 755 /opt/userscripts/userscript_everystart_example.sh echo "Done." echo ' ' elif [ -f /opt/userscripts/userscript_firststart.sh ] || [ -f /opt/userscripts/userscript_everystart.sh ] @@ -424,17 +422,17 @@ then then echo "Userscript for first start detected and this is the first start of a new container." echo "Running userscript_firststart.sh..." - chmod 755 /opt/userscripts/userscript_firststart.sh - bash /opt/userscripts/userscript_firststart.sh - rm -f /opt/.firstrun + chmod 755 /opt/userscripts/userscript_firststart.sh + bash /opt/userscripts/userscript_firststart.sh + rm -f /opt/.firstrun echo "Done." echo ' ' fi if [ -f /opt/userscripts/userscript_everystart.sh ] then echo "Userscript for every start detected. Running userscript_everystart.sh..." - chmod 755 /opt/userscripts/userscript_everystart.sh - bash /opt/userscripts/userscript_everystart.sh + chmod 755 /opt/userscripts/userscript_everystart.sh + bash /opt/userscripts/userscript_everystart.sh echo "Done." echo ' ' fi @@ -454,11 +452,7 @@ echo ' ' echo "Starting ioBroker..." echo ' ' -exec gosu iobroker node node_modules/iobroker.js-controller/controller.js "$@" - -fi - -exec "$@" +exec gosu iobroker node node_modules/iobroker.js-controller/controller.js # Preventing container restart by keeping a process alive even if iobroker will be stopped -# tail -f /dev/null +tail -f /dev/null From 314590d97f51d76086af9be3741ac44dc0680ed7 Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 23 Jun 2020 00:23:42 +0200 Subject: [PATCH 24/27] some testing --- amd64/scripts/iobroker_startup.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 9916a81..0d0fb0d 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -439,9 +439,6 @@ then fi -sleep 5 - - ##### # Starting ioBroker ##### @@ -452,7 +449,19 @@ echo ' ' echo "Starting ioBroker..." echo ' ' -exec gosu iobroker node node_modules/iobroker.js-controller/controller.js +# Function for graceful shutdown by SIGTERM signal +shut_down() { + echo ' ' + echo "Recived termination signal (SIGTERM)." + echo "Shutting down ioBroker..." + pid=$(ps -ef | awk '/[j]s.controller/{print $2}') + kill -SIGTERM "$pid" + exit +} + +trap 'shut_down' SIGTERM + +gosu iobroker node node_modules/iobroker.js-controller/controller.js & wait # Preventing container restart by keeping a process alive even if iobroker will be stopped tail -f /dev/null From 71076baae3c15d128938f5979f1f3c73227deb58 Mon Sep 17 00:00:00 2001 From: buanet Date: Tue, 23 Jun 2020 08:19:19 +0200 Subject: [PATCH 25/27] prepare new beta --- .VERSION | 2 +- README.md | 14 ++- aarch64/Dockerfile | 5 +- aarch64/scripts/iobroker_startup.sh | 162 ++++++++++++++++++++++------ amd64/scripts/iobroker_startup.sh | 4 +- armv7hf/Dockerfile | 5 +- armv7hf/scripts/iobroker_startup.sh | 162 ++++++++++++++++++++++------ 7 files changed, 280 insertions(+), 74 deletions(-) diff --git a/.VERSION b/.VERSION index 58d9f45..536a94d 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v4.2.3beta +v4.2.4beta diff --git a/README.md b/README.md index 82adb8a..e9143d6 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ You do not have to declare every single variable when setting up your container. |---|---|---| |AVAHI|false|Installs and activates avahi-daemon for supporting yahka-adapter, can be "true" or "false"| |IOB_ADMINPORT|8081|Sets ioBroker adminport on startup| +|IOB_MULTIHOST|master|Sets ioBroker instance as "master" or "slave" for multihost (additional config for objectsdb and statesdb needed)| |IOB_OBJECTSDB_HOST|127.0.0.1|Sets hostname for ioBroker objects db| |IOB_OBJECTSDB_PORT|9001|Sets port for ioBroker objects db| |IOB_OBJECTSDB_TYPE|file|Sets type of ioBroker objects db, cloud be "file", "redis" or "couch"| @@ -119,6 +120,10 @@ Basically there are two different scripts which will be read and called by the s Hint: To get familiar with that feature try the following: Create a Container, mount an empty folder to /opt/userscripts, start your container. Two scripts will be restored into the empty folder. Rename the example scripts by simply removing "\_example". Restart your container and take a look at the Log. In "Step 4 of 5: Applying special settings" you will see the messages generated by the example userscripts. +### Multihost + +Details will follow soon. + ## Best practices ### Avoid using "latest" tag @@ -157,8 +162,13 @@ Thank you! ## Changelog -### v4.2.3beta (2020-06-05) -* updating js-controller to not stable version 3.1.5 to fix renaming issue +### v4.2.4beta (2020-06-23) +* added graceful shutdown +* small fix for GID/UID handling +* adding new ENV "IOB_MULTIHOST" for multihost support +* small syntax fixes in iobroker_startup.sh +* v4.2.3beta (2020-06-05) + * updating js-controller to not stable version 3.1.5 to fix renaming issue * v4.2.2beta (2020-06-03) * ~~workaround for renaming issues on startup~~ (fixed in js-controller) * v4.2.1beta (2020-05-10) diff --git a/aarch64/Dockerfile b/aarch64/Dockerfile index d4e3e90..85f6760 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -79,14 +79,15 @@ RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ # Setting up iobroker-user (shell and home directory) RUN chsh -s /bin/bash iobroker \ - && usermod --home /opt/iobroker iobroker + && usermod --home /opt/iobroker iobroker \ + && usermod -u 1000 iobroker \ + && groupmod -g 1000 iobroker # Setting up ENVs ENV DEBIAN_FRONTEND="teletype" \ LANG="de_DE.UTF-8" \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ - PACKAGES="vi" \ SETGID=1000 \ SETUID=1000 \ TZ="Europe/Berlin" diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 4c2b690..63c4e89 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -3,6 +3,7 @@ # Reading ENV adminport=$IOB_ADMINPORT avahi=$AVAHI +multihost=$IOB_MULTIHOST objectsdbhost=$IOB_OBJECTSDB_HOST objectsdbport=$IOB_OBJECTSDB_PORT objectsdbtype=$IOB_OBJECTSDB_TYPE @@ -75,7 +76,7 @@ then echo "Installing additional packages is set by ENV." echo "The following packages will be installed:" $packages"..." echo $packages > /opt/scripts/.packages - bash /opt/scripts/setup_packages.sh + bash /opt/scripts/setup_packages.sh echo "Done." echo ' ' fi @@ -83,13 +84,14 @@ then then echo "Different UID and/ or GID is set by ENV." echo "Changing UID to "$setuid" and GID to "$setgid"..." - usermod -u $setuid iobroker - groupmod -g $setgid iobroker + usermod -u $setuid iobroker + groupmod -g $setgid iobroker echo "Done." echo ' ' fi else echo "Nothing to do here." + echo ' ' fi # Change directory for next steps @@ -107,7 +109,7 @@ echo ' ' 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 / + tar -xf /opt/initial_iobroker.tar -C / echo "Done." elif [ -f /opt/iobroker/iobroker ] then @@ -115,11 +117,11 @@ then 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 + 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 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" @@ -200,7 +202,7 @@ then then echo "Adminport set by ENV does not match port configured in ioBroker installation." echo "Setting Adminport to \""$adminport"\"..." - bash iobroker set admin.0 --port $adminport + bash iobroker set admin.0 --port $adminport echo "Done." echo ' ' fi @@ -213,8 +215,8 @@ then if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." - chmod 755 /opt/scripts/setup_avahi.sh - bash /opt/scripts/setup_avahi.sh + chmod 755 /opt/scripts/setup_avahi.sh + bash /opt/scripts/setup_avahi.sh echo "Done." echo ' ' fi @@ -227,8 +229,8 @@ then if [ "$zwave" = "true" ] then echo "Z-Wave is activated by ENV." - chmod 755 /opt/scripts/setup_zwave.sh - bash /opt/scripts/setup_zwave.sh + chmod 755 /opt/scripts/setup_zwave.sh + bash /opt/scripts/setup_zwave.sh echo "Done." echo ' ' fi @@ -254,6 +256,89 @@ then fi +# Checking ENV for multihost setup +# Configuring objects db host +if [ "$multihost" = "master" ] && [ "$objectsdbtype" = "" ] && [ "$objectsdbhost" = "" ] && [ "$objectsdbport" = "" ] +then + echo "Multihost is set as \"master\" by ENV and no external objects db is set." + echo "Setting host of objects db to \"0.0.0.0\" to allow external communication..." + jq --arg objectsdbhost "0.0.0.0" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + echo "Done." + echo ' ' +elif [ "$multihost" = "master" ] && [ "$objectsdbhost" = "127.0.0.1" ] +then + echo "Multihost is set as \"master\" by ENV. But objects db host is set to \"127.0.0.1\" by ENV too." + echo "This configuration will not work! Please change or remove ENV \"IOB_OBJECTSDB_HOST\" and start over!" + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "master" ] && [ "$objectsdbtype" != "" ] && [ "$objectsdbhost" != "" ] && [ "$objectsdbport" != "" ] +then + echo "Multihost is set as \"master\" by ENV and external objects db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif ([ "$multihost" = "slave" ] && [ "$objectsdbtype" = "" ]) || ([ "$multihost" = "slave" ] && [ "$objectsdbhost" = "" ]) || ([ "$multihost" = "slave" ] && [ "$objectsdbport" = "" ]) +then + echo "Multihost is set as \"slave\" by ENV. But no external objects db is set." + echo "You have to configure ENVs \"IOB_OBJECTSDB_TYPE\", \"IOB_OBJECTSDB_HOST\" and \"IOB_OBJECTSDB_PORT\" to connect to a maser objects db." + echo "Please check your settings and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "slave" ] && [ "$objectsdbtype" != "" ] && [ "$objectsdbhost" != "" ] && [ "$objectsdbport" != "" ] +then + echo "Multihost is set as \"slave\" by ENV and external objects db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif [ "$multihost" != "" ] +then + echo "Multihost is set but it seems like some configuration is missing." + echo "Please checke if you have configured the ENVs \"MULTIHOST\", \"IOB_OBJECTSDB_TYPE\", \"IOB_OBJECTSDB_HOST\" and \"IOB_OBJECTSDB_PORT\" correctly and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +fi +#Configuring states db host +if [ "$multihost" = "master" ] && [ "$statesdbtype" = "" ] && [ "$statesdbhost" = "" ] && [ "$statesdbport" = "" ] +then + echo "Multihost is set as \"master\" by ENV and no external states db is set." + echo "Setting host of states db to \"0.0.0.0\" to allow external communication..." + jq --arg statesdbhost "0.0.0.0" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + echo "Done." + echo ' ' +elif [ "$multihost" = "master" ] && [ "$statesdbhost" = "127.0.0.1" ] +then + echo "Multihost is set as \"master\" by ENV. But states db host is set to \"127.0.0.1\" by ENV too." + echo "This configuration will not work! Please change or remove ENV \"IOB_STATESDB_HOST\" and start over!" + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "master" ] && [ "$statesdbtype" != "" ] && [ "$statesdbhost" != "" ] && [ "$statesdbport" != "" ] +then + echo "Multihost is set as \"master\" by ENV and external states db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif ([ "$multihost" = "slave" ] && [ "$statesdbtype" = "" ]) || ([ "$multihost" = "slave" ] && [ "$statesdbhost" = "" ]) || ([ "$multihost" = "slave" ] && [ "$statesdbport" = "" ]) +then + echo "Multihost is set as \"slave\" by ENV. But no external states db is set." + echo "You have to configure ENVs \"IOB_STATESDB_TYPE\", \"IOB_STATESDB_HOST\" and \"IOB_STATESDB_PORT\" to connect to a maser states db." + echo "Please check your settings and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "slave" ] && [ "$statesdbtype" != "" ] && [ "$statesdbhost" != "" ] && [ "$statesdbport" != "" ] +then + echo "Multihost is set as \"slave\" by ENV and external states db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif [ "$multihost" != "" ] +then + echo "Multihost is set but it seems like some configuration is missing." + echo "Please checke if you have configured the ENVs \"MULTIHOST\", \"IOB_STATESDB_TYPE\", \"IOB_STATESDB_HOST\" and \"IOB_STATESTDB_PORT\" correctly and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +fi + + # Checking ENVs for custom setup of objects db if [ "$objectsdbtype" != "" ] || [ "$objectsdbhost" != "" ] || [ "$objectsdbport" != "" ] then @@ -261,7 +346,7 @@ then then echo "ENV IOB_OBJECTSDB_TYPE is set and value is different from detected ioBroker installation." echo "Setting type of objects db to \""$objectsdbtype"\"..." - jq --arg objectsdbtype "$objectsdbtype" '.objects.type = $objectsdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbtype "$objectsdbtype" '.objects.type = $objectsdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_OBJECTSDB_TYPE is set and value meets detected ioBroker installation. Nothing to do here." @@ -270,7 +355,7 @@ then then echo "ENV IOB_OBJECTSDB_HOST is set and value is different from detected ioBroker installation." echo "Setting host of objects db to \""$objectsdbhost"\"..." - jq --arg objectsdbhost "$objectsdbhost" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbhost "$objectsdbhost" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_OBJECTSDB_HOST is set and value meets detected ioBroker installation. Nothing to do here." @@ -279,7 +364,7 @@ then then echo "ENV IOB_OBJECTSDB_PORT is set and value is different from detected ioBroker installation." echo "Setting port of objects db to \""$objectsdbport"\"..." - jq --arg objectsdbport "$objectsdbport" '.objects.port = $objectsdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbport "$objectsdbport" '.objects.port = $objectsdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_OBJECTSDB_PORT is set and value meets detected ioBroker installation. Nothing to do here." @@ -295,7 +380,7 @@ then then echo "ENV IOB_STATESDB_TYPE is set and value is different from detected ioBroker installation." echo "Setting type of states db to \""$statesdbtype"\"..." - jq --arg statesdbtype "$statesdbtype" '.states.type = $statesdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbtype "$statesdbtype" '.states.type = $statesdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_STATESDB_TYPE is set and value meets detected ioBroker installation. Nothing to do here." @@ -304,7 +389,7 @@ then then echo "ENV IOB_STATESDB_HOST is set and value is different from detected ioBroker installation." echo "Setting host of states db to \""$statesdbhost"\"..." - jq --arg statesdbhost "$statesdbhost" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbhost "$statesdbhost" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_STATESDB_HOST is set and value meets detected ioBroker installation. Nothing to do here." @@ -313,7 +398,7 @@ then then echo "ENV IOB_STATESDB_PORT is set and value is different from detected ioBroker installation." echo "Setting port of states db to \""$statesdbport"\"..." - jq --arg statesdbport "$statesdbport" '.states.port = $statesdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbport "$statesdbport" '.states.port = $statesdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_STATESDB_PORT is set and value meets detected ioBroker installation. Nothing to do here." @@ -326,9 +411,9 @@ fi if [ `find /opt/userscripts -type f | wc -l` -lt 1 ] then echo "There is no data detected in /opt/userscripts. Restoring exapmple userscripts..." - tar -xf /opt/initial_userscripts.tar -C / - chmod 755 /opt/userscripts/userscript_firststart_example.sh - chmod 755 /opt/userscripts/userscript_everystart_example.sh + tar -xf /opt/initial_userscripts.tar -C / + chmod 755 /opt/userscripts/userscript_firststart_example.sh + chmod 755 /opt/userscripts/userscript_everystart_example.sh echo "Done." echo ' ' elif [ -f /opt/userscripts/userscript_firststart.sh ] || [ -f /opt/userscripts/userscript_everystart.sh ] @@ -337,26 +422,23 @@ then then echo "Userscript for first start detected and this is the first start of a new container." echo "Running userscript_firststart.sh..." - chmod 755 /opt/userscripts/userscript_firststart.sh - bash /opt/userscripts/userscript_firststart.sh - rm -f /opt/.firstrun + chmod 755 /opt/userscripts/userscript_firststart.sh + bash /opt/userscripts/userscript_firststart.sh + rm -f /opt/.firstrun echo "Done." echo ' ' fi if [ -f /opt/userscripts/userscript_everystart.sh ] then echo "Userscript for every start detected. Running userscript_everystart.sh..." - chmod 755 /opt/userscripts/userscript_everystart.sh - bash /opt/userscripts/userscript_everystart.sh + chmod 755 /opt/userscripts/userscript_everystart.sh + bash /opt/userscripts/userscript_everystart.sh echo "Done." echo ' ' fi fi -sleep 5 - - ##### # Starting ioBroker ##### @@ -367,7 +449,21 @@ echo ' ' echo "Starting ioBroker..." echo ' ' -gosu iobroker node node_modules/iobroker.js-controller/controller.js +# Function for graceful shutdown by SIGTERM signal +shut_down() { + echo ' ' + echo "Recived termination signal (SIGTERM)." + echo "Shutting down ioBroker..." + pid=$(ps -ef | awk '/[j]s.controller/{print $2}') + kill -SIGTERM "$pid" + exit +} -# Preventing container restart by keeping a process alive even if iobroker will be stopped +# Trap to get signal for graceful shutdown +trap 'shut_down' SIGTERM + +# IoBroker start +gosu iobroker node node_modules/iobroker.js-controller/controller.js & wait + +# Fallback process for keeping container running when ioBroker is stopped for maintenance (e.g. js-controller update) tail -f /dev/null diff --git a/amd64/scripts/iobroker_startup.sh b/amd64/scripts/iobroker_startup.sh index 0d0fb0d..63c4e89 100644 --- a/amd64/scripts/iobroker_startup.sh +++ b/amd64/scripts/iobroker_startup.sh @@ -459,9 +459,11 @@ shut_down() { exit } +# Trap to get signal for graceful shutdown trap 'shut_down' SIGTERM +# IoBroker start gosu iobroker node node_modules/iobroker.js-controller/controller.js & wait -# Preventing container restart by keeping a process alive even if iobroker will be stopped +# Fallback process for keeping container running when ioBroker is stopped for maintenance (e.g. js-controller update) tail -f /dev/null diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index ce66351..63f217f 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -79,14 +79,15 @@ RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ # Setting up iobroker-user (shell and home directory) RUN chsh -s /bin/bash iobroker \ - && usermod --home /opt/iobroker iobroker + && usermod --home /opt/iobroker iobroker \ + && usermod -u 1000 iobroker \ + && groupmod -g 1000 iobroker # Setting up ENVs ENV DEBIAN_FRONTEND="teletype" \ LANG="de_DE.UTF-8" \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ - PACKAGES="vim" \ SETGID=1000 \ SETUID=1000 \ TZ="Europe/Berlin" diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 4c2b690..63c4e89 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -3,6 +3,7 @@ # Reading ENV adminport=$IOB_ADMINPORT avahi=$AVAHI +multihost=$IOB_MULTIHOST objectsdbhost=$IOB_OBJECTSDB_HOST objectsdbport=$IOB_OBJECTSDB_PORT objectsdbtype=$IOB_OBJECTSDB_TYPE @@ -75,7 +76,7 @@ then echo "Installing additional packages is set by ENV." echo "The following packages will be installed:" $packages"..." echo $packages > /opt/scripts/.packages - bash /opt/scripts/setup_packages.sh + bash /opt/scripts/setup_packages.sh echo "Done." echo ' ' fi @@ -83,13 +84,14 @@ then then echo "Different UID and/ or GID is set by ENV." echo "Changing UID to "$setuid" and GID to "$setgid"..." - usermod -u $setuid iobroker - groupmod -g $setgid iobroker + usermod -u $setuid iobroker + groupmod -g $setgid iobroker echo "Done." echo ' ' fi else echo "Nothing to do here." + echo ' ' fi # Change directory for next steps @@ -107,7 +109,7 @@ echo ' ' 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 / + tar -xf /opt/initial_iobroker.tar -C / echo "Done." elif [ -f /opt/iobroker/iobroker ] then @@ -115,11 +117,11 @@ then 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 + 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 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" @@ -200,7 +202,7 @@ then then echo "Adminport set by ENV does not match port configured in ioBroker installation." echo "Setting Adminport to \""$adminport"\"..." - bash iobroker set admin.0 --port $adminport + bash iobroker set admin.0 --port $adminport echo "Done." echo ' ' fi @@ -213,8 +215,8 @@ then if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." - chmod 755 /opt/scripts/setup_avahi.sh - bash /opt/scripts/setup_avahi.sh + chmod 755 /opt/scripts/setup_avahi.sh + bash /opt/scripts/setup_avahi.sh echo "Done." echo ' ' fi @@ -227,8 +229,8 @@ then if [ "$zwave" = "true" ] then echo "Z-Wave is activated by ENV." - chmod 755 /opt/scripts/setup_zwave.sh - bash /opt/scripts/setup_zwave.sh + chmod 755 /opt/scripts/setup_zwave.sh + bash /opt/scripts/setup_zwave.sh echo "Done." echo ' ' fi @@ -254,6 +256,89 @@ then fi +# Checking ENV for multihost setup +# Configuring objects db host +if [ "$multihost" = "master" ] && [ "$objectsdbtype" = "" ] && [ "$objectsdbhost" = "" ] && [ "$objectsdbport" = "" ] +then + echo "Multihost is set as \"master\" by ENV and no external objects db is set." + echo "Setting host of objects db to \"0.0.0.0\" to allow external communication..." + jq --arg objectsdbhost "0.0.0.0" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + echo "Done." + echo ' ' +elif [ "$multihost" = "master" ] && [ "$objectsdbhost" = "127.0.0.1" ] +then + echo "Multihost is set as \"master\" by ENV. But objects db host is set to \"127.0.0.1\" by ENV too." + echo "This configuration will not work! Please change or remove ENV \"IOB_OBJECTSDB_HOST\" and start over!" + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "master" ] && [ "$objectsdbtype" != "" ] && [ "$objectsdbhost" != "" ] && [ "$objectsdbport" != "" ] +then + echo "Multihost is set as \"master\" by ENV and external objects db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif ([ "$multihost" = "slave" ] && [ "$objectsdbtype" = "" ]) || ([ "$multihost" = "slave" ] && [ "$objectsdbhost" = "" ]) || ([ "$multihost" = "slave" ] && [ "$objectsdbport" = "" ]) +then + echo "Multihost is set as \"slave\" by ENV. But no external objects db is set." + echo "You have to configure ENVs \"IOB_OBJECTSDB_TYPE\", \"IOB_OBJECTSDB_HOST\" and \"IOB_OBJECTSDB_PORT\" to connect to a maser objects db." + echo "Please check your settings and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "slave" ] && [ "$objectsdbtype" != "" ] && [ "$objectsdbhost" != "" ] && [ "$objectsdbport" != "" ] +then + echo "Multihost is set as \"slave\" by ENV and external objects db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif [ "$multihost" != "" ] +then + echo "Multihost is set but it seems like some configuration is missing." + echo "Please checke if you have configured the ENVs \"MULTIHOST\", \"IOB_OBJECTSDB_TYPE\", \"IOB_OBJECTSDB_HOST\" and \"IOB_OBJECTSDB_PORT\" correctly and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +fi +#Configuring states db host +if [ "$multihost" = "master" ] && [ "$statesdbtype" = "" ] && [ "$statesdbhost" = "" ] && [ "$statesdbport" = "" ] +then + echo "Multihost is set as \"master\" by ENV and no external states db is set." + echo "Setting host of states db to \"0.0.0.0\" to allow external communication..." + jq --arg statesdbhost "0.0.0.0" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + echo "Done." + echo ' ' +elif [ "$multihost" = "master" ] && [ "$statesdbhost" = "127.0.0.1" ] +then + echo "Multihost is set as \"master\" by ENV. But states db host is set to \"127.0.0.1\" by ENV too." + echo "This configuration will not work! Please change or remove ENV \"IOB_STATESDB_HOST\" and start over!" + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "master" ] && [ "$statesdbtype" != "" ] && [ "$statesdbhost" != "" ] && [ "$statesdbport" != "" ] +then + echo "Multihost is set as \"master\" by ENV and external states db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif ([ "$multihost" = "slave" ] && [ "$statesdbtype" = "" ]) || ([ "$multihost" = "slave" ] && [ "$statesdbhost" = "" ]) || ([ "$multihost" = "slave" ] && [ "$statesdbport" = "" ]) +then + echo "Multihost is set as \"slave\" by ENV. But no external states db is set." + echo "You have to configure ENVs \"IOB_STATESDB_TYPE\", \"IOB_STATESDB_HOST\" and \"IOB_STATESDB_PORT\" to connect to a maser states db." + echo "Please check your settings and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +elif [ "$multihost" = "slave" ] && [ "$statesdbtype" != "" ] && [ "$statesdbhost" != "" ] && [ "$statesdbport" != "" ] +then + echo "Multihost is set as \"slave\" by ENV and external states db is set." + echo "Skipping this step..." + echo "Done." + echo ' ' +elif [ "$multihost" != "" ] +then + echo "Multihost is set but it seems like some configuration is missing." + echo "Please checke if you have configured the ENVs \"MULTIHOST\", \"IOB_STATESDB_TYPE\", \"IOB_STATESDB_HOST\" and \"IOB_STATESTDB_PORT\" correctly and start over." + echo "For more information see readme.md on Github (https://github.com/buanet/docker-iobroker)." + exit 1 +fi + + # Checking ENVs for custom setup of objects db if [ "$objectsdbtype" != "" ] || [ "$objectsdbhost" != "" ] || [ "$objectsdbport" != "" ] then @@ -261,7 +346,7 @@ then then echo "ENV IOB_OBJECTSDB_TYPE is set and value is different from detected ioBroker installation." echo "Setting type of objects db to \""$objectsdbtype"\"..." - jq --arg objectsdbtype "$objectsdbtype" '.objects.type = $objectsdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbtype "$objectsdbtype" '.objects.type = $objectsdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_OBJECTSDB_TYPE is set and value meets detected ioBroker installation. Nothing to do here." @@ -270,7 +355,7 @@ then then echo "ENV IOB_OBJECTSDB_HOST is set and value is different from detected ioBroker installation." echo "Setting host of objects db to \""$objectsdbhost"\"..." - jq --arg objectsdbhost "$objectsdbhost" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbhost "$objectsdbhost" '.objects.host = $objectsdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_OBJECTSDB_HOST is set and value meets detected ioBroker installation. Nothing to do here." @@ -279,7 +364,7 @@ then then echo "ENV IOB_OBJECTSDB_PORT is set and value is different from detected ioBroker installation." echo "Setting port of objects db to \""$objectsdbport"\"..." - jq --arg objectsdbport "$objectsdbport" '.objects.port = $objectsdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg objectsdbport "$objectsdbport" '.objects.port = $objectsdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_OBJECTSDB_PORT is set and value meets detected ioBroker installation. Nothing to do here." @@ -295,7 +380,7 @@ then then echo "ENV IOB_STATESDB_TYPE is set and value is different from detected ioBroker installation." echo "Setting type of states db to \""$statesdbtype"\"..." - jq --arg statesdbtype "$statesdbtype" '.states.type = $statesdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbtype "$statesdbtype" '.states.type = $statesdbtype' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_STATESDB_TYPE is set and value meets detected ioBroker installation. Nothing to do here." @@ -304,7 +389,7 @@ then then echo "ENV IOB_STATESDB_HOST is set and value is different from detected ioBroker installation." echo "Setting host of states db to \""$statesdbhost"\"..." - jq --arg statesdbhost "$statesdbhost" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbhost "$statesdbhost" '.states.host = $statesdbhost' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_STATESDB_HOST is set and value meets detected ioBroker installation. Nothing to do here." @@ -313,7 +398,7 @@ then then echo "ENV IOB_STATESDB_PORT is set and value is different from detected ioBroker installation." echo "Setting port of states db to \""$statesdbport"\"..." - jq --arg statesdbport "$statesdbport" '.states.port = $statesdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json + jq --arg statesdbport "$statesdbport" '.states.port = $statesdbport' /opt/iobroker/iobroker-data/iobroker.json > /opt/iobroker/iobroker-data/iobroker.json.tmp && mv /opt/iobroker/iobroker-data/iobroker.json.tmp /opt/iobroker/iobroker-data/iobroker.json echo "Done." else echo "ENV IOB_STATESDB_PORT is set and value meets detected ioBroker installation. Nothing to do here." @@ -326,9 +411,9 @@ fi if [ `find /opt/userscripts -type f | wc -l` -lt 1 ] then echo "There is no data detected in /opt/userscripts. Restoring exapmple userscripts..." - tar -xf /opt/initial_userscripts.tar -C / - chmod 755 /opt/userscripts/userscript_firststart_example.sh - chmod 755 /opt/userscripts/userscript_everystart_example.sh + tar -xf /opt/initial_userscripts.tar -C / + chmod 755 /opt/userscripts/userscript_firststart_example.sh + chmod 755 /opt/userscripts/userscript_everystart_example.sh echo "Done." echo ' ' elif [ -f /opt/userscripts/userscript_firststart.sh ] || [ -f /opt/userscripts/userscript_everystart.sh ] @@ -337,26 +422,23 @@ then then echo "Userscript for first start detected and this is the first start of a new container." echo "Running userscript_firststart.sh..." - chmod 755 /opt/userscripts/userscript_firststart.sh - bash /opt/userscripts/userscript_firststart.sh - rm -f /opt/.firstrun + chmod 755 /opt/userscripts/userscript_firststart.sh + bash /opt/userscripts/userscript_firststart.sh + rm -f /opt/.firstrun echo "Done." echo ' ' fi if [ -f /opt/userscripts/userscript_everystart.sh ] then echo "Userscript for every start detected. Running userscript_everystart.sh..." - chmod 755 /opt/userscripts/userscript_everystart.sh - bash /opt/userscripts/userscript_everystart.sh + chmod 755 /opt/userscripts/userscript_everystart.sh + bash /opt/userscripts/userscript_everystart.sh echo "Done." echo ' ' fi fi -sleep 5 - - ##### # Starting ioBroker ##### @@ -367,7 +449,21 @@ echo ' ' echo "Starting ioBroker..." echo ' ' -gosu iobroker node node_modules/iobroker.js-controller/controller.js +# Function for graceful shutdown by SIGTERM signal +shut_down() { + echo ' ' + echo "Recived termination signal (SIGTERM)." + echo "Shutting down ioBroker..." + pid=$(ps -ef | awk '/[j]s.controller/{print $2}') + kill -SIGTERM "$pid" + exit +} -# Preventing container restart by keeping a process alive even if iobroker will be stopped +# Trap to get signal for graceful shutdown +trap 'shut_down' SIGTERM + +# IoBroker start +gosu iobroker node node_modules/iobroker.js-controller/controller.js & wait + +# Fallback process for keeping container running when ioBroker is stopped for maintenance (e.g. js-controller update) tail -f /dev/null From 83c10ab83b76f1e6eb42a0a730e1caef807926be Mon Sep 17 00:00:00 2001 From: andre <> Date: Mon, 29 Jun 2020 21:15:27 +0200 Subject: [PATCH 26/27] Preparing V5 --- README.md | 15 ++++++++------- aarch64/Dockerfile | 3 --- amd64/Dockerfile | 3 --- armv7hf/Dockerfile | 3 --- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index e9143d6..43966ee 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you need more please let me know by opening a Github issue. ## Important notice -Normally a new major version (e.g. v2, v4 and upcoming v5) of the image comes with a new, preinstalled major node version! +Normally a new major version (e.g. v2, v4, v5) of the image comes with a new, preinstalled major node version! If you are updating an existing installation to a new major version (e.g. from v4 to v5) you have to perform some additional steps inside ioBroker! 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).
You might avoid these procedure if you use my "Best practice" hint for "upgrading your ioBroker container".
In any case make a backup first! @@ -162,13 +162,14 @@ Thank you! ## Changelog -### v4.2.4beta (2020-06-23) -* added graceful shutdown -* small fix for GID/UID handling -* adding new ENV "IOB_MULTIHOST" for multihost support -* small syntax fixes in iobroker_startup.sh +### v5.0.0 (2020-06-29) +* v4.2.4beta (2020-06-23) + * added graceful shutdown + * small fix for GID/UID handling + * adding new ENV "IOB_MULTIHOST" for multihost support + * small syntax fixes in iobroker_startup.sh * v4.2.3beta (2020-06-05) - * updating js-controller to not stable version 3.1.5 to fix renaming issue + * ~~updating js-controller to not stable version 3.1.5 to fix renaming issue~~ (is stable now) * v4.2.2beta (2020-06-03) * ~~workaround for renaming issues on startup~~ (fixed in js-controller) * v4.2.1beta (2020-05-10) diff --git a/aarch64/Dockerfile b/aarch64/Dockerfile index 85f6760..383975d 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -70,9 +70,6 @@ RUN apt-get update \ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp -# Temporary updating js-controller to not stable version -RUN npm install iobroker.js-controller@3.1.5 - # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ && tar -cf /opt/initial_userscripts.tar /opt/userscripts diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 597c0f0..8ded5d9 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -70,9 +70,6 @@ RUN apt-get update \ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp -# Temporary updating js-controller to not stable version -RUN npm install iobroker.js-controller@3.1.5 - # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ && tar -cf /opt/initial_userscripts.tar /opt/userscripts diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index 63f217f..bbf2285 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -70,9 +70,6 @@ RUN apt-get update \ WORKDIR /opt/iobroker/ RUN npm install -g node-gyp -# Temporary updating js-controller to not stable version -RUN npm install iobroker.js-controller@3.1.5 - # Backup initial ioBroker and userscript folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \ && tar -cf /opt/initial_userscripts.tar /opt/userscripts From c0bd56f7e5c3cdd3554386e45452400658f85290 Mon Sep 17 00:00:00 2001 From: Andre Germann Date: Mon, 29 Jun 2020 21:18:49 +0200 Subject: [PATCH 27/27] Update .VERSION --- .VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.VERSION b/.VERSION index 536a94d..d3845ad 100644 --- a/.VERSION +++ b/.VERSION @@ -1 +1 @@ -v4.2.4beta +v5.0.0