Created
April 22, 2013 21:40
-
-
Save mackuba/5438786 to your computer and use it in GitHub Desktop.
Monitors external IP address using curlmyip.com and sends an email when it changes (should be run from cron)
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/bash | |
FILE="$HOME/ip-monitor.txt" | |
OLD_IP=`cat $FILE` | |
CURRENT_IP=`curl -s http://curlmyip.com` | |
EMAILS="my.address@gmail.com" | |
SUBJECT="IP address changed" | |
FROM="IP Address Bot <root@localhost>" | |
if [ "$CURRENT_IP" ]; then | |
if [ "$CURRENT_IP" != "$OLD_IP" ]; then | |
echo "New external IP address: $CURRENT_IP" | mail -s "$SUBJECT" -a "From: $FROM" $EMAILS | |
echo "$CURRENT_IP" > $FILE | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment