ansible-gateway/files/verify_ip.sh

26 lines
543 B
Bash
Executable File

#!/usr/bin/env bash
RETRY=3
CURL_SLEEP_TIME=10 # These are seconds
EXPECTED_IP=172.94.25.17
sleep 10 # Wait these seconds for ppp to come up
while [ $RETRY -ne 0 ]; do
IP_RESULT=$(curl -s ifconfig.co)
if [ $? -ne 0 ]; then
RETRY=$(( $RETRY - 1 ))
echo "curl failed - retrying ${RETRY} times."
sleep $CURL_SLEEP_TIME
else
break
fi
done
if [ "${EXPECTED_IP}" != "${IP_RESULT}" ]; then
echo "Expected ip (${EXPECTED_IP}) different from the one got (${IP_RESULT})"
exit 1
fi
# vim: set ft=sh et sw=0 ts=2 sts=0: