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.

47 lines
1.7 KiB

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