From 71a170513bef426f8a63190a5eb899da399448c7 Mon Sep 17 00:00:00 2001 From: Slava <20563034+veaceslavdoina@users.noreply.github.com> Date: Tue, 21 Nov 2023 13:22:45 +0200 Subject: [PATCH] Update Public IP resolving in docker-entrypoint.sh (#2) --- content/docker-entrypoint.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/content/docker-entrypoint.sh b/content/docker-entrypoint.sh index 96d593b..c6ab121 100644 --- a/content/docker-entrypoint.sh +++ b/content/docker-entrypoint.sh @@ -25,9 +25,15 @@ if [[ -n "${NAT_PUBLIC_IP_AUTO}" ]]; then SECONDS=0 SLEEP=5 while (( $SECONDS < $WAIT )); do - PUBLIC_IP_ARGS=--nat=extip:$(curl -s -f -m 5 "${NAT_PUBLIC_IP_AUTO}") + PUBLIC_IP=$(curl -s -f -m 5 "${NAT_PUBLIC_IP_AUTO}") # Check if exit code is 0 and returned value is not empty - [[ $? -eq 0 && -n "${PUBLIC_IP_ARGS}" ]] && { echo "Public: Set extip: ${PUBLIC_IP_ARGS}"; break; } || { echo "Can't get Public IP - Retry in $SLEEP seconds / $((WAIT - SECONDS))"; } + if [[ $? -eq 0 && -n "${PUBLIC_IP}" ]]; then + PUBLIC_IP_ARGS="--nat=extip:${PUBLIC_IP}" + echo "Public: Set extip: ${PUBLIC_IP_ARGS}" + break + else + echo "Can't get Public IP - Retry in $SLEEP seconds / $((WAIT - SECONDS))" + fi # Sleep and check again sleep $SLEEP done