Created
November 22, 2019 23:01
-
-
Save henkin/7b58b3d52fe1e8b622fc7a147e0b88a5 to your computer and use it in GitHub Desktop.
Wait for DNS to resolve, return IP #gcp #dns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# wait-dns-ip.sh <hostname> | |
# eg: wait-dns-ip.sh host.foo.com | |
# | |
# Will timeout after 5minutes (5 * 60 tries * 1 sec wait = 300 secs) | |
DNS_IP="" | |
COUNTER=0 | |
while [ -z $DNS_IP ] && [ $COUNTER -lt 300 ]; do | |
DNS_IP=$(nslookup $1.humanaedge.io | awk '/^Address: / { print $2 }') | |
[ -z "$DNS_IP" ] && sleep 1 | |
((COUNTER++)) | |
done | |
[ -z "$DNS_IP" ] && echo "timeout" || echo $DNS_IP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment