Last active
October 13, 2015 13:58
-
-
Save stevejenkins/4206617 to your computer and use it in GitHub Desktop.
"Is Comcast up?" shell script
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
#!/bin/sh | |
# Original version developed by Reverend Booyah! (SteveCook.net) | |
# First, ping Comcast's web server | |
ping -q -c 2 www.comcast.net &> /dev/null | |
if [ $? -ne 0 ] ; then | |
echo "Comcast didn't work" | |
# If Comcast fails, that's Strike 1. Next, ping Yahoo's web server | |
ping -q -c 2 yahoo.com &> /dev/null | |
if [ $? -ne 0 ] ; then | |
echo "Yahoo didn't work" | |
# If Yahoo fails, that's Strike 2. Next, ping Google's web server | |
ping -q -c 2 google.com &> /dev/null | |
if [ $? -ne 0 ] ; then | |
echo "Google didn't work" | |
# Since Google also failed, that's Strike 3. Time to power cycle the modem and router! | |
echo "Initiating reboot script" | |
# Send yourself an email with the script output | |
/usr/bin/smtp-cli --missing-modules-ok --ipv4 --server=localhost --host=mail.example.com --port=587 --enable-auth --user username --pass password --from root@example.com --to yourself@example.com --subject "Reboot Alert" | |
# Pipe the reboot script through telnet | |
/usr/local/bin/reboot_script.php | telnet | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment