#!/bin/sh # Send mail if new IP comes in. # based on WANIPCheck # Checks your WAN IP-Address at a given interval and emails you the new IP-Address if changed # # Orig Created by CYBERDE for DD-WRT users ;) # --> http://www.dd-wrt.com/phpBB2/viewtopic.php?t=16041 # mod by Henning Mersch # Some settings MAIL_BINARY=/jffs/bin/sendmail MAIL_SERVER=SOMEMAILSERVER.TLD MAIL_TO=SEND_TO_ADDR MAIL_FROM=SEND_FROM_ADDR MAIL_SUBJECT="New IP Notification" # Function for sending the log to an email address sendemail() { # Create the email message echo "Subject: $MAIL_SUBJECT" > /tmp/mailnotification echo "WAN IP-Address has changed to: $1" >> /tmp/mailnotification echo "Previous known WAN IP-Address: $2" >> /tmp/mailnotification # Send the email message logger "$0: Sending email to $MAIL_TO" cat /tmp/mailnotification | $MAIL_BINARY -s$MAIL_SERVER -f$MAIL_FROM $MAIL_TO # Cleanup email message rm /tmp/mailnotification } # Does the nvram var wan_ipaddr_last exist? if ! nvram show | grep -q wan_ipaddr_last; then nvram set wan_ipaddr_last=`nvram get wan_ipaddr` nvram commit fi # The "main" loop CURR_WAN_IPADDR=`nvram get wan_ipaddr` LAST_WAN_IPADDR=`nvram get wan_ipaddr_last` # Send mail sendemail $CURR_WAN_IPADDR $LAST_WAN_IPADDR # Update the nvram variable to the current IP-Address nvram set wan_ipaddr_last=$CURR_WAN_IPADDR nvram commit