You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.2 KiB

  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 __UPDURL6="http://[USERNAME]:[PASSWORD]@dynupdate6.noip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
  14. local __UPDURL="http://[USERNAME]:[PASSWORD]@dynupdate.noip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
  15. # inside url we need username and password
  16. [ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
  17. [ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
  18. # set IP version dependend dummy (localhost)
  19. [ $use_ipv6 -eq 0 ] && __DUMMY="127.0.0.1" || __DUMMY="::1"
  20. [ $use_ipv6 -eq 0 ] && __UPDURL=$__UPDURL || __UPDURL=$__UPDURL6
  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. do_transfer "$__URL" || return 1
  27. write_log 7 "'no-ip.com' answered:${N}$(cat $DATFILE)"
  28. # analyse provider answers
  29. # "good [IP_ADR]" = successful
  30. # "nochg [IP_ADR]" = no change but OK
  31. grep -E "good|nochg" $DATFILE >/dev/null 2>&1 || return 1
  32. # lets wait a seconds
  33. sleep 1
  34. # now send the correct data
  35. write_log 7 "sending real IP to 'no-ip.com'"
  36. __URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
  37. -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
  38. [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
  39. do_transfer "$__URL" || return 1
  40. write_log 7 "'no-ip.com' answered:${N}$(cat $DATFILE)"
  41. # analyse provider answers
  42. # "good [IP_ADR]" = successful
  43. # "nochg [IP_ADR]" = no change but OK
  44. grep -E "good|nochg" $DATFILE >/dev/null 2>&1
  45. return $? # "0" if "good" or "nochg" found