lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

update_no-ip_com.sh (2075B)


      1 #
      2 #.Distributed under the terms of the GNU General Public License (GPL) version 2.0
      3 #
      4 # script for sending updates to no-ip.com / noip.com
      5 #.2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
      6 #
      7 # This script is parsed by dynamic_dns_functions.sh inside send_update() function
      8 #
      9 # provider did not reactivate records, if no IP change was recognized
     10 # so we send a dummy (localhost) and a seconds later we send the correct IP addr
     11 #
     12 local __DUMMY
     13 local __UPDURL="http://[USERNAME]:[PASSWORD]@dynupdate.no-ip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
     14 # inside url we need username and password
     15 [ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
     16 [ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
     17 
     18 # set IP version dependend dummy (localhost)
     19 [ $use_ipv6 -eq 0 ] && __DUMMY="127.0.0.1" || __DUMMY="::1"
     20 
     21 # lets do DUMMY transfer
     22 write_log 7 "sending dummy IP to 'no-ip.com'"
     23 __URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
     24 			       -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__DUMMY#g")
     25 [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
     26 
     27 do_transfer "$__URL" || return 1
     28 
     29 write_log 7 "'no-ip.com' answered:\n$(cat $DATFILE)"
     30 # analyse provider answers
     31 # "good [IP_ADR]"	= successful
     32 # "nochg [IP_ADR]"	= no change but OK
     33 grep -E "good|nochg" $DATFILE >/dev/null 2>&1 || return 1
     34 
     35 # lets wait a seconds
     36 sleep 1
     37 
     38 # now send the correct data
     39 write_log 7 "sending real IP to 'no-ip.com'"
     40 __URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
     41 			       -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
     42 [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
     43 
     44 do_transfer "$__URL" || return 1
     45 
     46 write_log 7 "'no-ip.com' answered:\n$(cat $DATFILE)"
     47 # analyse provider answers
     48 # "good [IP_ADR]"	= successful
     49 # "nochg [IP_ADR]"	= no change but OK
     50 grep -E "good|nochg" $DATFILE >/dev/null 2>&1
     51 return $?	# "0" if "good" or "nochg" found
     52