skip hostname check when multihost is slave

This commit is contained in:
buanet
2022-11-08 22:25:01 +01:00
parent 5f40675501
commit 6223cdad53

View File

@@ -217,36 +217,38 @@ echo 'Done.'
echo ' ' echo ' '
# hostname check # hostname check
# get admin instance and hostname if [[ "$multihost" == "slave" ]]; then
set +e echo "IOB_MULTIHOST ist set to \"slave\". Hostname check will be skipped."
admininstance=$(bash iobroker list instances | grep -m 1 -o 'system.adapter.admin..') echo ' '
set -e else
if [[ "$admininstance" != "" ]]; then # get admin instance and hostname
set +e
admininstance=$(bash iobroker list instances | grep -m 1 -o 'system.adapter.admin..')
set -e
if [[ "$admininstance" != "" ]]; then
if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected admin instance is:" $admininstance; fi if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected admin instance is:" $admininstance; fi
adminhostname=$(bash iobroker object get $admininstance --pretty | grep -oP '(?<="host": ")[^"]*') adminhostname=$(bash iobroker object get $admininstance --pretty | grep -oP '(?<="host": ")[^"]*')
if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected admin hostname is:" $adminhostname; fi if [[ "$debug" == "true" ]]; then echo "[DEBUG] Detected admin hostname is:" $adminhostname; fi
else else
echo "There was a problem detecting the admin instance and/or hostname of your iobroker." echo "There was a problem detecting the admin instance and/or hostname of your iobroker."
echo "Make sure the ioBroker installation you use has an admin instance or start over with a fresh installation and restore your configuration." echo "Make sure the ioBroker installation you use has an admin instance or start over with a fresh installation and restore your configuration."
echo "For more details see https://docs.buanet.de/iobroker-docker-image/docs/#restore" echo "For more details see https://docs.buanet.de/iobroker-docker-image/docs/#restore"
exit 1 exit 1
fi fi
# check hostname # check hostname
if [[ "$adminhostname" != "" && "$adminhostname" != "$(hostname)" && "$multihost" != "slave" ]]; then if [[ "$adminhostname" != "" && "$adminhostname" != "$(hostname)" ]]; 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."
echo -n "Updating hostname to "$(hostname)"... " echo -n "Updating hostname to "$(hostname)"... "
bash iobroker host $adminhostname bash iobroker host $adminhostname
echo 'Done.' echo 'Done.'
echo ' ' echo ' '
elif [[ "$multihost" == "slave" ]]; then elif [[ "$adminhostname" = "$(hostname)" ]]; then
echo "IOB_MULTIHOST ist set to \"slave\". Hostname check will be skipped."
echo ' '
elif [[ "$adminhostname" = "$(hostname)" && "$multihost" != "slave" ]]; then
echo "Hostname in ioBroker matches the hostname of this container." echo "Hostname in ioBroker matches the hostname of this container."
echo "No action required." echo "No action required."
echo ' ' echo ' '
else else
echo "There was a problem checking the hostname." echo "There was a problem checking the hostname."
fi
fi fi
##### #####
@@ -262,7 +264,7 @@ 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" != "" ]]; then if [[ "$adminport" != "" && "$multihost" != "slave" ]]; then
adminportold=$(bash iobroker object get $admininstance --pretty | grep -oP '(?<="port": )[^,]*') adminportold=$(bash iobroker object get $admininstance --pretty | grep -oP '(?<="port": )[^,]*')
admininstanceshort=$(echo $admininstance | grep -m 1 -o 'admin..') admininstanceshort=$(echo $admininstance | grep -m 1 -o 'admin..')
if [[ "$adminport" != "$adminportold" ]]; then if [[ "$adminport" != "$adminportold" ]]; then