This commit is contained in:
buanet
2020-02-04 20:08:54 +01:00
parent 3df642f9f8
commit 71a1c78446
5 changed files with 57 additions and 21 deletions

View File

@@ -61,10 +61,11 @@ 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.
|env|default|description|
|---|---|---|
|ADMINPORT|8081|Sets ioBroker adminport on startup|
|IOB_ADMINPORT|8081|Sets ioBroker adminport on startup|
|AVAHI|false|Installs and activates avahi-daemon for supporting yahka-adapter, can be "true" or "false"|
|LANG|de_DE.UTF‑8|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8|
|LANGUAGE|de_DE:de|The following locales are pre-generated: de_DE:de, en_US:en|
@@ -77,7 +78,7 @@ To configure the ioBroker container on startup it is possible to set some enviro
|USBDEVICES|none|Sets relevant permissions on mounted devices like "/dev/ttyACM0", for more than one device separate with ";" like "/dev/ttyACM0;/dev/ttyACM1"|
|ZWAVE|false|Will install openzwave to support zwave-adapter, can be "true" or "false"|
### Mounting Folder/ Volume
### 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".
@@ -88,10 +89,20 @@ Note: It is absolutely recommended to use a mounted folder or persistent volume
You can also mount a folder containing an existing ioBroker-installation (e.g. when moving an existing installation to docker).
But watch for the used node version. If the existing installation runs with another major version of node you have do perform additional steps. For more Details see the "Important notice" on top.
### Permission Fixer
### Permission fixer
After some issues with permissions related to the use of a dedicated user for ioBroker, I added some code for fixing permissions on container startup. This might take a few minutes on first startup. Please take a look at the container logs and be patient!
### Userdefined startup scripts (advanced setting/ beta status)
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.
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).
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.
## Miscellaneous
### Keep me updated
@@ -102,6 +113,7 @@ You will find the channel here: https://t.me/buanet_tutorials
## Changelog
### v4.1.2beta (2020-02-02)
* added feature userscripts on startup
* small fix for permissions issues on some systems
* v4.1.1beta (2020-01-17)
* updated openzwave to version 1.6.1007
@@ -112,7 +124,7 @@ You will find the channel here: https://t.me/buanet_tutorials
* added support to restore backup on startup
* small fixes according to "docker best practices"
* v4.0.2beta (2019-12-10)
* added env for activating redis
* ~~added env for activating redis~~
* enhancements in startupscript and dockerfile
* v4.0.1beta (2019-11-25)
* added env for iobroker admin port

View File

@@ -78,14 +78,19 @@ RUN chsh -s /bin/bash iobroker \
&& usermod --home /opt/iobroker iobroker
# Setting up ENVs
ENV ADMINPORT=8081 \
AVAHI="false" \
ENV AVAHI="false" \
DEBIAN_FRONTEND="teletype" \
IOB_ADMINPORT=8081 \
IOB_OBJECTSDB_HOST="127.0.0.1" \
IOB_OBJECTSDB_PORT="9001" \
IOB_OBJECTSDB_TYPE="file" \
IOB_STATESDB_HOST="127.0.0.1" \
IOB_STATESDB_PORT="9000" \
IOB_STATESDB_TYPE="file" \
LANG="de_DE.UTF-8" \
LANGUAGE="de_DE:de" \
LC_ALL="de_DE.UTF-8" \
PACKAGES="vi" \
REDIS="false" \
SETGID=1000 \
SETUID=1000 \
TZ="Europe/Berlin" \

View File

@@ -1,11 +1,16 @@
#!/bin/bash
# Reading ENV
adminport=$ADMINPORT
adminport=$IOB_ADMINPORT
avahi=$AVAHI
gid=$SETGID
objectsdbhost=$IOB_OBJECTSDB_HOST
objectsdbport=$IOB_OBJECTSDB_PORT
objectsdbtype=$IOB_OBJECTSDB_TYPE
packages=$PACKAGES
redis=$REDIS
statesdbhost=$IOB_STATESDB_HOST
statesdbport=$IOB_STATESDB_PORT
statesdbtype=$IOB_STATESDB_TYPE
uid=$SETUID
usbdevices=$USBDEVICES
zwave=$ZWAVE
@@ -229,7 +234,7 @@ then
echo ' '
fi
# Checking ENV for REDIS
# Checking ENVs for custom setup of objects db
if [ "$redis" != "false" ]
then
echo "Connection to Redis is configured by ENV."
@@ -245,13 +250,18 @@ then
echo ' '
fi
# Checking ENVs for custom setup of states db#
# Checking for Userscripts in /opt/userscripts
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 userscript_firststart_example.sh
chmod 755 userscript_everystart_example.sh
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 ]
@@ -260,7 +270,7 @@ 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 userscript_firststart.sh
chmod 755 /opt/userscripts/userscript_firststart.sh
bash /opt/userscripts/userscript_firststart.sh
rm -f /opt/.firstrun
echo "Done."
@@ -269,7 +279,7 @@ then
if [ -f /opt/userscripts/userscript_everystart.sh ]
then
echo "Userscript for every start detected. Running userscript_everystart.sh..."
chmod 755 userscript_everystart.sh
chmod 755 /opt/userscripts/userscript_everystart.sh
bash /opt/userscripts/userscript_everystart.sh
echo "Done."
echo ' '

View File

@@ -5,4 +5,9 @@
# You can add your advanced script code here!
echo ' '
echo "I'm your startscript userscript_everystart.sh. I will run on EVERY container startup."
echo ' '
exit 0

View File

@@ -5,4 +5,8 @@
# You can add your advanced script code here!
echo ' '
echo "I'm your startscript userscript_firststart.sh. I will run only on the FIRST startup of the container."
echo ' '
exit 0