Last active
March 28, 2016 12:09
-
-
Save wb14123/93b8ec085b5772d92493 to your computer and use it in GitHub Desktop.
Send you an Email while the IP has changed
This file contains hidden or 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 | |
# Install postfix in order to send Email | |
# Put this script in /etc/cron.hourly can test if the IP has changed per hour. | |
# Change the Email "[email protected]" to your Email | |
ip_file='/tmp/cur_ip' | |
email='[email protected]' | |
last_ip=`cat $ip_file` | |
cur_ip=`curl ifconfig.me` | |
if [ "$cur_ip" != "" ] && [ "$last_ip" != "$cur_ip" ]; then | |
echo $cur_ip > $ip_file | |
echo "IP has changed to $cur_ip" | |
echo "Office IP has changed to $cur_ip" | mail -s "Office IP Changed" $email | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment