Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- IP=$(curl -s http://www.ipchicken.com/ | awk '/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/ {print $1}' | uniq)
- FILE="/dev/shm/ip.dat"
- trigger_notification () {
- echo $IP > $FILE
- # see http://www.nixtutor.com/linux/send-mail-with-gmail-and-ssmtp/
- /sbin/ifconfig | mail -s "Notification: IP address $IP" my-email@addr.com
- }
- if [ ! -f "$FILE" ]; then
- # data file does not exist, create one and notify the user
- trigger_notification
- else
- if [ $IP != "$(cat $FILE)" ]
- then
- # file already exists but ip doesn't match
- trigger_notification
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement