From 7293e3c9e8fed5020495f0bbfc8805e3a7fe3683 Mon Sep 17 00:00:00 2001 From: Casper Date: Sat, 19 Jun 2021 22:24:06 +0200 Subject: [PATCH] Check if CONTAINER_IP could be determined (#2046) Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> --- target/scripts/helper-functions.sh | 6 ++++++ target/scripts/startup/check-stack.sh | 2 +- target/scripts/startup/setup-stack.sh | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/target/scripts/helper-functions.sh b/target/scripts/helper-functions.sh index ea2f9f96..d94091ff 100755 --- a/target/scripts/helper-functions.sh +++ b/target/scripts/helper-functions.sh @@ -208,3 +208,9 @@ function _monitored_files_checksums ) } export -f _monitored_files_checksums + +function _shutdown +{ + _notify 'err' "Shutting down.." + kill 1 +} diff --git a/target/scripts/startup/check-stack.sh b/target/scripts/startup/check-stack.sh index facf7e0e..0f3203e9 100644 --- a/target/scripts/startup/check-stack.sh +++ b/target/scripts/startup/check-stack.sh @@ -25,7 +25,7 @@ function _check_hostname if ! grep -q -E '^(\S+[.]\S+)$' <<< "${HOSTNAME}" then _notify 'err' 'Setting hostname/domainname is required' - kill "$(< /var/run/supervisord.pid)" + _shutdown return 1 fi } diff --git a/target/scripts/startup/setup-stack.sh b/target/scripts/startup/setup-stack.sh index e2399f41..1077dea5 100644 --- a/target/scripts/startup/setup-stack.sh +++ b/target/scripts/startup/setup-stack.sh @@ -1108,6 +1108,12 @@ function _setup_docker_permit grep 'inet ' | sed 's|[^0-9\.\/]*||g' | cut -d '/' -f 1) CONTAINER_NETWORK="$(echo "${CONTAINER_IP}" | cut -d '.' -f1-2).0.0" + if [[ -z ${CONTAINER_IP} ]] + then + _notify 'err' "Detecting the container IP address failed. Check if NETWORK_INTERFACE is correctly configured." + _shutdown + fi + while read -r IP do CONTAINER_NETWORKS+=("${IP}") @@ -1156,7 +1162,7 @@ function _setup_postfix_virtual_transport if [[ -z ${POSTFIX_DAGENT} ]] then _notify 'err' "${POSTFIX_DAGENT} not set." - kill -15 "$(< /var/run/supervisord.pid)" + _shutdown return 1 fi