packages/net/ddns-scripts/samples/update_sample.sh
Christian Schoenebeck 5b26382273 ddns-scripts: Update to version 2.2.0-1
modified source directory structure
  - files for production files
  - samples for sample files (not installed in final build)
modified Makefile
  - separate options for additional provider scripts
  - remove comments and empty lines from final build
add IPv4 100.64/10 (RFC 6598) and 169.254/16 (RFC 5735) to the range of default blocked IP's.
new option "bind_network" to force GNU Wget or cURL to use specific network/interface for communication
new "domains.google.com" as IPv4 DDNS provider #822

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
2015-02-05 21:33:02 +01:00

39 lines
1.6 KiB
Bash

# sample script for sending user defined updates
# 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
#
# activated inside /etc/config/ddns by setting
#
# option update_script '/usr/lib/ddns/update_sample.sh'
#
# the script is parsed (not executed) inside send_update() function
# of /usr/lib/ddns/dynamic_dns_functions.sh
# so you can use all available functions and global variables inside this script
# already defined in dynamic_dns_updater.sh and dynamic_dns_functions.sh
#
# It make sence to define the update url ONLY inside this script
# because it's anyway unique to the update script
# otherwise it should work with the default scripts
#
# the code here is the copy of the default used inside send_update()
#
# tested with spdns.de
local __URL="http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
# inside url we need username and password
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
# do replaces in URL
__URL=$(echo $__URL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
-e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
[ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
do_transfer "$__URL" || return 1
write_log 7 "DDNS Provider answered:\n$(cat $DATFILE)"
# analyse provider answers
# "good [IP_ADR]" = successful
# "nochg [IP_ADR]" = no change but OK
grep -E "good|nochg" $DATFILE >/dev/null 2>&1
return $? # "0" if "good" or "nochg" found