daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Dec 14th, 2018 198 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. NOWIPADDR="/home/scripts/nowipaddr"
  3. GETIPADDR="dig +short myip.opendns.com @resolver1.opendns.com"
  4. LOG="/home/scripts/ip.log"
  5. timestamp=$( date +%T )
  6. curDate=$( date +"%m-%d-%y" )
  7.  
  8. if [ -f $NOWIPADDR ]; then
  9.   if [[ `$GETIPADDR` = $(< $NOWIPADDR) ]]; then
  10.     echo $curDate $timestamp " IP address check: " $(< $NOWIPADDR) >> $LOG
  11.   else
  12.     $GETIPADDR > $NOWIPADDR
  13.     mail -s "Server IP" email@gmail.com < $NOWIPADDR
  14. fi
  15. else
  16.   curl $GETIPADDR > $NOWIPADDR
  17.   mail -s "Server IP" email@gmail.com < $NOWIPADDR
  18. fi
  19.    
  20. wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//' > ~/myip
  21.    
  22. myip=`wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'`<br>
  23. sendEmail -f you@yourmail.com -m $myip
  24.    
  25. NOWIPADDR="nowipaddr"
  26. GETIPADDR="ifconfig.me"
  27.  
  28.  
  29.     if [ -f $NOWIPADDR ]
  30.     then
  31.        if [ `cat $NOWIPADDR` = `curl $GETIPADDR` ]
  32.        then
  33.            echo "no change in IP."
  34.        else
  35.            $GETIPADDR > $NOWIPADDR
  36.            mail -s "IP is $GETIPADDR" yourmailadd@gmail.com
  37.         fi
  38.     else
  39.         curl $GETIPADDR >> $NOWIPADDR
  40.     fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top