mirror of
https://github.com/buanet/ioBroker.docker.git
synced 2025-12-22 04:39:12 +02:00
14
README.md
14
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"|
|
|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_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_HOST|127.0.0.1|Sets hostname for ioBroker objects db|
|
||||||
|IOB_OBJECTSDB_PORT|9001|Sets port 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"|
|
|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:
|
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.
|
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
|
## Best practices
|
||||||
|
|
||||||
### Avoid using "latest" tag
|
### Avoid using "latest" tag
|
||||||
@@ -157,8 +162,13 @@ Thank you!
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### v4.2.3beta (2020-06-05)
|
### v4.2.4beta (2020-06-23)
|
||||||
* updating js-controller to not stable version 3.1.5 to fix renaming issue
|
* 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)
|
* v4.2.2beta (2020-06-03)
|
||||||
* ~~workaround for renaming issues on startup~~ (fixed in js-controller)
|
* ~~workaround for renaming issues on startup~~ (fixed in js-controller)
|
||||||
* v4.2.1beta (2020-05-10)
|
* v4.2.1beta (2020-05-10)
|
||||||
|
|||||||
@@ -79,14 +79,15 @@ RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \
|
|||||||
|
|
||||||
# Setting up iobroker-user (shell and home directory)
|
# Setting up iobroker-user (shell and home directory)
|
||||||
RUN chsh -s /bin/bash iobroker \
|
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
|
# Setting up ENVs
|
||||||
ENV DEBIAN_FRONTEND="teletype" \
|
ENV DEBIAN_FRONTEND="teletype" \
|
||||||
LANG="de_DE.UTF-8" \
|
LANG="de_DE.UTF-8" \
|
||||||
LANGUAGE="de_DE:de" \
|
LANGUAGE="de_DE:de" \
|
||||||
LC_ALL="de_DE.UTF-8" \
|
LC_ALL="de_DE.UTF-8" \
|
||||||
PACKAGES="vi" \
|
|
||||||
SETGID=1000 \
|
SETGID=1000 \
|
||||||
SETUID=1000 \
|
SETUID=1000 \
|
||||||
TZ="Europe/Berlin"
|
TZ="Europe/Berlin"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
# Reading ENV
|
# Reading ENV
|
||||||
adminport=$IOB_ADMINPORT
|
adminport=$IOB_ADMINPORT
|
||||||
avahi=$AVAHI
|
avahi=$AVAHI
|
||||||
|
multihost=$IOB_MULTIHOST
|
||||||
objectsdbhost=$IOB_OBJECTSDB_HOST
|
objectsdbhost=$IOB_OBJECTSDB_HOST
|
||||||
objectsdbport=$IOB_OBJECTSDB_PORT
|
objectsdbport=$IOB_OBJECTSDB_PORT
|
||||||
objectsdbtype=$IOB_OBJECTSDB_TYPE
|
objectsdbtype=$IOB_OBJECTSDB_TYPE
|
||||||
@@ -90,6 +91,7 @@ then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Nothing to do here."
|
echo "Nothing to do here."
|
||||||
|
echo ' '
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change directory for next steps
|
# Change directory for next steps
|
||||||
@@ -254,6 +256,89 @@ then
|
|||||||
fi
|
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
|
# Checking ENVs for custom setup of objects db
|
||||||
if [ "$objectsdbtype" != "" ] || [ "$objectsdbhost" != "" ] || [ "$objectsdbport" != "" ]
|
if [ "$objectsdbtype" != "" ] || [ "$objectsdbhost" != "" ] || [ "$objectsdbport" != "" ]
|
||||||
then
|
then
|
||||||
@@ -354,9 +439,6 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
|
|
||||||
#####
|
#####
|
||||||
# Starting ioBroker
|
# Starting ioBroker
|
||||||
#####
|
#####
|
||||||
@@ -367,7 +449,21 @@ echo ' '
|
|||||||
echo "Starting ioBroker..."
|
echo "Starting ioBroker..."
|
||||||
echo ' '
|
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
|
tail -f /dev/null
|
||||||
|
|||||||
@@ -79,14 +79,15 @@ RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \
|
|||||||
|
|
||||||
# Setting up iobroker-user (shell and home directory)
|
# Setting up iobroker-user (shell and home directory)
|
||||||
RUN chsh -s /bin/bash iobroker \
|
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
|
# Setting up ENVs
|
||||||
ENV DEBIAN_FRONTEND="teletype" \
|
ENV DEBIAN_FRONTEND="teletype" \
|
||||||
LANG="de_DE.UTF-8" \
|
LANG="de_DE.UTF-8" \
|
||||||
LANGUAGE="de_DE:de" \
|
LANGUAGE="de_DE:de" \
|
||||||
LC_ALL="de_DE.UTF-8" \
|
LC_ALL="de_DE.UTF-8" \
|
||||||
PACKAGES="vi" \
|
|
||||||
SETGID=1000 \
|
SETGID=1000 \
|
||||||
SETUID=1000 \
|
SETUID=1000 \
|
||||||
TZ="Europe/Berlin"
|
TZ="Europe/Berlin"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
# Reading ENV
|
# Reading ENV
|
||||||
adminport=$IOB_ADMINPORT
|
adminport=$IOB_ADMINPORT
|
||||||
avahi=$AVAHI
|
avahi=$AVAHI
|
||||||
|
multihost=$IOB_MULTIHOST
|
||||||
objectsdbhost=$IOB_OBJECTSDB_HOST
|
objectsdbhost=$IOB_OBJECTSDB_HOST
|
||||||
objectsdbport=$IOB_OBJECTSDB_PORT
|
objectsdbport=$IOB_OBJECTSDB_PORT
|
||||||
objectsdbtype=$IOB_OBJECTSDB_TYPE
|
objectsdbtype=$IOB_OBJECTSDB_TYPE
|
||||||
@@ -90,6 +91,7 @@ then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Nothing to do here."
|
echo "Nothing to do here."
|
||||||
|
echo ' '
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change directory for next steps
|
# Change directory for next steps
|
||||||
@@ -254,6 +256,89 @@ then
|
|||||||
fi
|
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
|
# Checking ENVs for custom setup of objects db
|
||||||
if [ "$objectsdbtype" != "" ] || [ "$objectsdbhost" != "" ] || [ "$objectsdbport" != "" ]
|
if [ "$objectsdbtype" != "" ] || [ "$objectsdbhost" != "" ] || [ "$objectsdbport" != "" ]
|
||||||
then
|
then
|
||||||
@@ -354,9 +439,6 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
|
|
||||||
#####
|
#####
|
||||||
# Starting ioBroker
|
# Starting ioBroker
|
||||||
#####
|
#####
|
||||||
@@ -367,7 +449,21 @@ echo ' '
|
|||||||
echo "Starting ioBroker..."
|
echo "Starting ioBroker..."
|
||||||
echo ' '
|
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
|
tail -f /dev/null
|
||||||
|
|||||||
@@ -79,14 +79,15 @@ RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \
|
|||||||
|
|
||||||
# Setting up iobroker-user (shell and home directory)
|
# Setting up iobroker-user (shell and home directory)
|
||||||
RUN chsh -s /bin/bash iobroker \
|
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
|
# Setting up ENVs
|
||||||
ENV DEBIAN_FRONTEND="teletype" \
|
ENV DEBIAN_FRONTEND="teletype" \
|
||||||
LANG="de_DE.UTF-8" \
|
LANG="de_DE.UTF-8" \
|
||||||
LANGUAGE="de_DE:de" \
|
LANGUAGE="de_DE:de" \
|
||||||
LC_ALL="de_DE.UTF-8" \
|
LC_ALL="de_DE.UTF-8" \
|
||||||
PACKAGES="vim" \
|
|
||||||
SETGID=1000 \
|
SETGID=1000 \
|
||||||
SETUID=1000 \
|
SETUID=1000 \
|
||||||
TZ="Europe/Berlin"
|
TZ="Europe/Berlin"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
# Reading ENV
|
# Reading ENV
|
||||||
adminport=$IOB_ADMINPORT
|
adminport=$IOB_ADMINPORT
|
||||||
avahi=$AVAHI
|
avahi=$AVAHI
|
||||||
|
multihost=$IOB_MULTIHOST
|
||||||
objectsdbhost=$IOB_OBJECTSDB_HOST
|
objectsdbhost=$IOB_OBJECTSDB_HOST
|
||||||
objectsdbport=$IOB_OBJECTSDB_PORT
|
objectsdbport=$IOB_OBJECTSDB_PORT
|
||||||
objectsdbtype=$IOB_OBJECTSDB_TYPE
|
objectsdbtype=$IOB_OBJECTSDB_TYPE
|
||||||
@@ -90,6 +91,7 @@ then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Nothing to do here."
|
echo "Nothing to do here."
|
||||||
|
echo ' '
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change directory for next steps
|
# Change directory for next steps
|
||||||
@@ -254,6 +256,89 @@ then
|
|||||||
fi
|
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
|
# Checking ENVs for custom setup of objects db
|
||||||
if [ "$objectsdbtype" != "" ] || [ "$objectsdbhost" != "" ] || [ "$objectsdbport" != "" ]
|
if [ "$objectsdbtype" != "" ] || [ "$objectsdbhost" != "" ] || [ "$objectsdbport" != "" ]
|
||||||
then
|
then
|
||||||
@@ -354,9 +439,6 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
|
|
||||||
#####
|
#####
|
||||||
# Starting ioBroker
|
# Starting ioBroker
|
||||||
#####
|
#####
|
||||||
@@ -367,7 +449,21 @@ echo ' '
|
|||||||
echo "Starting ioBroker..."
|
echo "Starting ioBroker..."
|
||||||
echo ' '
|
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
|
tail -f /dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user