#!/bin/bash
#
# 11-01 Pete Nesbitt
# script to check if eth0's IP has changed.
#
DATE=`/bin/date`
# set variables for email
EMAIL="user domain com user otherdomain com"
# a file to hold the previous IP
OLDIP="/usr/local/scripts/check_ip/oldip.txt"
# check for the current IP
CURRENT_IP="`/sbin/ifconfig -a|/bin/grep -A 2 eth0|/bin/awk '/inet/ { print $2
}'|/bin/sed -e s/addr://`"
# compare to new IP to last IP
if [ "`/bin/cat $OLDIP`" != "$CURRENT_IP" ]; then
# next part is all one line
/bin/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."|/bin/mail -s "New IP Address" $EMAIL
# end if the long line
# copy the new IP to the old IP
/bin/echo "$CURRENT_IP" > $OLDIP
fi
exit