Skip to content

Instantly share code, notes, and snippets.

@henkin
Created November 22, 2019 23:01
Show Gist options
  • Save henkin/7b58b3d52fe1e8b622fc7a147e0b88a5 to your computer and use it in GitHub Desktop.
Save henkin/7b58b3d52fe1e8b622fc7a147e0b88a5 to your computer and use it in GitHub Desktop.
Wait for DNS to resolve, return IP #gcp #dns
#!/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