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.

52 lines
2.0 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 __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. # set IP version dependend dummy (localhost)
  18. [ $use_ipv6 -eq 0 ] && __DUMMY="127.0.0.1" || __DUMMY="::1"
  19. # lets do DUMMY transfer
  20. write_log 7 "sending dummy IP to 'no-ip.com'"
  21. __URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
  22. -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__DUMMY#g")
  23. [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
  24. do_transfer "$__URL" || return 1
  25. write_log 7 "'no-ip.com' answered:\n$(cat $DATFILE)"
  26. # analyse provider answers
  27. # "good [IP_ADR]" = successful
  28. # "nochg [IP_ADR]" = no change but OK
  29. grep -E "good|nochg" $DATFILE >/dev/null 2>&1 || return 1
  30. # lets wait a seconds
  31. sleep 1
  32. # now send the correct data
  33. write_log 7 "sending real IP to 'no-ip.com'"
  34. __URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
  35. -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
  36. [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
  37. do_transfer "$__URL" || return 1
  38. write_log 7 "'no-ip.com' answered:\n$(cat $DATFILE)"
  39. # analyse provider answers
  40. # "good [IP_ADR]" = successful
  41. # "nochg [IP_ADR]" = no change but OK
  42. grep -E "good|nochg" $DATFILE >/dev/null 2>&1
  43. return $? # "0" if "good" or "nochg" found