ddns-scripts: Update to Version 2.1.0-1 see description
[feed/packages.git] / net / ddns-scripts / files / usr / lib / ddns / update_no-ip.sh
1 #
2 # script for sending updates to no-ip.com / noip.com
3 # 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
4 #
5 # This script is parsed by dynamic_dns_functions.sh inside send_update() function
6 #
7 # provider did not reactivate records, if no IP change was recognized
8 # so we send a dummy (localhost) and a seconds later we send the correct IP addr
9 #
10 local __ANSWER __LH
11 local __UPDURL="http://[USERNAME]:[PASSWORD]@dynupdate.no-ip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
12
13 # set IP version dependend dummy (localhost)
14 [ $use_ipv6 -eq 0 ] && __LH="127.0.0.1" || __LH="::1"
15
16 # lets do DUMMY transfer
17 write_log 7 "sending dummy IP to 'no-ip.com'"
18 __URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
19 -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__LH#g")
20 [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
21
22 do_transfer __ANSWER "$__URL" || return 1
23
24 write_log 7 "'no-ip.com' answered:\n$__ANSWER"
25 # analyse provider answers
26 # "good [IP_ADR]" = successful
27 # "nochg [IP_ADR]" = no change but OK
28 echo "$__ANSWER" | grep -E "good|nochg" >/dev/null 2>&1 || return 1
29
30 # lets wait a seconds
31 sleep 1
32
33 # now send the correct data
34 write_log 7 "sending real IP to 'no-ip.com'"
35 __URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
36 -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
37 [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
38
39 do_transfer __ANSWER "$__URL" || return 1
40
41 write_log 7 "'no-ip.com' answered:\n$__ANSWER"
42 # analyse provider answers
43 # "good [IP_ADR]" = successful
44 # "nochg [IP_ADR]" = no change but OK
45 echo "$__ANSWER" | grep -E "good|nochg" >/dev/null 2>&1
46 return $? # "0" if "good" or "nochg" found
47