mirror of
https://github.com/buanet/ioBroker.docker.git
synced 2025-12-21 20:29:09 +02:00
testing
This commit is contained in:
142
debian/scripts/iobroker_startup.sh
vendored
142
debian/scripts/iobroker_startup.sh
vendored
@@ -10,6 +10,7 @@ echo 'starting' > /opt/scripts/.docker_config/.healthcheck
|
|||||||
set +u
|
set +u
|
||||||
adminport=$IOB_ADMINPORT
|
adminport=$IOB_ADMINPORT
|
||||||
avahi=$AVAHI
|
avahi=$AVAHI
|
||||||
|
debug=$DEBUG
|
||||||
multihost=$IOB_MULTIHOST
|
multihost=$IOB_MULTIHOST
|
||||||
offlinemode=$OFFLINE_MODE
|
offlinemode=$OFFLINE_MODE
|
||||||
objectsdbhost=$IOB_OBJECTSDB_HOST
|
objectsdbhost=$IOB_OBJECTSDB_HOST
|
||||||
@@ -43,8 +44,6 @@ echo "----- Please be patient!
|
|||||||
echo "$(printf -- '-%.0s' {1..80})"
|
echo "$(printf -- '-%.0s' {1..80})"
|
||||||
echo ' '
|
echo ' '
|
||||||
echo "$(printf -- '-%.0s' {1..80})"
|
echo "$(printf -- '-%.0s' {1..80})"
|
||||||
echo "----- Debugging information -----"
|
|
||||||
echo "----- -----"
|
|
||||||
echo "----- System -----"
|
echo "----- System -----"
|
||||||
echo -n "----- " && echo -n "$(printf "%-20s %-28s" arch: $(uname -m))" && echo " -----"
|
echo -n "----- " && echo -n "$(printf "%-20s %-28s" arch: $(uname -m))" && echo " -----"
|
||||||
echo -n "----- " && echo -n "$(printf "%-20s %-28s" hostname: $(hostname))" && echo " -----"
|
echo -n "----- " && echo -n "$(printf "%-20s %-28s" hostname: $(hostname))" && echo " -----"
|
||||||
@@ -58,8 +57,9 @@ echo -n "----- " && echo -n "$(printf "%-20s %-28s" node: $(n
|
|||||||
echo -n "----- " && echo -n "$(printf "%-20s %-28s" npm: $(npm -v))" && echo " -----"
|
echo -n "----- " && echo -n "$(printf "%-20s %-28s" npm: $(npm -v))" && echo " -----"
|
||||||
echo "----- -----"
|
echo "----- -----"
|
||||||
echo "----- ENV -----"
|
echo "----- ENV -----"
|
||||||
if [[ "$avahi" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" AVAHI: $avahi)" && echo " -----"; fi
|
|
||||||
if [[ "$adminport" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_ADMINPORT: $adminport)" && echo " -----"; fi
|
if [[ "$adminport" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_ADMINPORT: $adminport)" && echo " -----"; fi
|
||||||
|
if [[ "$avahi" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" AVAHI: $avahi)" && echo " -----"; fi
|
||||||
|
if [[ "$debug" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" DEBUG: $debug)" && echo " -----"; fi
|
||||||
if [[ "$multihost" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_MULTIHOST: $multihost)" && echo " -----"; fi
|
if [[ "$multihost" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_MULTIHOST: $multihost)" && echo " -----"; fi
|
||||||
if [[ "$objectsdbhost" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_OBJECTSDB_HOST: $objectsdbhost)" && echo " -----"; fi
|
if [[ "$objectsdbhost" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_OBJECTSDB_HOST: $objectsdbhost)" && echo " -----"; fi
|
||||||
if [[ "$objectsdbport" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_OBJECTSDB_PORT: $objectsdbport)" && echo " -----"; fi
|
if [[ "$objectsdbport" != "" ]]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_OBJECTSDB_PORT: $objectsdbport)" && echo " -----"; fi
|
||||||
@@ -109,13 +109,13 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Installing packages from ENV
|
# Installing packages from ENV
|
||||||
if [[ "$packages" != "" ]] && [[ "$offlinemode" = "true" ]]; then
|
if [[ "$packages" != "" && "$offlinemode" = "true" ]]; then
|
||||||
echo 'Installing additional packages is set by ENV but offline mode is activated!'
|
echo 'Installing additional packages is set by ENV but offline mode is activated!'
|
||||||
echo 'Skipping Linux packages installation.'
|
echo 'Skipping Linux packages installation.'
|
||||||
echo ' '
|
echo ' '
|
||||||
else
|
else
|
||||||
echo 'Installing additional packages is set by ENV.'
|
echo 'Installing additional packages is set by ENV.'
|
||||||
echo "Checking the following Packages:" $packages"..."
|
echo "Checking the following packages:" $packages"..."
|
||||||
echo $packages > /opt/scripts/.docker_config/.packages
|
echo $packages > /opt/scripts/.docker_config/.packages
|
||||||
bash /opt/scripts/setup_packages.sh -install
|
bash /opt/scripts/setup_packages.sh -install
|
||||||
echo 'Done.'
|
echo 'Done.'
|
||||||
@@ -123,7 +123,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Setting UID and/ or GID
|
# Setting UID and/ or GID
|
||||||
if [[ $(cat /etc/group | grep 'iobroker:' | cut -d':' -f3) != $setgid ]] || [[ $(cat /etc/passwd | grep 'iobroker:' | cut -d':' -f3) != $setuid ]]; then
|
if [[ "$setgid" != "$(cat /etc/group | grep 'iobroker:' | cut -d':' -f3)" || "$setuid" != "$(cat /etc/passwd | grep 'iobroker:' | cut -d':' -f3)" ]]; then
|
||||||
echo "Different UID and/ or GID is set by ENV."
|
echo "Different UID and/ or GID is set by ENV."
|
||||||
echo -n "Changing UID to "$setuid" and GID to "$setgid"... "
|
echo -n "Changing UID to "$setuid" and GID to "$setgid"... "
|
||||||
usermod -u $setuid iobroker
|
usermod -u $setuid iobroker
|
||||||
@@ -143,25 +143,24 @@ echo "----- Step 2 of 5: Detecting ioBroker installation
|
|||||||
echo "$(printf -- '-%.0s' {1..80})"
|
echo "$(printf -- '-%.0s' {1..80})"
|
||||||
echo ' '
|
echo ' '
|
||||||
|
|
||||||
if [[ `find /opt/iobroker -type f | wc -l` -lt 1 ]]
|
if [[ `find /opt/iobroker -type f | wc -l` -lt 1 ]]; then
|
||||||
then
|
|
||||||
echo "There is no data detected in /opt/iobroker."
|
echo "There is no data detected in /opt/iobroker."
|
||||||
echo -n "Restoring initial ioBroker installation... "
|
echo -n "Restoring initial ioBroker installation... "
|
||||||
tar -xf /opt/initial_iobroker.tar -C /
|
tar -xf /opt/initial_iobroker.tar -C /
|
||||||
echo 'Done.'
|
echo 'Done.'
|
||||||
elif [[ -f /opt/iobroker/iobroker ]]
|
elif [[ -f /opt/iobroker/iobroker ]]; then
|
||||||
then
|
|
||||||
echo "Existing installation of ioBroker detected in /opt/iobroker."
|
echo "Existing installation of ioBroker detected in /opt/iobroker."
|
||||||
elif [[ $(ls *_backupiobroker.tar.gz 2> /dev/null | wc -l) != "0" ]] && [[ $(tar -ztvf /opt/iobroker/*_backupiobroker.tar.gz "backup/backup.json" 2> /dev/null | wc -l) != "0" ]]
|
elif [[ $(ls *_backupiobroker.tar.gz 2> /dev/null | wc -l) != "0" && $(tar -ztvf /opt/iobroker/*_backupiobroker.tar.gz "backup/backup.json" 2> /dev/null | wc -l) != "0" ]]; then
|
||||||
then
|
if [[ "$multihost" = "slave" ]]; then
|
||||||
if [[ "$multihost" = "slave" ]]
|
|
||||||
then
|
|
||||||
echo "IoBroker backup file detected in /opt/iobroker. But Multihost is set to \"slave\"."
|
echo "IoBroker backup file detected in /opt/iobroker. But Multihost is set to \"slave\"."
|
||||||
echo "Restoring a backup is not supported on Multihost slaves. Please check configuration and start over."
|
echo "Restoring a backup is not supported on Multihost slaves. Please check configuration and start over."
|
||||||
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "IoBroker backup file detected in /opt/iobroker."
|
echo "IoBroker backup file detected in /opt/iobroker."
|
||||||
|
if [[ "$debug" == "true" ]]; then
|
||||||
|
echo "[DEBUG] Backup file name: " $(ls *_backupiobroker.tar.gz)
|
||||||
|
fi
|
||||||
echo -n "Preparing restore... "
|
echo -n "Preparing restore... "
|
||||||
mv /opt/iobroker/*.tar.gz /opt/
|
mv /opt/iobroker/*.tar.gz /opt/
|
||||||
tar -xf /opt/initial_iobroker.tar -C /
|
tar -xf /opt/initial_iobroker.tar -C /
|
||||||
@@ -186,6 +185,10 @@ then
|
|||||||
else
|
else
|
||||||
echo "There is data detected in /opt/iobroker but it looks like it is no instance of ioBroker or a valid backup file!"
|
echo "There is data detected in /opt/iobroker but it looks like it is no instance of ioBroker or a valid backup file!"
|
||||||
echo "Please check/ recreate mounted folder or volume and start over."
|
echo "Please check/ recreate mounted folder or volume and start over."
|
||||||
|
if [[ "$debug" == "true" ]]; then
|
||||||
|
echo "[DEBUG] Detected files:"
|
||||||
|
ls -al
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo ' '
|
echo ' '
|
||||||
@@ -214,13 +217,25 @@ echo 'Done.'
|
|||||||
echo ' '
|
echo ' '
|
||||||
|
|
||||||
# checking hostname in ioBroker to match container hostname
|
# checking hostname in ioBroker to match container hostname
|
||||||
if [[ "$(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*')" != "$(hostname)" ]] && [[ "$multihost" != "slave" ]]
|
if [[ "$(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*')" != "$(hostname)" && "$multihost" != "slave" ]]; then
|
||||||
then
|
|
||||||
echo "Hostname in ioBroker does not match the hostname of this container."
|
echo "Hostname in ioBroker does not match the hostname of this container."
|
||||||
|
if [[ "$debug" == "true" ]]; then
|
||||||
|
echo "[DEBUG] Detected hostname in ioBroker: " $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*')
|
||||||
|
fi
|
||||||
echo -n "Updating hostname to " $(hostname)"... "
|
echo -n "Updating hostname to " $(hostname)"... "
|
||||||
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 'Done.'
|
||||||
echo ' '
|
echo ' '
|
||||||
|
elif [[ "$multihost" == "slave" ]]; then
|
||||||
|
echo "IOB_MULTIHOST ist set to \"slave\". Hostname check will be skipped."
|
||||||
|
echo ' '
|
||||||
|
else
|
||||||
|
if [[ "$debug" == "true" ]]; then
|
||||||
|
echo "[DEBUG] Hostnames match successful!"
|
||||||
|
echo "[DEBUG] Detected hostname in ioBroker: " $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*')
|
||||||
|
echo "[DEBUG] Detected hostname in container: " $(hostname)
|
||||||
|
echo ' '
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####
|
#####
|
||||||
@@ -236,11 +251,12 @@ echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.d
|
|||||||
echo ' '
|
echo ' '
|
||||||
|
|
||||||
# Checking ENV for Adminport
|
# Checking ENV for Adminport
|
||||||
if [[ "$adminport" != "" ]]
|
if [[ "$adminport" != "" ]]; then
|
||||||
then
|
if [[ "$adminport" != "$(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="port": )[^,]*')" ]]; then
|
||||||
if [[ "$adminport" != $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="port": )[^,]*') ]]
|
|
||||||
then
|
|
||||||
echo "Adminport set by ENV does not match port configured in ioBroker installation."
|
echo "Adminport set by ENV does not match port configured in ioBroker installation."
|
||||||
|
if [[ "$debug" == "true" ]]; then
|
||||||
|
echo "[DEBUG] Detected Admin Port in ioBroker: " $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="port": )[^,]*')
|
||||||
|
fi
|
||||||
echo -n "Setting Adminport to \""$adminport"\"... "
|
echo -n "Setting Adminport to \""$adminport"\"... "
|
||||||
bash iobroker set admin.0 --port $adminport
|
bash iobroker set admin.0 --port $adminport
|
||||||
echo 'Done.'
|
echo 'Done.'
|
||||||
@@ -249,7 +265,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking ENV for AVAHI
|
# Checking ENV for AVAHI
|
||||||
if [[ "$avahi" = "true" ]] && [[ "$offlinemode" = "true" ]]; then
|
if [[ "$avahi" = "true" && "$offlinemode" = "true" ]]; then
|
||||||
echo 'Avahi-daemon is activated by ENV but offline mode is activated!'
|
echo 'Avahi-daemon is activated by ENV but offline mode is activated!'
|
||||||
echo 'Skipping Avahi daemon setup.'
|
echo 'Skipping Avahi daemon setup.'
|
||||||
elif [[ "$avahi" = "true" ]]; then
|
elif [[ "$avahi" = "true" ]]; then
|
||||||
@@ -262,7 +278,7 @@ elif [[ "$avahi" = "true" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking ENV for Z-WAVE
|
# Checking ENV for Z-WAVE
|
||||||
if [[ "$zwave" = "true" ]] && [[ "$offlinemode" = "true" ]]; then
|
if [[ "$zwave" = "true" && "$offlinemode" = "true" ]]; then
|
||||||
echo 'Z-Wave is activated by ENV but offline mode is activated!'
|
echo 'Z-Wave is activated by ENV but offline mode is activated!'
|
||||||
echo 'Skipping Z-Wave setup.'
|
echo 'Skipping Z-Wave setup.'
|
||||||
elif [[ "$zwave" = "true" ]]; then
|
elif [[ "$zwave" = "true" ]]; then
|
||||||
@@ -275,7 +291,7 @@ elif [[ "$zwave" = "true" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# checking ENV for USBDEVICES
|
# checking ENV for USBDEVICES
|
||||||
if [[ "$usbdevices" != "" ]] && [[ "$usbdevices" != "none" ]]; then
|
if [[ "$usbdevices" != "" && "$usbdevices" != "none" ]]; then
|
||||||
echo "Usb-device-support is activated by ENV."
|
echo "Usb-device-support is activated by ENV."
|
||||||
IFS=';' read -ra devicearray <<< "$usbdevices"
|
IFS=';' read -ra devicearray <<< "$usbdevices"
|
||||||
for i in "${devicearray[@]}"
|
for i in "${devicearray[@]}"
|
||||||
@@ -289,38 +305,31 @@ if [[ "$usbdevices" != "" ]] && [[ "$usbdevices" != "none" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking ENV for multihost setup
|
# Checking ENV for multihost setup
|
||||||
if [[ "$multihost" != "" ]]
|
if [[ "$multihost" != "" ]]; then
|
||||||
then
|
|
||||||
echo "Checking multihost setup..."
|
echo "Checking multihost setup..."
|
||||||
# Configuring objects db host
|
# Configuring objects db host
|
||||||
if [[ "$multihost" = "master" ]] && [[ "$objectsdbtype" = "" ]] && [[ "$objectsdbhost" = "" ]] && [[ "$objectsdbport" = "" ]]
|
if [[ "$multihost" = "master" && "$objectsdbtype" = "" && "$objectsdbhost" = "" && "$objectsdbport" = "" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"master\" by ENV and no external objects db is set."
|
echo "Multihost is set as \"master\" by ENV and no external objects db is set."
|
||||||
echo -n "Setting host of objects db to \"0.0.0.0\" to allow external communication... "
|
echo -n "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
|
||||||
chown -R $setuid:$setgid /opt/iobroker/iobroker-data/iobroker.json && chmod 674 /opt/iobroker/iobroker-data/iobroker.json
|
chown -R $setuid:$setgid /opt/iobroker/iobroker-data/iobroker.json && chmod 674 /opt/iobroker/iobroker-data/iobroker.json
|
||||||
echo 'Done.'
|
echo 'Done.'
|
||||||
elif [[ "$multihost" = "master" ]] && [[ "$objectsdbhost" = "127.0.0.1" ]]
|
elif [[ "$multihost" = "master" && "$objectsdbhost" = "127.0.0.1" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"master\" by ENV. But objects db host is set to \"127.0.0.1\" by ENV too."
|
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 allow slaves to connect the objects db! Please change or remove ENV \"IOB_OBJECTSDB_HOST\" and start over!"
|
echo "This configuration will not allow slaves to connect the objects db! Please change or remove ENV \"IOB_OBJECTSDB_HOST\" and start over!"
|
||||||
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ "$multihost" = "master" ]] && [[ "$objectsdbtype" != "" ]] && [[ "$objectsdbhost" != "" ]] && [[ "$objectsdbport" != "" ]]
|
elif [[ "$multihost" = "master" && "$objectsdbtype" != "" && "$objectsdbhost" != "" && "$objectsdbport" != "" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"master\" by ENV and external objects db is set."
|
echo "Multihost is set as \"master\" by ENV and external objects db is set."
|
||||||
elif ([[ "$multihost" = "slave" ]] && [[ "$objectsdbtype" = "" ]]) || ([[ "$multihost" = "slave" ]] && [[ "$objectsdbhost" = "" ]]) || ([[ "$multihost" = "slave" ]] && [[ "$objectsdbport" = "" ]])
|
elif ([[ "$multihost" = "slave" && "$objectsdbtype" = "" ]]) || ([[ "$multihost" = "slave" && "$objectsdbhost" = "" ]]) || ([[ "$multihost" = "slave" && "$objectsdbport" = "" ]]); then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"slave\" by ENV. But no external objects db is set."
|
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 "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 "Please check your settings and start over."
|
||||||
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ "$multihost" = "slave" ]] && [[ "$objectsdbtype" != "" ]] && [[ "$objectsdbhost" != "" ]] && [[ "$objectsdbport" != "" ]]
|
elif [[ "$multihost" = "slave" && "$objectsdbtype" != "" && "$objectsdbhost" != "" && "$objectsdbport" != "" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"slave\" by ENV and external objects db is set."
|
echo "Multihost is set as \"slave\" by ENV and external objects db is set."
|
||||||
elif [[ "$multihost" != "" ]]
|
elif [[ "$multihost" != "" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set but it seems like some configuration is missing."
|
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 "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 ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
||||||
@@ -328,34 +337,28 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Configuring states db host
|
# Configuring states db host
|
||||||
if [[ "$multihost" = "master" ]] && [[ "$statesdbtype" = "" ]] && [[ "$statesdbhost" = "" ]] && [[ "$statesdbport" = "" ]]
|
if [[ "$multihost" = "master" && "$statesdbtype" = "" && "$statesdbhost" = "" && "$statesdbport" = "" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"master\" by ENV and no external states db is set."
|
echo "Multihost is set as \"master\" by ENV and no external states db is set."
|
||||||
echo -n "Setting host of states db to \"0.0.0.0\" to allow external communication... "
|
echo -n "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
|
||||||
chown -R $setuid:$setgid /opt/iobroker/iobroker-data/iobroker.json && chmod 674 /opt/iobroker/iobroker-data/iobroker.json
|
chown -R $setuid:$setgid /opt/iobroker/iobroker-data/iobroker.json && chmod 674 /opt/iobroker/iobroker-data/iobroker.json
|
||||||
echo 'Done.'
|
echo 'Done.'
|
||||||
elif [[ "$multihost" = "master" ]] && [[ "$statesdbhost" = "127.0.0.1" ]]
|
elif [[ "$multihost" = "master" && "$statesdbhost" = "127.0.0.1" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"master\" by ENV. But states db host is set to \"127.0.0.1\" by ENV too."
|
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 "This configuration will not work! Please change or remove ENV \"IOB_STATESDB_HOST\" and start over!"
|
||||||
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ "$multihost" = "master" ]] && [[ "$statesdbtype" != "" ]] && [[ "$statesdbhost" != "" ]] && [[ "$statesdbport" != "" ]]
|
elif [[ "$multihost" = "master" && "$statesdbtype" != "" && "$statesdbhost" != "" && "$statesdbport" != "" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"master\" by ENV and external states db is set."
|
echo "Multihost is set as \"master\" by ENV and external states db is set."
|
||||||
elif ([[ "$multihost" = "slave" ]] && [[ "$statesdbtype" = "" ]]) || ([[ "$multihost" = "slave" ]] && [[ "$statesdbhost" = "" ]]) || ([[ "$multihost" = "slave" ]] && [[ "$statesdbport" = "" ]])
|
elif ([[ "$multihost" = "slave" && "$statesdbtype" = "" ]]) || ([[ "$multihost" = "slave" && "$statesdbhost" = "" ]]) || ([[ "$multihost" = "slave" && "$statesdbport" = "" ]]); then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"slave\" by ENV. But no external states db is set."
|
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 "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 "Please check your settings and start over."
|
||||||
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
echo "For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ "$multihost" = "slave" ]] && [[ "$statesdbtype" != "" ]] && [[ "$statesdbhost" != "" ]] && [[ "$statesdbport" != "" ]]
|
elif [[ "$multihost" = "slave" && "$statesdbtype" != "" && "$statesdbhost" != "" && "$statesdbport" != "" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set as \"slave\" by ENV and external states db is set."
|
echo "Multihost is set as \"slave\" by ENV and external states db is set."
|
||||||
elif [[ "$multihost" != "" ]]
|
elif [[ "$multihost" != "" ]]; then
|
||||||
then
|
|
||||||
echo "Multihost is set but it seems like some configuration is missing."
|
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 "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 ioBroker Docker image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
echo "For more information see ioBroker Docker image Docs (https://docs.buanet.de/iobroker-docker-image/docs/)."
|
||||||
@@ -366,11 +369,9 @@ then
|
|||||||
fi
|
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
|
|
||||||
echo "Checking custom settings for objects db..."
|
echo "Checking custom settings for objects db..."
|
||||||
if [[ "$objectsdbtype" != $(jq -r '.objects.type' /opt/iobroker/iobroker-data/iobroker.json) ]]
|
if [[ "$objectsdbtype" != "$(jq -r '.objects.type' /opt/iobroker/iobroker-data/iobroker.json)" ]]; then
|
||||||
then
|
|
||||||
echo "IOB_OBJECTSDB_TYPE is set and value is different from detected ioBroker installation."
|
echo "IOB_OBJECTSDB_TYPE is set and value is different from detected ioBroker installation."
|
||||||
echo -n "Setting type of objects db to \""$objectsdbtype"\"... "
|
echo -n "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
|
||||||
@@ -379,8 +380,7 @@ then
|
|||||||
else
|
else
|
||||||
echo "IOB_OBJECTSDB_TYPE is set and value meets detected ioBroker installation."
|
echo "IOB_OBJECTSDB_TYPE is set and value meets detected ioBroker installation."
|
||||||
fi
|
fi
|
||||||
if [[ "$objectsdbhost" != $(jq -r '.objects.host' /opt/iobroker/iobroker-data/iobroker.json) ]]
|
if [[ "$objectsdbhost" != "$(jq -r '.objects.host' /opt/iobroker/iobroker-data/iobroker.json)" ]]; then
|
||||||
then
|
|
||||||
echo "IOB_OBJECTSDB_HOST is set and value is different from detected ioBroker installation."
|
echo "IOB_OBJECTSDB_HOST is set and value is different from detected ioBroker installation."
|
||||||
echo -n "Setting host of objects db to \""$objectsdbhost"\"... "
|
echo -n "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
|
||||||
@@ -389,8 +389,7 @@ then
|
|||||||
else
|
else
|
||||||
echo "IOB_OBJECTSDB_HOST is set and value meets detected ioBroker installation."
|
echo "IOB_OBJECTSDB_HOST is set and value meets detected ioBroker installation."
|
||||||
fi
|
fi
|
||||||
if [[ "$objectsdbport" != $(jq -r '.objects.port' /opt/iobroker/iobroker-data/iobroker.json) ]]
|
if [[ "$objectsdbport" != "$(jq -r '.objects.port' /opt/iobroker/iobroker-data/iobroker.json)" ]]; then
|
||||||
then
|
|
||||||
echo "IOB_OBJECTSDB_PORT is set and value is different from detected ioBroker installation."
|
echo "IOB_OBJECTSDB_PORT is set and value is different from detected ioBroker installation."
|
||||||
echo -n "Setting port of objects db to \""$objectsdbport"\"... "
|
echo -n "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
|
||||||
@@ -404,11 +403,9 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking ENVs for custom setup of states db
|
# Checking ENVs for custom setup of states db
|
||||||
if [[ "$statesdbtype" != "" ]] || [[ "$statesdbhost" != "" ]] || [[ "$statesdbport" != "" ]]
|
if [[ "$statesdbtype" != "" || "$statesdbhost" != "" || "$statesdbport" != "" ]]; then
|
||||||
then
|
|
||||||
echo "Checking custom settings for states db..."
|
echo "Checking custom settings for states db..."
|
||||||
if [[ "$statesdbtype" != $(jq -r '.states.type' /opt/iobroker/iobroker-data/iobroker.json) ]]
|
if [[ "$statesdbtype" != "$(jq -r '.states.type' /opt/iobroker/iobroker-data/iobroker.json)" ]]; then
|
||||||
then
|
|
||||||
echo "IOB_STATESDB_TYPE is set and value is different from detected ioBroker installation."
|
echo "IOB_STATESDB_TYPE is set and value is different from detected ioBroker installation."
|
||||||
echo -n "Setting type of states db to \""$statesdbtype"\"... "
|
echo -n "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
|
||||||
@@ -417,8 +414,7 @@ then
|
|||||||
else
|
else
|
||||||
echo "IOB_STATESDB_TYPE is set and value meets detected ioBroker installation."
|
echo "IOB_STATESDB_TYPE is set and value meets detected ioBroker installation."
|
||||||
fi
|
fi
|
||||||
if [[ "$statesdbhost" != $(jq -r '.states.host' /opt/iobroker/iobroker-data/iobroker.json) ]]
|
if [[ "$statesdbhost" != "$(jq -r '.states.host' /opt/iobroker/iobroker-data/iobroker.json)" ]]; then
|
||||||
then
|
|
||||||
echo "IOB_STATESDB_HOST is set and value is different from detected ioBroker installation."
|
echo "IOB_STATESDB_HOST is set and value is different from detected ioBroker installation."
|
||||||
echo -n "Setting host of states db to \""$statesdbhost"\"... "
|
echo -n "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
|
||||||
@@ -427,8 +423,7 @@ then
|
|||||||
else
|
else
|
||||||
echo "IOB_STATESDB_HOST is set and value meets detected ioBroker installation."
|
echo "IOB_STATESDB_HOST is set and value meets detected ioBroker installation."
|
||||||
fi
|
fi
|
||||||
if [[ "$statesdbport" != $(jq -r '.states.port' /opt/iobroker/iobroker-data/iobroker.json) ]]
|
if [[ "$statesdbport" != "$(jq -r '.states.port' /opt/iobroker/iobroker-data/iobroker.json)" ]]; then
|
||||||
then
|
|
||||||
echo "IOB_STATESDB_PORT is set and value is different from detected ioBroker installation."
|
echo "IOB_STATESDB_PORT is set and value is different from detected ioBroker installation."
|
||||||
echo -n "Setting port of states db to \""$statesdbport"\"... "
|
echo -n "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
|
||||||
@@ -442,18 +437,15 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking for Userscripts in /opt/userscripts
|
# Checking for Userscripts in /opt/userscripts
|
||||||
if [[ `find /opt/userscripts -type f | wc -l` -lt 1 ]]
|
if [[ `find /opt/userscripts -type f | wc -l` -lt 1 ]]; then
|
||||||
then
|
|
||||||
echo -n "There is no data detected in /opt/userscripts. Restoring exapmple userscripts... "
|
echo -n "There is no data detected in /opt/userscripts. Restoring exapmple userscripts... "
|
||||||
tar -xf /opt/initial_userscripts.tar -C /
|
tar -xf /opt/initial_userscripts.tar -C /
|
||||||
chmod 755 /opt/userscripts/userscript_firststart_example.sh
|
chmod 755 /opt/userscripts/userscript_firststart_example.sh
|
||||||
chmod 755 /opt/userscripts/userscript_everystart_example.sh
|
chmod 755 /opt/userscripts/userscript_everystart_example.sh
|
||||||
echo 'Done.'
|
echo 'Done.'
|
||||||
echo ' '
|
echo ' '
|
||||||
elif [[ -f /opt/userscripts/userscript_firststart.sh ]] || [[ -f /opt/userscripts/userscript_everystart.sh ]]
|
elif [[ -f /opt/userscripts/userscript_firststart.sh || -f /opt/userscripts/userscript_everystart.sh ]]; then
|
||||||
then
|
if [[ -f /opt/userscripts/userscript_firststart.sh && -f /opt/.firstrun ]]; then
|
||||||
if [[ -f /opt/userscripts/userscript_firststart.sh ]] && [[ -f /opt/.firstrun ]]
|
|
||||||
then
|
|
||||||
echo "Userscript for first start detected and this is the first start of a new container."
|
echo "Userscript for first start detected and this is the first start of a new container."
|
||||||
echo "Running userscript_firststart.sh..."
|
echo "Running userscript_firststart.sh..."
|
||||||
chmod 755 /opt/userscripts/userscript_firststart.sh
|
chmod 755 /opt/userscripts/userscript_firststart.sh
|
||||||
@@ -461,8 +453,7 @@ then
|
|||||||
echo "Done."
|
echo "Done."
|
||||||
echo ' '
|
echo ' '
|
||||||
fi
|
fi
|
||||||
if [[ -f /opt/userscripts/userscript_everystart.sh ]]
|
if [[ -f /opt/userscripts/userscript_everystart.sh ]]; then
|
||||||
then
|
|
||||||
echo "Userscript for every start detected. Running userscript_everystart.sh..."
|
echo "Userscript for every start detected. Running userscript_everystart.sh..."
|
||||||
chmod 755 /opt/userscripts/userscript_everystart.sh
|
chmod 755 /opt/userscripts/userscript_everystart.sh
|
||||||
bash /opt/userscripts/userscript_everystart.sh
|
bash /opt/userscripts/userscript_everystart.sh
|
||||||
@@ -472,9 +463,8 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Removing first run marker when exists
|
# Removing first run marker when exists
|
||||||
if [[ -f /opt/.firstrun ]]
|
if [[ -f /opt/.firstrun ]]; then
|
||||||
then
|
rm -f /opt/.firstrun
|
||||||
rm -f /opt/.firstrun
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####
|
#####
|
||||||
|
|||||||
Reference in New Issue
Block a user