Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- get_ip=`wget -q -O - http://checkip.dyndns.org/ | grep -Eo '[0-9\.]+'`
- if [ "$get_ip" = "$(cat ./iplog.txt)" ]; then
- echo "No need, I'm out of here..."
- exit;
- else
- echo "The IP has changed! Sending an email..."
- echo "SUBJECT: My External WAN IP Address has changed" > ./whereami.txt
- echo "FROM: John's CentOS 7 Samba Server" >> ./whereami.txt
- date >> ./whereami.txt
- echo " " >> ./whereami.txt
- echo "$get_ip" >> ./whereami.txt
- echo "$get_ip" > ./iplog.txt
- echo "My External IP Address Changed: " `date` > My_External_IP_Address_Changed.txt
- # my code
- /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