Adjust Public IP resolving to be used in sh (#3)

This commit is contained in:
Slava 2023-11-21 13:54:20 +02:00 committed by GitHub
parent 71a170513b
commit 814b9d7bde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -21,10 +21,10 @@ 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
@ -32,10 +32,10 @@ if [[ -n "${NAT_PUBLIC_IP_AUTO}" ]]; then
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