Skip to content

Instantly share code, notes, and snippets.

@mannieschumpert
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mannieschumpert/aca2fc81f0d00c21e5cb to your computer and use it in GitHub Desktop.
Save mannieschumpert/aca2fc81f0d00c21e5cb to your computer and use it in GitHub Desktop.
Bash loop to test URL propagation, including notifications when propagated
propagate(){
# Reminder for arguments
if [ "$1" == "-h" ]; then
echo "Arguments:
1: URL
2: New IP
Example: website.com 879.30.33.21"
return
fi
curr_ip=`nslookup $1 | grep Address | sed -n '2p' | cut -d: -f2|sed 's/^[ \t]*//'`
while [ "${2}" != "$curr_ip" ]; do
echo "$curr_ip $(date "+%T")"
sleep 300
curr_ip=`nslookup $1 | grep Address | sed -n '2p' | cut -d: -f2|sed 's/^[ \t]*//'`
done
echo "${1} has propagated to ${2}"
# Echo to Notification Center (requires terminal notifier Ruby gem https://github.com/alloy/terminal-notifier)
terminal-notifier -message "${1} has propagated to ${2}" -title "Propagation Complete" -sound "Glass"
# Other notifications
# (I use curl to text myself via the Twilio API in case I'm AFK
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment