#!/bin/bash # # 11-01 Pete Nesbitt # script to check if eth0's IP has changed. # # already have a "emailnotice" alias in /etc/aliases DATE=`date` # set variables for email EMAIL="linux1@telus.net petern@ola.bc.ca" # a file to hold the previous IP OLDIP="/usr/scripts/checkip/oldip" # check for the current IP CURRENT_IP="`/sbin/ifconfig -a|grep -A 2 eth0|awk '/inet/ { print $2 }'|sed -e s/addr://`" # compare to new IP to last IP if [ "`cat $OLDIP`" != "$CURRENT_IP" ]; then echo "The IP was reset at $DATE (ea 20 min.). The OLD IP was `cat $OLDIP`. The New IP is $CURRENT_IP. You must update yi.org and hostname."|mail -s "New IP Address" $EMAIL # copy the new IP to the old IP echo "$CURRENT_IP" > $OLDIP fi exit