Advertisement
stspringer

my script

Feb 15th, 2016
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. get_ip=`wget -q -O - http://checkip.dyndns.org/ | grep -Eo '[0-9\.]+'`
  2. if [ "$get_ip" = "$(cat ./iplog.txt)" ]; then
  3. echo "No need, I'm out of here..."
  4. exit;
  5. else
  6. echo "The IP has changed! Sending an email..."
  7. echo "SUBJECT: My External WAN IP Address has changed" > ./whereami.txt
  8. echo "FROM: John's CentOS 7 Samba Server" >> ./whereami.txt
  9. date >> ./whereami.txt
  10. echo " " >> ./whereami.txt
  11. echo "$get_ip" >> ./whereami.txt
  12. echo "$get_ip" > ./iplog.txt
  13. echo "My External IP Address Changed: " `date` > My_External_IP_Address_Changed.txt
  14. # my code
  15.  
  16. /usr/sbin/sendmail -v -f [email protected] -s smtp.gmail.com:587 -xu [email protected] -xp password -t [email protected] -o tls=yes -u "Attention John! From Your Samba Server, Your External IP Addresss Has Changed" -m < ./whereami.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement