Skip to content

Instantly share code, notes, and snippets.

@michaelsanford
Created May 25, 2016 20:51
Show Gist options
  • Save michaelsanford/50ae8804ed0f848e6725c5f4d7f84741 to your computer and use it in GitHub Desktop.
Save michaelsanford/50ae8804ed0f848e6725c5f4d7f84741 to your computer and use it in GitHub Desktop.
Email when a DNS change has propagated to a certain nameserver.
#!/usr/bin/env bash
# The IP to which you just updated your DNS
NEW_IP="127.0.0.1"
# The domain for which you're awaiting propagation
DOMAIN="EXAMPLE.COM"
# Polling interval in seconds
WAIT=30
until [ "$(host "${DOMAIN}" | awk 'NR==1{print $4}')" = "${NEW_IP}" ]; do
echo "$(date) Still waiting..."
sleep ${WAIT};
done
echo "The DNS migration for ${DOMAIN} has propagated and the server which can now see itself as ${NEW_IP}." | \
mail -s "DNS update for ${DOMAIN} to ${NEW_IP} propagated" [email protected]
# If you run this script but abort it before the condition is met, don't send any emails.
trap "exit" SIGHUP SIGINT SIGTERM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment