Skip to content

Instantly share code, notes, and snippets.

@chenshaoju
Created April 11, 2021 08:01
Show Gist options
  • Save chenshaoju/5a361138d55630d2bcef3581139fb17e to your computer and use it in GitHub Desktop.
Save chenshaoju/5a361138d55630d2bcef3581139fb17e to your computer and use it in GitHub Desktop.
Check public ip, if changed then send email by using ssmtp
#!/bin/bash
#
LastIP=`cat /root/ip1`
WanIP=`curl ifconfig.me`
if [ "$LastIP" != "$WanIP" ]
then
echo "$WanIP" > /root/ip1
echo -e "Subject: this is the subject\n\n$WanIP" | ssmtp example@example.com
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment