Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.