Skip to content

Instantly share code, notes, and snippets.

@stevejenkins
Last active October 13, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stevejenkins/4206617 to your computer and use it in GitHub Desktop.
Save stevejenkins/4206617 to your computer and use it in GitHub Desktop.
"Is Comcast up?" shell script
#!/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