Last active
August 29, 2015 14:07
-
-
Save mannieschumpert/aca2fc81f0d00c21e5cb to your computer and use it in GitHub Desktop.
Bash loop to test URL propagation, including notifications when propagated
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
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