From 2afe9ca853cb083f81893c9d241478bde969be8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20Wildf=C3=B6rster?= Date: Wed, 19 Dec 2018 17:19:53 +0100 Subject: [PATCH] check for RESOLVERS env variable before computing dns to make the variable work as intended --- docker-entrypoint.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7e7a312..8e4b0a2 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -18,11 +18,16 @@ fi # Note: if $DHPARAM_BITS is not defined, generate-dhparam.sh will use 2048 as a default /app/generate-dhparam.sh $DHPARAM_BITS -# Compute the DNS resolvers for use in the templates - if the IP contains ":", it's IPv6 and must be enclosed in [] -export RESOLVERS=$(awk '$1 == "nameserver" {print ($2 ~ ":")? "["$2"]": $2}' ORS=' ' /etc/resolv.conf | sed 's/ *$//g') -if [ "x$RESOLVERS" = "x" ]; then - echo "Warning: unable to determine DNS resolvers for nginx" >&2 - unset RESOLVERS +# Check if the RESOLVERS environment variable has been set +if [ "x$RESOLVERS" != "x" ]; then + echo "RESOLVERS environment variable set to '$RESOLVERS', skipping dns compute from resolv.conf" >&2 +else + # Compute the DNS resolvers for use in the templates - if the IP contains ":", it's IPv6 and must be enclosed in [] + export RESOLVERS=$(awk '$1 == "nameserver" {print ($2 ~ ":")? "["$2"]": $2}' ORS=' ' /etc/resolv.conf | sed 's/ *$//g') + if [ "x$RESOLVERS" = "x" ]; then + echo "Warning: unable to determine DNS resolvers for nginx" >&2 + unset RESOLVERS + fi fi # If the user has run the default command and the socket doesn't exist, fail