Adjust Public IP resolving to be used in sh (#3)
This commit is contained in:
parent
71a170513b
commit
814b9d7bde
|
@ -21,10 +21,10 @@ echo "Starting geth..."
|
||||||
PUBLIC_IP_ARGS=""
|
PUBLIC_IP_ARGS=""
|
||||||
if [[ -n "${NAT_PUBLIC_IP_AUTO}" ]]; then
|
if [[ -n "${NAT_PUBLIC_IP_AUTO}" ]]; then
|
||||||
# Run for 60 seconds if fail
|
# Run for 60 seconds if fail
|
||||||
WAIT=60
|
wait=60
|
||||||
SECONDS=0
|
end=$(( $(date +%s) + wait ))
|
||||||
SLEEP=5
|
sleep=5
|
||||||
while (( $SECONDS < $WAIT )); do
|
while [[ $(date +%s) -lt $end ]]; do
|
||||||
PUBLIC_IP=$(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
|
# Check if exit code is 0 and returned value is not empty
|
||||||
if [[ $? -eq 0 && -n "${PUBLIC_IP}" ]]; then
|
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}"
|
echo "Public: Set extip: ${PUBLIC_IP_ARGS}"
|
||||||
break
|
break
|
||||||
else
|
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
|
fi
|
||||||
# Sleep and check again
|
# Sleep and check again
|
||||||
sleep $SLEEP
|
sleep $sleep
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue