Created
May 25, 2016 20:51
-
-
Save michaelsanford/50ae8804ed0f848e6725c5f4d7f84741 to your computer and use it in GitHub Desktop.
Email when a DNS change has propagated to a certain nameserver.
This file contains 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
#!/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