From a3f8fbaee1c037bc28413ebe145b33e23480c665 Mon Sep 17 00:00:00 2001 From: alexandredevely <12896316+alexandredevely@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:37:27 +0200 Subject: [PATCH] add FQDN var env --- docker-entrypoint.sh | 46 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 4807e6a..7a23595 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,17 +1,53 @@ #!/bin/bash -NAMESERVER_RESOLVER=$(grep ^nameserver /etc/resolv.conf | head -n 1 |awk '{ print $2}') +if [ -z "$NAMESERVER_RESOLVER" ]; then + NAMESERVER_RESOLVER=$(grep ^nameserver /etc/resolv.conf | head -n 1 |awk '{ print $2}') +fi + # create nginx resolver directive echo "resolver $NAMESERVER_RESOLVER;">/tmp/resolver.conf # dump /tmp/resolver.conf echo NGINX resolver directive dump cat /tmp/resolver.conf +echo "resolver=$NAMESERVER_RESOLVER" + +while true; do + if [ -z "$SPEEDTEST_FQDN" ]; then + SPEEDTEST_FQDN=$(nslookup website | awk '/^Name:/ { print $2 }') + fi + + if [ -z "$PYOS_FQDN" ]; then + PYOS_FQDN=$(nslookup pyos | awk '/^Name:/ { print $2 }') + fi + + if [ -z "$CONSOLE_FQDN" ]; then + CONSOLE_FQDN=$(nslookup console | awk '/^Name:/ { print $2 }') + fi + if [ -z "$WEBSITE_FQDN" ]; then + WEBSITE_FQDN=$(nslookup website | awk '/^Name:/ { print $2 }') + fi + + if [ -z "$SPEEDTEST_FQDN" ] || [ -z "$PYOS_FQDN" ] || [ -z "$CONSOLE_FQDN" ] || [ -z "$WEBSITE_FQDN" ] ; then + echo "SPEEDTEST_FQDN=$SPEEDTEST_FQDN" + echo "PYOS_FQDN=$PYOS_FQDN" + echo "CONSOLE_FQDN=$CONSOLE_FQDN" + echo "WEBSITE_FQDN=$WEBSITE_FQDN" + echo "sleeping for 1s, for nslookup" + sleep 1s + else + break + fi +done -SPEEDTEST_FQDN=$(nslookup website | awk '/^Name:/ { print $2 }') -PYOS_FQDN=$(nslookup pyos | awk '/^Name:/ { print $2 }') -CONSOLE_FQDN=$(nslookup console | awk '/^Name:/ { print $2 }') -WEBSITE_FQDN=$(nslookup website | awk '/^Name:/ { print $2 }') +echo +echo "==========================" +echo "nginx is starting with env" +echo "resolver=$NAMESERVER_RESOLVER" +echo "SPEEDTEST_FQDN=$SPEEDTEST_FQDN" +echo "PYOS_FQDN=$PYOS_FQDN" +echo "CONSOLE_FQDN=$CONSOLE_FQDN" +echo "WEBSITE_FQDN=$WEBSITE_FQDN" export SPEEDTEST_FQDN export PYOS_FQDN