Skip to content

Commit

Permalink
Adjust Public IP resolving to be used in sh (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
veaceslavdoina authored Nov 21, 2023
1 parent 71a1705 commit 814b9d7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions content/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ echo "Starting geth..."
PUBLIC_IP_ARGS=""
if [[ -n "${NAT_PUBLIC_IP_AUTO}" ]]; then
# Run for 60 seconds if fail
WAIT=60
SECONDS=0
SLEEP=5
while (( $SECONDS < $WAIT )); do
wait=60
end=$(( $(date +%s) + wait ))
sleep=5
while [[ $(date +%s) -lt $end ]]; do
PUBLIC_IP=$(curl -s -f -m 5 "${NAT_PUBLIC_IP_AUTO}")
# Check if exit code is 0 and returned value is not empty
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))"
echo "Can't get Public IP - Retry in $sleep seconds / $(( end - $(date +%s) ))"
fi
# Sleep and check again
sleep $SLEEP
sleep $sleep
done
fi

Expand Down

0 comments on commit 814b9d7

Please sign in to comment.