Without taking the cron job into account, this script would check the ip and email if different:
if [ $(echo $CURIP) != $(echo $OLDIP) ]
env MAILRC=/dev/null from="firstname.lastname@example.org" smtp=smtp.example.com mailx -n -s "IP Change Alert" email@example.com < /path/to/message.contents.txt
echo $CURIP > /path/to/some/file/containing/old/ip/address
CURIP is the result of the command `curl ipplz.org` which i'm using instead of the overly verbose ifconfig.me
OLDIP is the contents of some file you must have on your system telling you of your old IP address
if these two values do not match,
then send the email.
and also place the new IP in the standard file keeping track of your public IP address so we can use it the next time this script runs.
So you need:
- the old ip address to be stored in some location on your harddrive. I dunno, maybe in /tmp or something.
- an email address to plug into your FROM field
- an email address to plug into your TO field
- a valid SMTP server through which you may send email
There are probably better ways to do it but that should work, I think.