Browse Source

ddns-scripts: Update to Version 2.1.0-1 see description

- fixed postinst and prerm in Makefile
- implementation of provider specific update scripts into services and
services_ipv6 file.
	first Provider "no-ip.com"	- Thanks to DarkStarXxX for
request and testing
- finished uci/ddns wiki at http://wiki.openwrt.org/doc/uci/ddns
- rewritten retry management
- rewritten logging including following Issue 469
	https://github.com/openwrt/packages/issues/469
- stop running sections on hotplug ifdown event (like start on ifup)
- implement trap detection
	also kill "sleep" child processes
	SIGHUP to reload configuration (not really reloading, simply
starting a new process)
	/etc/init.d/ddns reload implemented
- code optimization
- new provider LoopiaDNS.se	Issue 494
	https://github.com/openwrt/packages/issues/494

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
Christian Schoenebeck 10 years ago
parent
commit
4192651448

+ 84
- 0
net/ddns-scripts/CHANGELOG View File

1
+Version 2.1.0-1
2
+Date	2014-11-09
3
+
4
+- fixed postinst and prerm in Makefile
5
+- implementation of provider specific update scripts into services and services_ipv6 file.
6
+	first Provider "no-ip.com"	- Thanks to DarkStarXxX for request and testing
7
+- finished uci/ddns wiki at http://wiki.openwrt.org/doc/uci/ddns
8
+- rewritten retry management
9
+- rewritten logging including following Issue 469 
10
+	https://github.com/openwrt/packages/issues/469
11
+- stop running sections on hotplug ifdown event (like start on ifup)
12
+- implement trap detection
13
+	also kill "sleep" child processes
14
+	SIGHUP to reload configuration (not really reloading, simply starting a new process)
15
+	/etc/init.d/ddns reload implemented
16
+- code optimization
17
+- new provider LoopiaDNS.se	Issue 494
18
+	https://github.com/openwrt/packages/issues/494
19
+
20
+--------------------------------------------------------------------------------
21
+Version 2.0.1-9
22
+Date	2014-10-11
23
+
24
+- add retry loop to verify dns and proxy when script starts
25
+
26
+--------------------------------------------------------------------------------
27
+Version 2.0.1-8
28
+Date	2014-10-06
29
+
30
+- fixes problem CRITICAL ERROR - custom update_script not found
31
+
32
+--------------------------------------------------------------------------------
33
+Version 2.0.1-7
34
+Date	2014-10-05
35
+
36
+- Added support for custom update scripts with new option update_script
37
+
38
+--------------------------------------------------------------------------------
39
+Version 2.0.1-6
40
+Date	2014-10-01
41
+
42
+- url encode USERNAME and PASSWORD in update url
43
+
44
+--------------------------------------------------------------------------------
45
+Version 2.0.1-5
46
+Date	2014-09-30
47
+
48
+- fix send_update() detection of private IPv4
49
+
50
+--------------------------------------------------------------------------------
51
+Version 2.0.1-4
52
+Date	2014-09-29
53
+
54
+- fix ticket #17998: wrongly detect ipv4 start with 10x.x.x.x
55
+
56
+--------------------------------------------------------------------------------
57
+Version 2.0.1-3
58
+Date	2014-09-28
59
+
60
+- add service two-dns.de
61
+
62
+--------------------------------------------------------------------------------
63
+Version 2.0.1-2
64
+Date	2014-09-22
65
+
66
+- fix issue (#337) current/registered ip
67
+	https://github.com/openwrt/packages/issues/337
68
+
69
+--------------------------------------------------------------------------------
70
+Version 2.0.1-1
71
+Date	2014-09-20
72
+
73
+- 1st published version via github
74
+
75
+--------------------------------------------------------------------------------
76
+Version 2.0.0
77
+Date	2014-07-16
78
+
79
+- published via OpenWrt TRAC system as zip-file for testing
80
+	- IPv6 address support
81
+	- log file support
82
+	- syslog support for various error levels
83
+	- verify all given parameters before starting main loop
84
+	- retry max retry_counter times before terminating scripts

+ 7
- 4
net/ddns-scripts/Makefile View File

1
 include $(TOPDIR)/rules.mk
1
 include $(TOPDIR)/rules.mk
2
 
2
 
3
 PKG_NAME:=ddns-scripts
3
 PKG_NAME:=ddns-scripts
4
-PKG_VERSION:=2.0.1
5
-PKG_RELEASE:=9
4
+PKG_VERSION:=2.1.0
5
+PKG_RELEASE:=1
6
 PKG_LICENSE:=GPL-2.0
6
 PKG_LICENSE:=GPL-2.0
7
 
7
 
8
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
8
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
62
 define Package/ddns-scripts/postinst
62
 define Package/ddns-scripts/postinst
63
 	#!/bin/sh
63
 	#!/bin/sh
64
 	# if run within buildroot exit
64
 	# if run within buildroot exit
65
-	[ -n "${IPKG_INSTROOT}" ] && exit 0
65
+	[ -n "$${IPKG_INSTROOT}" ] && exit 0
66
+
67
+	# remove old sed script file
68
+	[ -f /usr/lib/ddns/url_escape.sed ] && rm -f /usr/lib/ddns/url_escape.sed
66
 
69
 
67
 	# add new section "ddns" "global" if not exists
70
 	# add new section "ddns" "global" if not exists
68
 	uci -q get ddns.global > /dev/null || uci -q set ddns.global='ddns'
71
 	uci -q get ddns.global > /dev/null || uci -q set ddns.global='ddns'
79
 define Package/ddns-scripts/prerm
82
 define Package/ddns-scripts/prerm
80
 	#!/bin/sh
83
 	#!/bin/sh
81
 	# if run within buildroot exit
84
 	# if run within buildroot exit
82
-	[ -n "${IPKG_INSTROOT}" ] && exit 0
85
+	[ -n "$${IPKG_INSTROOT}" ] && exit 0
83
 
86
 
84
 	# stop running scripts
87
 	# stop running scripts
85
 	/etc/init.d/ddns disable
88
 	/etc/init.d/ddns disable

+ 3
- 2
net/ddns-scripts/files/etc/config/ddns View File

1
 #
1
 #
2
 # Please read ddns.sample
2
 # Please read ddns.sample
3
+# or http://wiki.openwrt.org/doc/uci/ddns
3
 #
4
 #
4
 config ddns "global"
5
 config ddns "global"
5
 	option date_format "%F %R"
6
 	option date_format "%F %R"
9
 
10
 
10
 
11
 
11
 config service "myddns_ipv4"
12
 config service "myddns_ipv4"
12
-	option service_name	"dyndns.org"
13
-	option domain		"yourhost.dyndns.org"
13
+	option service_name	"example.org"
14
+	option domain		"yourhost.example.org"
14
 	option username		"your_username"
15
 	option username		"your_username"
15
 	option password		"your_password"
16
 	option password		"your_password"
16
 	option interface	"wan"
17
 	option interface	"wan"

+ 8
- 8
net/ddns-scripts/files/etc/config/ddns.sample View File

127
 	###########
127
 	###########
128
 	# use HTTPS for secure communication with you DDNS provider
128
 	# use HTTPS for secure communication with you DDNS provider
129
 	# personally found some providers having problems when not sending 
129
 	# personally found some providers having problems when not sending 
130
-	# updates via HTTPS. Yyou must not specify "https://" in update_url. 
130
+	# updates via HTTPS. You must not specify "https://" in update_url. 
131
 	# It's modified by the scripts themselves
131
 	# It's modified by the scripts themselves
132
 	# Needs GNU Wget (with SSL support) or cURL to be installed.
132
 	# Needs GNU Wget (with SSL support) or cURL to be installed.
133
 	# default: "0"	do not use HTTPS
133
 	# default: "0"	do not use HTTPS
139
 	# the transfer program can find them. (might need package CA-certificates)
139
 	# the transfer program can find them. (might need package CA-certificates)
140
 	# if you don't want to verify servers certificate (insecure) you should
140
 	# if you don't want to verify servers certificate (insecure) you should
141
 	# this parameter to "IGNORE" (in capital letters)
141
 	# this parameter to "IGNORE" (in capital letters)
142
-	# default: "/etc/cacert"	path where CA-certificate package is installed
143
-	option cacert "/etc/cacert"
142
+	# default: (none)	path where CA-certificate package is installed
143
+	option cacert "/etc/ssl/certs"
144
 
144
 
145
 	###########
145
 	###########
146
 	# for logging and control if everything work fine you can get information inside
146
 	# for logging and control if everything work fine you can get information inside
210
 	option force_ipversion "0"
210
 	option force_ipversion "0"
211
 
211
 
212
 	###########
212
 	###########
213
-	# normally the current (in the internet) registered ip is detected using the
213
+	# Normally the current (in the internet) registered ip is detected using the
214
 	# local defined name lookup policies (i.e. /etc/resolve.conf etc.)
214
 	# local defined name lookup policies (i.e. /etc/resolve.conf etc.)
215
 	# Specify here a DNS server to use instead of the defaults.
215
 	# Specify here a DNS server to use instead of the defaults.
216
 	# you can use hostname or ip address
216
 	# you can use hostname or ip address
217
-	# IPv6 address must be in squared brackets "[...]"
218
 	# i.e. "google-public-dns-a.google.com"
217
 	# i.e. "google-public-dns-a.google.com"
219
 	# default: none
218
 	# default: none
220
 #	option dns_server "google-public-dns-a.google.com"
219
 #	option dns_server "google-public-dns-a.google.com"
236
 	# ip_source='web' (see above) because this request is also 
235
 	# ip_source='web' (see above) because this request is also 
237
 	# send via the configured proxy !!!
236
 	# send via the configured proxy !!!
238
 	# Syntax: [user:password@]proxy:port !port is required !
237
 	# Syntax: [user:password@]proxy:port !port is required !
238
+	# IPv6 address must be in squared brackets "[...]"
239
 	# default: none
239
 	# default: none
240
 #	option proxy ''
240
 #	option proxy ''
241
 
241
 
247
 	# wait this time before verify if update was successful send.
247
 	# wait this time before verify if update was successful send.
248
 	# !!! checks below 5 minutes make no sense because the Internet 
248
 	# !!! checks below 5 minutes make no sense because the Internet 
249
 	# needs about 5-10 minutes to sync an IP-change to all DNS servers !!!
249
 	# needs about 5-10 minutes to sync an IP-change to all DNS servers !!!
250
-	# accepted unit entry’s: 'seconds' 'minutes' 'hours' 'days'
250
+	# accepted unit entry’s: 'seconds' 'minutes' 'hours'
251
 	# minimum 5 minutes == 300 seconds
251
 	# minimum 5 minutes == 300 seconds
252
 	# default 10 minutes
252
 	# default 10 minutes
253
 	option check_interval	'10'
253
 	option check_interval	'10'
256
 	###########
256
 	###########
257
 	# force to send an update to service provider, if no change was detected.
257
 	# force to send an update to service provider, if no change was detected.
258
 	# consult DDNS providers documentation if your DDNS entry might timeout.
258
 	# consult DDNS providers documentation if your DDNS entry might timeout.
259
-	# accepted unit entry’s: 'seconds' 'minutes' 'hours' 'days'
259
+	# accepted unit entry’s: 'minutes' 'hours' 'days'
260
 	# minimum needs to be greater or equal check interval (see above)
260
 	# minimum needs to be greater or equal check interval (see above)
261
 	# A special setting of '0' is allowed, which forces the script to run once.
261
 	# A special setting of '0' is allowed, which forces the script to run once.
262
 	# It sends an update, verify if update was accepted by DNS 
262
 	# It sends an update, verify if update was accepted by DNS 
276
 	# if error happen on detecting, sending or updating the
276
 	# if error happen on detecting, sending or updating the
277
 	# script will retry the relevant action.
277
 	# script will retry the relevant action.
278
 	# here you define the time to wait before retry is started
278
 	# here you define the time to wait before retry is started
279
-	# accepted unit entry’s: 'seconds' 'minutes' 'hours' 'days'
279
+	# accepted unit entry’s: 'seconds' 'minutes'
280
 	# default: 60 seconds
280
 	# default: 60 seconds
281
 	option retry_interval	'60'
281
 	option retry_interval	'60'
282
 	option retry_unit	'seconds'
282
 	option retry_unit	'seconds'

+ 12
- 6
net/ddns-scripts/files/etc/hotplug.d/iface/25-ddns View File

1
 #!/bin/sh
1
 #!/bin/sh
2
 
2
 
3
-if [ "$ACTION" = "ifup" ]; then
4
-	. /usr/lib/ddns/dynamic_dns_functions.sh
5
-	/etc/init.d/ddns enabled && start_daemon_for_all_ddns_sections "$INTERFACE"
6
-fi
7
-
8
-
3
+# there are other ACTIONs like ifupdate we don't need
4
+# so parse dynamic_dns_functions.sh only when needed
5
+case "$ACTION" in
6
+	ifup)
7
+		. /usr/lib/ddns/dynamic_dns_functions.sh
8
+		/etc/init.d/ddns enabled && start_daemon_for_all_ddns_sections "$INTERFACE"
9
+		;;
10
+	ifdown)
11
+		. /usr/lib/ddns/dynamic_dns_functions.sh
12
+		stop_daemon_for_all_ddns_sections "$INTERFACE"
13
+		;;
14
+esac

+ 12
- 2
net/ddns-scripts/files/etc/init.d/ddns View File

1
 #!/bin/sh /etc/rc.common
1
 #!/bin/sh /etc/rc.common
2
 START=95
2
 START=95
3
+STOP=10
3
 
4
 
4
 boot() {
5
 boot() {
5
 	return 0
6
 	return 0
6
 }
7
 }
7
 
8
 
9
+reload() {
10
+	killall -1 dynamic_dns_updater.sh	# send SIGHUP
11
+}
12
+
13
+restart() {
14
+	stop
15
+	sleep 1	# give time to shutdown
16
+	start
17
+}
18
+
8
 start() {
19
 start() {
9
 	. /usr/lib/ddns/dynamic_dns_functions.sh
20
 	. /usr/lib/ddns/dynamic_dns_functions.sh
10
 	start_daemon_for_all_ddns_sections
21
 	start_daemon_for_all_ddns_sections
11
 }
22
 }
12
 
23
 
13
 stop() {
24
 stop() {
14
-	killall -9 dynamic_dns_updater.sh
25
+	killall dynamic_dns_updater.sh
15
 }
26
 }
16
-

+ 470
- 252
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh
File diff suppressed because it is too large
View File


+ 112
- 228
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh View File

10
 # by Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
10
 # by Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
11
 # to support:
11
 # to support:
12
 # - IPv6 DDNS services
12
 # - IPv6 DDNS services
13
-# - DNS Server to retrieve registered IP including TCP transport
13
+# - DNS Server to retrieve registered IP including TCP transport (Ticket 7820)
14
 # - Proxy Server to send out updates
14
 # - Proxy Server to send out updates
15
-# - force_interval=0 to run once
15
+# - force_interval=0 to run once (Luci Ticket 538)
16
 # - the usage of BIND's host command instead of BusyBox's nslookup if installed
16
 # - the usage of BIND's host command instead of BusyBox's nslookup if installed
17
 # - extended Verbose Mode and log file support for better error detection 
17
 # - extended Verbose Mode and log file support for better error detection 
18
+# - wait for interface to fully come up, before the first update is done
18
 #
19
 #
19
 # variables in small chars are read from /etc/config/ddns
20
 # variables in small chars are read from /etc/config/ddns
20
 # variables in big chars are defined inside these scripts as global vars
21
 # variables in big chars are defined inside these scripts as global vars
38
 . /usr/lib/ddns/dynamic_dns_functions.sh	# global vars are also defined here
39
 . /usr/lib/ddns/dynamic_dns_functions.sh	# global vars are also defined here
39
 
40
 
40
 SECTION_ID="$1"
41
 SECTION_ID="$1"
41
-VERBOSE_MODE=${2:-1}	#default mode is log to console
42
+VERBOSE_MODE=${2:-1}	# default mode is log to console
42
 
43
 
43
 # set file names
44
 # set file names
44
 PIDFILE="$RUNDIR/$SECTION_ID.pid"	# Process ID file
45
 PIDFILE="$RUNDIR/$SECTION_ID.pid"	# Process ID file
47
 
48
 
48
 # VERBOSE_MODE > 1 delete logfile if exist to create an empty one
49
 # VERBOSE_MODE > 1 delete logfile if exist to create an empty one
49
 # only with this data of this run for easier diagnostic
50
 # only with this data of this run for easier diagnostic
50
-# new one created by verbose_echo function
51
+# new one created by write_log function
51
 [ $VERBOSE_MODE -gt 1 -a -f $LOGFILE ] && rm -f $LOGFILE
52
 [ $VERBOSE_MODE -gt 1 -a -f $LOGFILE ] && rm -f $LOGFILE
52
 
53
 
54
+# TRAP handler
55
+trap "trap_handler 0 \$?" 0	# handle script exit with exit status
56
+trap "trap_handler 1"  1	# SIGHUP	Hangup / reload config
57
+trap "trap_handler 2"  2	# SIGINT	Terminal interrupt
58
+trap "trap_handler 3"  3	# SIGQUIT	Terminal quit
59
+#trap "trap_handler 9"  9	# SIGKILL	no chance to trap
60
+trap "trap_handler 15" 15	# SIGTERM	Termination
61
+
53
 ################################################################################
62
 ################################################################################
54
 # Leave this comment here, to clearly document variable names that are expected/possible
63
 # Leave this comment here, to clearly document variable names that are expected/possible
55
 # Use load_all_config_options to load config options, which is a much more flexible solution.
64
 # Use load_all_config_options to load config options, which is a much more flexible solution.
56
 #
65
 #
57
 # config_load "ddns"
66
 # config_load "ddns"
58
-# config_get <variable> $SECTION_ID <option]>
67
+# config_get <variable> $SECTION_ID <option>
59
 #
68
 #
60
 # defined options (also used as variable):
69
 # defined options (also used as variable):
61
 # 
70
 # 
108
 [ "$(uci_get ddns $SECTION_ID)" != "service" ] && {
117
 [ "$(uci_get ddns $SECTION_ID)" != "service" ] && {
109
 	[ $VERBOSE_MODE -le 1 ] && VERBOSE_MODE=2	# force console out and logfile output
118
 	[ $VERBOSE_MODE -le 1 ] && VERBOSE_MODE=2	# force console out and logfile output
110
 	[ -f $LOGFILE ] && rm -f $LOGFILE		# clear logfile before first entry
119
 	[ -f $LOGFILE ] && rm -f $LOGFILE		# clear logfile before first entry
111
-	verbose_echo "\n ************** =: ************** ************** **************"
112
-	verbose_echo "       STARTED =: PID '$$' at $(eval $DATE_PROG)"
113
-	verbose_echo "    UCI CONFIG =:\n$(uci -q show ddns | grep '=service' | sort)"
114
-	critical_error "Service '$SECTION_ID' not defined"
120
+	write_log  7 "************ ************** ************** **************"
121
+	write_log  5 "PID '$$' started at $(eval $DATE_PROG)"
122
+	write_log  7 "uci configuration:\n$(uci -q show ddns | grep '=service' | sort)"
123
+	write_log 14 "Service section '$SECTION_ID' not defined"
115
 }
124
 }
116
 load_all_config_options "ddns" "$SECTION_ID"
125
 load_all_config_options "ddns" "$SECTION_ID"
117
 
126
 
118
-verbose_echo "\n ************** =: ************** ************** **************"
119
-verbose_echo "       STARTED =: PID '$$' at $(eval $DATE_PROG)"
127
+write_log  7 "************ ************** ************** **************"
128
+write_log  5 "PID '$$' started at $(eval $DATE_PROG)"
120
 case $VERBOSE_MODE in
129
 case $VERBOSE_MODE in
121
-	0) verbose_echo "  verbose mode =: '0' - run normal, NO console output";;
122
-	1) verbose_echo "  verbose mode =: '1' - run normal, console mode";;
123
-	2) verbose_echo "  verbose mode =: '2' - run once, NO retry on error";;
124
-	3) verbose_echo "  verbose mode =: '3' - run once, NO retry on error, NOT sending update";;
125
-	*) critical_error "ERROR detecting VERBOSE_MODE '$VERBOSE_MODE'"
130
+	0) write_log  7 "verbose mode '0' - run normal, NO console output";;
131
+	1) write_log  7 "verbose mode '1' - run normal, console mode";;
132
+	2) write_log  7 "verbose mode '2' - run once, NO retry on error";;
133
+	3) write_log  7 "verbose mode '3' - run once, NO retry on error, NOT sending update";;
134
+	*) write_log 14 "error detecting VERBOSE_MODE '$VERBOSE_MODE'";;
126
 esac
135
 esac
127
-verbose_echo "    UCI CONFIG =:\n$(uci -q show ddns.$SECTION_ID | sort)"
136
+write_log 7 "uci configuraion:\n$(uci -q show ddns.$SECTION_ID | sort)"
128
 
137
 
129
 # set defaults if not defined
138
 # set defaults if not defined
130
 [ -z "$enabled" ]	  && enabled=0
139
 [ -z "$enabled" ]	  && enabled=0
142
 [ "$ip_source" = "web" -a -z "$ip_url" -a $use_ipv6 -eq 1 ] && ip_url="http://checkipv6.dyndns.com"
151
 [ "$ip_source" = "web" -a -z "$ip_url" -a $use_ipv6 -eq 1 ] && ip_url="http://checkipv6.dyndns.com"
143
 [ "$ip_source" = "interface" -a -z "$ip_interface" ] && ip_interface="eth1"
152
 [ "$ip_source" = "interface" -a -z "$ip_interface" ] && ip_interface="eth1"
144
 
153
 
145
-# check configuration and enabled state
146
-[ -z "$domain" -o -z "$username" -o -z "$password" ] && critical_error "Service Configuration not correctly configured"
147
-[ $enabled -eq 0 ] && critical_error "Service Configuration is disabled"
154
+# check enabled state otherwise we don't need to continue
155
+[ $enabled -eq 0 ] && write_log 14 "Service section disabled!"
156
+
157
+# without domain or username or password we can do nothing for you
158
+[ -z "$domain" -o -z "$username" -o -z "$password" ] && write_log 14 "Service section not correctly configured!"
159
+urlencode URL_USER "$username"	# encode username, might be email or something like this
160
+urlencode URL_PASS "$password"	# encode password, might have special chars for security reason
148
 
161
 
149
-# verify script if configured and executable
162
+# verify ip_source script if configured and executable
150
 if [ "$ip_source" = "script" ]; then
163
 if [ "$ip_source" = "script" ]; then
151
-	[ -z "$ip_script" ] && critical_error "No script defined to detect local IP"
152
-	[ -x "$ip_script" ] || critical_error "Script to detect local IP not found or not executable"
164
+	[ -z "$ip_script" ] && write_log 14 "No script defined to detect local IP!"
165
+	[ -x "$ip_script" ] || write_log 14 "Script to detect local IP not found or not executable!"
153
 fi
166
 fi
154
 
167
 
155
 # compute update interval in seconds
168
 # compute update interval in seconds
156
 get_seconds CHECK_SECONDS ${check_interval:-10} ${check_unit:-"minutes"} # default 10 min
169
 get_seconds CHECK_SECONDS ${check_interval:-10} ${check_unit:-"minutes"} # default 10 min
157
 get_seconds FORCE_SECONDS ${force_interval:-72} ${force_unit:-"hours"}	 # default 3 days
170
 get_seconds FORCE_SECONDS ${force_interval:-72} ${force_unit:-"hours"}	 # default 3 days
158
 get_seconds RETRY_SECONDS ${retry_interval:-60} ${retry_unit:-"seconds"} # default 60 sec
171
 get_seconds RETRY_SECONDS ${retry_interval:-60} ${retry_unit:-"seconds"} # default 60 sec
159
-verbose_echo "check interval =: $CHECK_SECONDS seconds"
160
-verbose_echo "force interval =: $FORCE_SECONDS seconds"
161
-verbose_echo "retry interval =: $RETRY_SECONDS seconds"
162
-verbose_echo " retry counter =: $retry_count times"
172
+[ $CHECK_SECONDS -lt 300 ] && CHECK_SECONDS=300		# minimum 5 minutes
173
+[ $FORCE_SECONDS -gt 0 -a $FORCE_SECONDS -lt $CHECK_SECONDS ] && FORCE_SECONDS=$CHECK_SECONDS	# FORCE_SECONDS >= CHECK_SECONDS or 0
174
+write_log 7 "check interval: $CHECK_SECONDS seconds"
175
+write_log 7 "force interval: $FORCE_SECONDS seconds"
176
+write_log 7 "retry interval: $RETRY_SECONDS seconds"
177
+write_log 7 "retry counter : $retry_count times"
163
 
178
 
164
 # determine what update url we're using if a service_name is supplied
179
 # determine what update url we're using if a service_name is supplied
165
-# otherwise update_url is set inside configuration (custom service)
180
+# otherwise update_url is set inside configuration (custom update url)
166
 # or update_script is set inside configuration (custom update script)
181
 # or update_script is set inside configuration (custom update script)
167
 [ -n "$service_name" ] && get_service_data update_url update_script
182
 [ -n "$service_name" ] && get_service_data update_url update_script
168
-[ -z "$update_url" -a -z "$update_script" ] && critical_error "no update_url found/defined or no update_script found/defined"
169
-[ -n "$update_script" -a ! -f "$update_script" ] && critical_error "custom update_script not found"
183
+[ -z "$update_url" -a -z "$update_script" ] && write_log 14 "No update_url found/defined or no update_script found/defined!"
184
+[ -n "$update_script" -a ! -f "$update_script" ] && write_log 14 "Custom update_script not found!"
170
 
185
 
171
 #kill old process if it exists & set new pid file
186
 #kill old process if it exists & set new pid file
172
 if [ -d $RUNDIR ]; then
187
 if [ -d $RUNDIR ]; then
173
-	#if process is already running, stop it
174
-	if [ -e "$PIDFILE" ]; then
175
-		OLD_PID=$(cat $PIDFILE)
176
-		ps | grep -q "^[\t ]*$OLD_PID" && {
177
-			verbose_echo "   old process =: PID '$OLD_PID'"
178
-			kill $OLD_PID
179
-		} || verbose_echo "old process id =: PID 'none'"
180
-	else
181
-		verbose_echo "old process id =: PID 'none'"
182
-	fi
188
+	#if process for section is already running, stop it
189
+	stop_section_processes "$SECTION_ID"
190
+	[ $? -gt 0 ] && write_log 7 "Send 'SIGTERM' to old process" || write_log 7 "No old process"
183
 else
191
 else
184
 	#make dir since it doesn't exist
192
 	#make dir since it doesn't exist
185
 	mkdir -p $RUNDIR
193
 	mkdir -p $RUNDIR
186
-	verbose_echo "old process id =: PID 'none'"
194
+	write_log 7 "No old process"
187
 fi
195
 fi
188
 echo $$ > $PIDFILE
196
 echo $$ > $PIDFILE
189
 
197
 
201
 	[ $LAST_TIME -gt $CURR_TIME ] && LAST_TIME=0
209
 	[ $LAST_TIME -gt $CURR_TIME ] && LAST_TIME=0
202
 }
210
 }
203
 if [ $LAST_TIME -eq 0 ]; then
211
 if [ $LAST_TIME -eq 0 ]; then
204
-	verbose_echo "   last update =: never"
212
+	write_log 7 "last update: never"
205
 else
213
 else
206
 	EPOCH_TIME=$(( $(date +%s) - CURR_TIME + LAST_TIME ))
214
 	EPOCH_TIME=$(( $(date +%s) - CURR_TIME + LAST_TIME ))
207
 	EPOCH_TIME="date -d @$EPOCH_TIME +'$DATE_FORMAT'"
215
 	EPOCH_TIME="date -d @$EPOCH_TIME +'$DATE_FORMAT'"
208
-	verbose_echo "   last update =: $(eval $EPOCH_TIME)"
216
+	write_log 7 "last update: $(eval $EPOCH_TIME)"
209
 fi
217
 fi
210
 
218
 
211
 # we need time here because hotplug.d is fired by netifd
219
 # we need time here because hotplug.d is fired by netifd
212
 # but IP addresses are not set by DHCP/DHCPv6 etc.
220
 # but IP addresses are not set by DHCP/DHCPv6 etc.
213
-verbose_echo "       waiting =: 10 seconds for interfaces to fully come up"
214
-sleep 10
215
-
216
-# verify DNS server: 
217
-# do with retry's because there might be configurations
218
-# not directly could connect to outside dns when interface is already up
219
-ERR_VERIFY=0	# reset err counter
220
-while [ -n "$dns_server" ]; do
221
-	[ $ERR_VERIFY -eq 0 ] && verbose_echo "******* VERIFY =: DNS server '$dns_server'"
222
-	verify_dns "$dns_server"
223
-	ERR_LAST=$?			# save return value
224
-	[ $ERR_LAST -eq 0 ] && break	# everything ok leave while loop
225
-	ERR_VERIFY=$(( $ERR_VERIFY + 1 ))
226
-	# if error count > retry_count leave here with critical error
227
-	[ $ERR_VERIFY -gt $retry_count ] && {
228
-		case $ERR_LAST in
229
-			2)	critical_error "Invalid DNS server Error: '2' - nslookup can not resolve host";;
230
-			3)	critical_error "Invalid DNS server Error: '3' - nc (netcat) can not connect";;
231
-			*)	critical_error "Invalid DNS server Error: '$ERR_LAST' - unspecific error";;
232
-		esac
233
-	}
234
-	case $ERR_LAST in
235
-		2)	syslog_err "Invalid DNS server Error: '2' - nslookup can not resolve host - retry $ERR_VERIFY/$retry_count in $RETRY_SECONDS seconds\n";;
236
-		3)	syslog_err "Invalid DNS server Error: '3' - nc (netcat) can not connect - retry $ERR_VERIFY/$retry_count in $RETRY_SECONDS seconds\n";;
237
-		*)	syslog_err "Invalid DNS server Error: '$ERR_LAST' - unspecific error - retry $ERR_VERIFY/$retry_count in $RETRY_SECONDS seconds\n";;
238
-	esac
239
-	[ $VERBOSE_MODE -gt 1 ] && {
240
-		# VERBOSE_MODE > 1 then NO retry
241
-		verbose_echo "\n!!!!!!!!! ERROR =: Verbose Mode - NO retry\n"
242
-		break
243
-	}
244
-	verbose_echo "******** RETRY =: DNS server '$dns_server' - retry $ERR_VERIFY/$retry_count in $RETRY_SECONDS seconds"
245
-	sleep $RETRY_SECONDS
246
-done
221
+write_log 7 "Waiting 10 seconds for interfaces to fully come up"
222
+sleep 10 &
223
+PID_SLEEP=$!
224
+wait $PID_SLEEP	# enable trap-handler
225
+PID_SLEEP=0
226
+
227
+# verify DNS server 
228
+[ -n "$dns_server" ] && verify_dns "$dns_server"
247
 
229
 
248
 # verify Proxy server and set environment
230
 # verify Proxy server and set environment
249
-# do with retry's because there might be configurations
250
-# not directly could connect to outside dns when interface is already up
251
-ERR_VERIFY=0	# reset err counter
252
 [ -n "$proxy" ] && {
231
 [ -n "$proxy" ] && {
253
-	[ $ERR_VERIFY -eq 0 ] && verbose_echo "******* VERIFY =: Proxy server 'http://$proxy'"
254
-	verify_proxy "$proxy"
255
-	ERR_LAST=$?			# save return value
256
-	[ $ERR_LAST -eq 0 ] && {
257
-		# everything ok set proxy and leave while loop
232
+	verify_proxy "$proxy" && {
233
+		# everything ok set proxy
258
 		export HTTP_PROXY="http://$proxy"
234
 		export HTTP_PROXY="http://$proxy"
259
 		export HTTPS_PROXY="http://$proxy"
235
 		export HTTPS_PROXY="http://$proxy"
260
 		export http_proxy="http://$proxy"
236
 		export http_proxy="http://$proxy"
261
 		export https_proxy="http://$proxy"
237
 		export https_proxy="http://$proxy"
262
-		break
263
 	}
238
 	}
264
-	ERR_VERIFY=$(( $ERR_VERIFY + 1 ))
265
-	# if error count > retry_count leave here with critical error
266
-	[ $ERR_VERIFY -gt $retry_count ] && {
267
-		case $ERR_LAST in
268
-			2)	critical_error "Invalid Proxy server Error '2' - nslookup can not resolve host";;
269
-			3)	critical_error "Invalid Proxy server Error '3' - nc (netcat) can not connect";;
270
-			*)	critical_error "Invalid Proxy server Error '$ERR_LAST' - unspecific error";;
271
-		esac
272
-	}
273
-	case $ERR_LAST in
274
-		2)	syslog_err "Invalid Proxy server Error '2' - nslookup can not resolve host - retry $ERR_VERIFY/$retry_count in $RETRY_SECONDS seconds\n";;
275
-		3)	syslog_err "Invalid Proxy server Error '3' - nc (netcat) can not connect - retry $ERR_VERIFY/$retry_count in $RETRY_SECONDS seconds\n";;
276
-		*)	syslog_err "Invalid Proxy server Error '$ERR_LAST' - unspecific error - retry $ERR_VERIFY/$retry_count in $RETRY_SECONDS seconds\n";;
277
-	esac
278
-	[ $VERBOSE_MODE -gt 1 ] && {
279
-		# VERBOSE_MODE > 1 then NO retry
280
-		verbose_echo "\n!!!!!!!!! ERROR =: Verbose Mode - NO retry\n"
281
-		break
282
-	}
283
-	verbose_echo "******** RETRY =: Proxy server 'http://$proxy' - retry $ERR_VERIFY/$retry_count in $RETRY_SECONDS seconds"
284
-	sleep $RETRY_SECONDS
285
 }
239
 }
286
 
240
 
287
 # let's check if there is already an IP registered at the web
241
 # let's check if there is already an IP registered at the web
288
 # but ignore errors if not
242
 # but ignore errors if not
289
-verbose_echo "******* DETECT =: Registered IP"
290
-get_registered_ip REGISTERED_IP
243
+get_registered_ip REGISTERED_IP "NO_RETRY"
291
 
244
 
292
 # loop endlessly, checking ip every check_interval and forcing an updating once every force_interval
245
 # loop endlessly, checking ip every check_interval and forcing an updating once every force_interval
293
-# NEW: ### Luci Ticket 538
294
-# a "force_interval" of "0" will run this script only once
295
-# the update is only done once when an interface goes up
296
-# or you run /etc/init.d/ddns start or you can use a cron job
297
-# it will force an update without check when lastupdate happen
298
-# but it will verify after "check_interval" if update is seen in the web 
299
-# and retries on error retry_count times
300
-# CHANGES: ### Ticket 16363
301
-# modified nslookup / sed / grep to detect registered ip
302
-# NEW: ### Ticket 7820
303
-# modified nslookup to support non standard dns_server (needs to be defined in /etc/config/ddns)
304
-# support for BIND host command.
305
-# Wait for interface to fully come up, before the first update is done
306
-verbose_echo "*** START LOOP =: $(eval $DATE_PROG)"
307
-# we run NOT once
308
-[ $FORCE_SECONDS -gt 0 -o $VERBOSE_MODE -le 1 ] && syslog_info "Starting main loop"
309
-
246
+write_log 6 "Starting main loop at $(eval $DATE_PROG)"
310
 while : ; do
247
 while : ; do
311
 
248
 
312
-	# read local IP
313
-	verbose_echo "******* DETECT =: Local IP"
314
-	get_local_ip LOCAL_IP
315
-	ERR_LAST=$?	# save return value
316
-	# Error in function
317
-	[ $ERR_LAST -gt 0 ] && {
318
-		if [ $VERBOSE_MODE -le 1 ]; then	# VERBOSE_MODE <= 1 then retry
319
-			# we can't read local IP
320
-			ERR_LOCAL_IP=$(( $ERR_LOCAL_IP + 1 ))
321
-			[ $ERR_LOCAL_IP -gt $retry_count ] && critical_error "Can not detect local IP"
322
-			verbose_echo "\n!!!!!!!!! ERROR =: detecting local IP - retry $ERR_LOCAL_IP/$retry_count in $RETRY_SECONDS seconds\n"
323
-			syslog_err "Error detecting local IP - retry $ERR_LOCAL_IP/$retry_count in $RETRY_SECONDS seconds"
324
-			sleep $RETRY_SECONDS
325
-			continue	# jump back to the beginning of while loop
326
-		else
327
-			verbose_echo "\n!!!!!!!!! ERROR =: detecting local IP - NO retry\n"
328
-		fi
329
-	}
330
-	ERR_LOCAL_IP=0	# reset err counter
249
+	get_local_ip LOCAL_IP		# read local IP
331
 
250
 
332
 	# prepare update
251
 	# prepare update
333
-	# never updated or forced immediate then NEXT_TIME = 0 
252
+	# never updated or forced immediate then NEXT_TIME = 0
334
 	[ $FORCE_SECONDS -eq 0 -o $LAST_TIME -eq 0 ] \
253
 	[ $FORCE_SECONDS -eq 0 -o $LAST_TIME -eq 0 ] \
335
 		&& NEXT_TIME=0 \
254
 		&& NEXT_TIME=0 \
336
 		|| NEXT_TIME=$(( $LAST_TIME + $FORCE_SECONDS ))
255
 		|| NEXT_TIME=$(( $LAST_TIME + $FORCE_SECONDS ))
337
-	# get current uptime
338
-	get_uptime CURR_TIME
339
-	
340
-	# send update when current time > next time or local ip different from registered ip (as loop on error)
341
-	ERR_SEND=0
342
-	while [ $CURR_TIME -ge $NEXT_TIME -o "$LOCAL_IP" != "$REGISTERED_IP" ]; do
256
+
257
+	get_uptime CURR_TIME		# get current uptime
258
+
259
+	# send update when current time > next time or local ip different from registered ip
260
+	if [ $CURR_TIME -ge $NEXT_TIME -o "$LOCAL_IP" != "$REGISTERED_IP" ]; then
343
 		if [ $VERBOSE_MODE -gt 2 ]; then
261
 		if [ $VERBOSE_MODE -gt 2 ]; then
344
-			verbose_echo "  VERBOSE MODE =: NO UPDATE send to DDNS provider"
262
+			write_log 7 "Verbose Mode: $VERBOSE_MODE - NO UPDATE send"
345
 		elif [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
263
 		elif [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
346
-			verbose_echo "******* UPDATE =: LOCAL: '$LOCAL_IP' <> REGISTERED: '$REGISTERED_IP'"
264
+			write_log 7 "Update needed - L: '$LOCAL_IP' <> R: '$REGISTERED_IP'"
347
 		else
265
 		else
348
-			verbose_echo "******* FORCED =: LOCAL: '$LOCAL_IP' == REGISTERED: '$REGISTERED_IP'"
266
+			write_log 7 "Forced Update - L: '$LOCAL_IP' == R: '$REGISTERED_IP'"
349
 		fi
267
 		fi
350
-		# only send if VERBOSE_MODE < 3
268
+
351
 		ERR_LAST=0
269
 		ERR_LAST=0
352
 		[ $VERBOSE_MODE -lt 3 ] && {
270
 		[ $VERBOSE_MODE -lt 3 ] && {
353
-			send_update "$LOCAL_IP" 
271
+			# only send if VERBOSE_MODE < 3
272
+			send_update "$LOCAL_IP"
354
 			ERR_LAST=$?	# save return value
273
 			ERR_LAST=$?	# save return value
355
 		}
274
 		}
356
 
275
 
357
-		# Error in function 
358
-		if [ $ERR_LAST -gt 0 ]; then
359
-			if [ $VERBOSE_MODE -le 1 ]; then	# VERBOSE_MODE <=1 then retry
360
-				# error sending local IP
361
-				ERR_SEND=$(( $ERR_SEND + 1 ))
362
-				[ $ERR_SEND -gt $retry_count ] && critical_error "can not send update to DDNS Provider"
363
-				verbose_echo "\n!!!!!!!!! ERROR =: sending update - retry $ERR_SEND/$retry_count in $RETRY_SECONDS seconds\n"
364
-				syslog_err "Error sending update - retry $ERR_SEND/$retry_count in $RETRY_SECONDS seconds"
365
-				sleep $RETRY_SECONDS
366
-				continue # re-loop
367
-			else
368
-				verbose_echo "\n!!!!!!!!! ERROR =: sending update to DDNS service - NO retry\n"
369
-				break
370
-			fi
371
-		else
372
-			# we send data so save "last time"
373
-			get_uptime LAST_TIME
276
+		# error sending local IP to provider 
277
+		# we have no communication error (handled inside send_update/do_transfer)
278
+		# but update was not recognized
279
+		# do NOT retry after RETRY_SECONDS, do retry after CHECK_SECONDS
280
+		# to early retrys will block most DDNS provider
281
+		# providers answer is checked inside send_update() function
282
+		[ $ERR_LAST -eq 0 ] && {
283
+			get_uptime LAST_TIME		# we send update, so
374
 			echo $LAST_TIME > $UPDFILE	# save LASTTIME to file
284
 			echo $LAST_TIME > $UPDFILE	# save LASTTIME to file
375
 			[ "$LOCAL_IP" != "$REGISTERED_IP" ] \
285
 			[ "$LOCAL_IP" != "$REGISTERED_IP" ] \
376
-				&& syslog_notice "Changed IP: '$LOCAL_IP' successfully send" \
377
-				|| syslog_notice "Forced Update: IP: '$LOCAL_IP' successfully send"
378
-			break # leave while
379
-		fi
380
-	done
286
+				&& write_log 6 "Update successful - IP '$LOCAL_IP' send" \
287
+				|| write_log 6 "Forced update successful - IP: '$LOCAL_IP' send"
288
+		} || write_log 3 "Can not update IP at DDNS Provider"
289
+	fi
381
 
290
 
382
 	# now we wait for check interval before testing if update was recognized
291
 	# now we wait for check interval before testing if update was recognized
383
-	# only sleep if VERBOSE_MODE <= 2 because nothing send so do not wait
292
+	# only sleep if VERBOSE_MODE <= 2 because otherwise nothing was send
384
 	[ $VERBOSE_MODE -le 2 ] && {
293
 	[ $VERBOSE_MODE -le 2 ] && {
385
-		verbose_echo "****** WAITING =: $CHECK_SECONDS seconds (Check Interval) before continue"
386
-		sleep $CHECK_SECONDS
387
-	} || verbose_echo "  VERBOSE MODE =: NO WAITING for Check Interval\n"
388
-
389
-	# read at DDNS service registered IP (in loop on error)
390
-	REGISTERED_IP=""
391
-	ERR_REG_IP=0
392
-	while : ; do
393
-		verbose_echo "******* DETECT =: Registered IP"
394
-		get_registered_ip REGISTERED_IP
395
-		ERR_LAST=$?	# save return value
396
-
397
-		# No Error in function we leave while loop
398
-		[ $ERR_LAST -eq 0  ] && break
399
-
400
-		# we can't read Registered IP
401
-		if [ $VERBOSE_MODE -le 1 ]; then	# VERBOSE_MODE <=1 then retry
402
-			ERR_REG_IP=$(( $ERR_REG_IP + 1 ))
403
-			[ $ERR_REG_IP -gt $retry_count ] && critical_error "can not detect registered local IP"
404
-			verbose_echo "\n!!!!!!!!! ERROR =: detecting Registered IP - retry $ERR_REG_IP/$retry_count in $RETRY_SECONDS seconds\n"
405
-			syslog_err "Error detecting Registered IP - retry $ERR_REG_IP/$retry_count in $RETRY_SECONDS seconds"
406
-			sleep $RETRY_SECONDS
407
-		else
408
-			verbose_echo "\n!!!!!!!!! ERROR =: detecting Registered IP - NO retry\n"
409
-			break	# leave while loop
410
-		fi
411
-	done
294
+		write_log 7 "Waiting $CHECK_SECONDS seconds (Check Interval)"
295
+		sleep $CHECK_SECONDS &
296
+		PID_SLEEP=$!
297
+		wait $PID_SLEEP	# enable trap-handler
298
+		PID_SLEEP=0
299
+	} || write_log 7 "Verbose Mode: $VERBOSE_MODE - NO Check Interval waiting"
300
+
301
+	REGISTERED_IP=""		# clear variable
302
+	get_registered_ip REGISTERED_IP	# get registered/public IP
412
 
303
 
413
 	# IP's are still different
304
 	# IP's are still different
414
 	if [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
305
 	if [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
415
 		if [ $VERBOSE_MODE -le 1 ]; then	# VERBOSE_MODE <=1 then retry
306
 		if [ $VERBOSE_MODE -le 1 ]; then	# VERBOSE_MODE <=1 then retry
416
 			ERR_UPDATE=$(( $ERR_UPDATE + 1 ))
307
 			ERR_UPDATE=$(( $ERR_UPDATE + 1 ))
417
-			[ $ERR_UPDATE -gt $retry_count ] && critical_error "Registered IP <> Local IP - LocalIP: '$LOCAL_IP' - RegisteredIP: '$REGISTERED_IP'"
418
-			verbose_echo "\n!!!!!!!!! ERROR =: Registered IP <> Local IP - starting retry $ERR_UPDATE/$retry_count\n"
419
-			syslog_warn "Warning: Registered IP <> Local IP - starting retry $ERR_UPDATE/$retry_count"
308
+			[ $ERR_UPDATE -gt $retry_count ] && write_log 14 "Updating IP at DDNS provider failed after $retry_count retries"
309
+			write_log 4 "Updating IP at DDNS provider failed - starting retry $ERR_UPDATE/$retry_count"
420
 			continue # loop to beginning
310
 			continue # loop to beginning
421
 		else
311
 		else
422
-			verbose_echo "\n!!!!!!!!! ERROR =: Registered IP <> Local IP - LocalIP: '$LOCAL_IP' - RegisteredIP: '$REGISTERED_IP' - NO retry\n"
312
+			write_log 4 "Updating IP at DDNS provider failed"
313
+			write_log 7 "Verbose Mode: $VERBOSE_MODE - NO retry"; exit 1
423
 		fi
314
 		fi
424
-	fi		
425
-
426
-	# we checked successful the last update
427
-	ERR_UPDATE=0			# reset error counter
315
+	else
316
+		# we checked successful the last update
317
+		ERR_UPDATE=0			# reset error counter
318
+	fi
428
 
319
 
429
-	# force_update=0 or VERBOSE_MODE > 1 - leave the main loop
430
-	[ $FORCE_SECONDS -eq 0 -o $VERBOSE_MODE -gt 1 ] && {
431
-		verbose_echo "****** LEAVING =: $(eval $DATE_PROG)"
432
-		syslog_info "Leaving"
433
-		break
434
-	}
435
-	verbose_echo "********* LOOP =: $(eval $DATE_PROG)"
436
-	syslog_info "Rerun IP check"
320
+	# force_update=0 or VERBOSE_MODE > 1 - leave here
321
+	[ $VERBOSE_MODE -gt 1 ]  && write_log 7 "Verbose Mode: $VERBOSE_MODE - NO reloop"; exit 0
322
+	[ $FORCE_SECONDS -eq 0 ] && write_log 6 "Configured to run once"; exit 0
323
+	write_log 6 "Rerun IP check at $(eval $DATE_PROG)"
437
 done
324
 done
438
-
439
-verbose_echo "****** STOPPED =: PID '$$' at $(eval $DATE_PROG)\n"
440
-syslog_info "Done"
441
-
442
-exit 0
325
+# we should never come here there must be a programming error
326
+write_log 12 "Error in 'dynamic_dns_updater.sh - program coding error"

+ 35
- 23
net/ddns-scripts/files/usr/lib/ddns/services View File

1
-# This file contains the update urls for various dynamic dns services.
2
-# Column one contains the service name, column two contains the update url.
3
-# within the update url there are 4 variables you can use: [USERNAME], 
4
-# [PASSWORD], [DOMAIN] and [IP].  These are substituted for the username, 
5
-# password, and domain name specified in the /etc/config/ddns file when an 
6
-# update is performed.  The IP is substituted for the current ip address of the
7
-# router.  These variables are case sensitive, while urls generally are not, so 
8
-# if you need to enter the same text in the url (which seems very unlikely) put 
9
-# that text in lowercase, while the variables should remain in uppercase
1
+#444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
2
+#4
3
+#4 This file contains the update urls for various dynamic dns services.
4
+#4 Column one contains the service name, column two contains the update url.
5
+#4 within the update url there are 4 variables you can use: [USERNAME], 
6
+#4 [PASSWORD], [DOMAIN] and [IP].  These are substituted for the username, 
7
+#4 password, and domain name specified in the /etc/config/ddns file when an 
8
+#4 update is performed.  The IP is substituted for the current ip address of the
9
+#4 router.  These variables are case sensitive, while urls generally are not, so 
10
+#4 if you need to enter the same text in the url (which seems very unlikely) put 
11
+#4 that text in lowercase, while the variables should remain in uppercase
12
+#4
13
+#4 There are TONS of dynamic dns services out there. There's a huge list of them at:
14
+#4 http://www.dmoz.org/Computers/Software/Internet/Servers/Address_Management/Dynamic_DNS_Services/
15
+#4 If anyone has time they could update this file to be compatible with a bunch of them
16
+#4
17
+#4 !!! Since ddns-scripts Version 2.x the update of IPv6 addresses is also supported
18
+#4 !!! This file is used for update of IPv4 adresses only. For IPv6 use services_ipv6
19
+#4 
20
+#4 !!! Since ddns-scripts Version 2.x the update via provider specific update scripts is supported. 
21
+#4 !!! This scripts must be located at /usr/lib/ddns directory if defined inside this file.
22
+#4 !!! Use only the script name (without path). Sample: 
23
+#4 !!! "example.com"	"update_sample.sh"
24
+#4
25
+#444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
10
 
26
 
11
 "dyndns.org"		"http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]"
27
 "dyndns.org"		"http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]"
12
 "changeip.com"		"http://[USERNAME]:[PASSWORD]@nic.changeip.com/nic/update?u=[USERNAME]&p=[PASSWORD]&cmd=update&hostname=[DOMAIN]&ip=[IP]"
28
 "changeip.com"		"http://[USERNAME]:[PASSWORD]@nic.changeip.com/nic/update?u=[USERNAME]&p=[PASSWORD]&cmd=update&hostname=[DOMAIN]&ip=[IP]"
13
 "zoneedit.com"		"http://[USERNAME]:[PASSWORD]@dynamic.zoneedit.com/auth/dynamic.html?host=[DOMAIN]&dnsto=[IP]"
29
 "zoneedit.com"		"http://[USERNAME]:[PASSWORD]@dynamic.zoneedit.com/auth/dynamic.html?host=[DOMAIN]&dnsto=[IP]"
14
 "free.editdns.net"	"http://dyndns-free.editdns.net/api/dynLinux.php?p=[PASSWORD]&r=[DOMAIN]"
30
 "free.editdns.net"	"http://dyndns-free.editdns.net/api/dynLinux.php?p=[PASSWORD]&r=[DOMAIN]"
15
 
31
 
16
-#noip is an alias of no-ip, so allow both names for the same service
17
-"no-ip.com"		"http://[USERNAME]:[PASSWORD]@dynupdate.no-ip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
18
-"noip.com"		"http://[USERNAME]:[PASSWORD]@dynupdate.no-ip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
32
+# noip is an alias of no-ip, so allow both names for the same service
33
+# use provider specific update script
34
+"no-ip.com"	"update_no-ip.sh"
35
+"noip.com"	"update_no-ip.sh"
19
 
36
 
20
 #freedns.afraid.org is weird, you just need an update code, for which we use the password variable
37
 #freedns.afraid.org is weird, you just need an update code, for which we use the password variable
21
 "freedns.afraid.org"	"http://freedns.afraid.org/dynamic/update.php?[PASSWORD]&address=[IP]"
38
 "freedns.afraid.org"	"http://freedns.afraid.org/dynamic/update.php?[PASSWORD]&address=[IP]"
22
 
39
 
23
-#### ADD YOURS HERE! ######################################################################################
24
-#                                                                                                         #
25
-# There are TONS of dynamic dns services out there. There's a huge list of them at:                       #
26
-# http://www.dmoz.org/Computers/Software/Internet/Servers/Address_Management/Dynamic_DNS_Services/        #
27
-# If anyone has time they could update this file to be compatible with a bunch of them                    #
28
-#                                                                                                         #
29
-###########################################################################################################
30
-
31
 # DNS Max and resellers' update urls
40
 # DNS Max and resellers' update urls
32
 "dnsmax.com"	"http://update.dnsmax.com/update/?username=[USERNAME]&password=[PASSWORD]&resellerid=1&clientname=openwrt&clientversion=8.09&protocolversion=2.0&updatehostname=[DOMAIN]&ip=[IP]"
41
 "dnsmax.com"	"http://update.dnsmax.com/update/?username=[USERNAME]&password=[PASSWORD]&resellerid=1&clientname=openwrt&clientversion=8.09&protocolversion=2.0&updatehostname=[DOMAIN]&ip=[IP]"
33
 "thatip.com"	"http://update.dnsmax.com/update/?username=[USERNAME]&password=[PASSWORD]&resellerid=2&clientname=openwrt&clientversion=8.09&protocolversion=2.0&updatehostname=[DOMAIN]&ip=[IP]"
42
 "thatip.com"	"http://update.dnsmax.com/update/?username=[USERNAME]&password=[PASSWORD]&resellerid=2&clientname=openwrt&clientversion=8.09&protocolversion=2.0&updatehostname=[DOMAIN]&ip=[IP]"
34
 
43
 
35
 # Hurricane Electric Dynamic DNS
44
 # Hurricane Electric Dynamic DNS
36
-"he.net"		"http://[DOMAIN]:[PASSWORD]@dyn.dns.he.net/nic/update?hostname=[DOMAIN]&myip=[IP]" 
45
+"he.net"	"http://[DOMAIN]:[PASSWORD]@dyn.dns.he.net/nic/update?hostname=[DOMAIN]&myip=[IP]" 
37
 
46
 
38
 # DNSdynamic.org
47
 # DNSdynamic.org
39
 "dnsdynamic.org"	"http://[USERNAME]:[PASSWORD]@www.dnsdynamic.org/api/?hostname=[DOMAIN]&myip=[IP]"
48
 "dnsdynamic.org"	"http://[USERNAME]:[PASSWORD]@www.dnsdynamic.org/api/?hostname=[DOMAIN]&myip=[IP]"
40
 
49
 
41
 # dnsExit.com free dynamic DNS update url
50
 # dnsExit.com free dynamic DNS update url
42
-"dnsexit.com"		"http://www.dnsexit.com/RemoteUpdate.sv?login=[USERNAME]&password=[PASSWORD]&host=[DOMAIN]&myip=[IP]"
51
+"dnsexit.com"	"http://www.dnsexit.com/RemoteUpdate.sv?login=[USERNAME]&password=[PASSWORD]&host=[DOMAIN]&myip=[IP]"
43
 
52
 
44
 # OVH
53
 # OVH
45
 "ovh.com" "http://[USERNAME]:[PASSWORD]@www.ovh.com/nic/update?system=dyndns&hostname=[DOMAIN]&myip=[IP]"
54
 "ovh.com" "http://[USERNAME]:[PASSWORD]@www.ovh.com/nic/update?system=dyndns&hostname=[DOMAIN]&myip=[IP]"
56
 "namecheap.com" "http://dynamicdns.park-your-domain.com/update?host=[USERNAME]&domain=[DOMAIN]&password=[PASSWORD]&ip=[IP]"
65
 "namecheap.com" "http://dynamicdns.park-your-domain.com/update?host=[USERNAME]&domain=[DOMAIN]&password=[PASSWORD]&ip=[IP]"
57
 
66
 
58
 # easydns.com dynamic DNS
67
 # easydns.com dynamic DNS
59
-"easydns.com"		"http://[USERNAME]:[PASSWORD]@api.cp.easydns.com/dyn/tomato.php?hostname=[DOMAIN]&myip=[IP]"
68
+"easydns.com"	"http://[USERNAME]:[PASSWORD]@api.cp.easydns.com/dyn/tomato.php?hostname=[DOMAIN]&myip=[IP]"
60
 
69
 
61
 # Winco DDNS
70
 # Winco DDNS
62
 "ddns.com.br"	"http://[DOMAIN]:[PASSWORD]@members.ddns.com.br/nic/update?hostname=[DOMAIN]&myip=[IP]"
71
 "ddns.com.br"	"http://[DOMAIN]:[PASSWORD]@members.ddns.com.br/nic/update?hostname=[DOMAIN]&myip=[IP]"
75
 
84
 
76
 # MyDNS.JP
85
 # MyDNS.JP
77
 "mydns.jp"	"http://www.mydns.jp/directip.html?MID=[USERNAME]&PWD=[PASSWORD]&IPV4ADDR=[IP]"
86
 "mydns.jp"	"http://www.mydns.jp/directip.html?MID=[USERNAME]&PWD=[PASSWORD]&IPV4ADDR=[IP]"
87
+
88
+# LoopiaDNS
89
+"loopia.se" "http://[USERNAME]:[PASSWORD]@dns.loopia.se/XDynDNSServer/XDynDNS.php?system=custom&hostname=[DOMAIN]&myip=[IP]"

+ 28
- 26
net/ddns-scripts/files/usr/lib/ddns/services_ipv6 View File

1
-# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
-# !!!!! IPv6 Version of original services file			!!!!!
3
-# !!!!! funtionally and syntax is the same			!!!!!
4
-# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5
-# This file contains the update urls for various dynamic dns services.
6
-# Column one contains the service name, column two contains the update url.
7
-# within the update url there are 4 variables you can use: [USERNAME], 
8
-# [PASSWORD], [DOMAIN] and [IP].  These are substituted for the username, 
9
-# password, and domain name specified in the /etc/config/ddns file when an 
10
-# update is performed.  The IP is substituted for the current ip address of the
11
-# router.  These variables are case sensitive, while urls generally are not, so 
12
-# if you need to enter the same text in the url (which seems very unlikely) put 
13
-# that text in lowercase, while the variables should remain in uppercase
1
+#666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
2
+#6
3
+#6 This file contains the update urls for various dynamic dns services.
4
+#6 Column one contains the service name, column two contains the update url.
5
+#6 within the update url there are 4 variables you can use: [USERNAME], 
6
+#6 [PASSWORD], [DOMAIN] and [IP].  These are substituted for the username, 
7
+#6 password, and domain name specified in the /etc/config/ddns file when an 
8
+#6 update is performed.  The IP is substituted for the current ip address of the
9
+#6 router.  These variables are case sensitive, while urls generally are not, so 
10
+#6 if you need to enter the same text in the url (which seems very unlikely) put 
11
+#6 that text in lowercase, while the variables should remain in uppercase
12
+#6
13
+#6 There are TONS of dynamic dns services out there. There's a huge list of them at:
14
+#6 http://www.dmoz.org/Computers/Software/Internet/Servers/Address_Management/Dynamic_DNS_Services/
15
+#6 If anyone has time they could update this file to be compatible with a bunch of them
16
+#6
17
+#6 !!! Since ddns-scripts Version 2.x the update of IPv6 addresses is also supported
18
+#6 !!! This file is used for update of IPv6 adresses only. For IPv4 use services
19
+#6 
20
+#6 !!! Since ddns-scripts Version 2.x the update via provider specific update scripts is supported. 
21
+#6 !!! This scripts must be located at /usr/lib/ddns directory if defined inside this file.
22
+#6 !!! Use only the script name (without path). Sample:
23
+#6 !!! "example.com"	"update_sample.sh"
24
+#6
25
+#666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
14
 
26
 
15
-# tested with
16
-
17
-# Securepoint Dynamic-DNS-Service
27
+#IPv6 @ Securepoint Dynamic-DNS-Service
18
 "spdns.de"	"http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
28
 "spdns.de"	"http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
19
 
29
 
20
-# Hurricane Electric Dynamic DNS
30
+#IPv6 @ Hurricane Electric Dynamic DNS
21
 "he.net"	"http://[DOMAIN]:[PASSWORD]@dyn.dns.he.net/nic/update?hostname=[DOMAIN]&myip=[IP]" 
31
 "he.net"	"http://[DOMAIN]:[PASSWORD]@dyn.dns.he.net/nic/update?hostname=[DOMAIN]&myip=[IP]" 
22
 
32
 
23
-#### ADD YOURS HERE! ######################################################################################
24
-#                                                                                                         #
25
-# There are TONS of dynamic dns services out there. There's a huge list of them at:                       #
26
-# http://www.dmoz.org/Computers/Software/Internet/Servers/Address_Management/Dynamic_DNS_Services/        #
27
-# If anyone has time they could update this file to be compatible with a bunch of them                    #
28
-#                                                                                                         #
29
-###########################################################################################################
30
-
31
-# MyDNS.JP
33
+#IPv6 @ MyDNS.JP
32
 "mydns.jp"	"http://www.mydns.jp/directip.html?MID=[USERNAME]&PWD=[PASSWORD]&IPV6ADDR=[IP]"
34
 "mydns.jp"	"http://www.mydns.jp/directip.html?MID=[USERNAME]&PWD=[PASSWORD]&IPV6ADDR=[IP]"

+ 47
- 0
net/ddns-scripts/files/usr/lib/ddns/update_no-ip.sh View File

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
+

+ 12
- 12
net/ddns-scripts/files/usr/lib/ddns/update_sample.sh View File

16
 #
16
 #
17
 # the code here is the copy of the default used inside send_update()
17
 # the code here is the copy of the default used inside send_update()
18
 #
18
 #
19
-local __USER __PASS __ANSWER
19
+local __ANSWER
20
 # tested with spdns.de
20
 # tested with spdns.de
21
 local __URL="http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
21
 local __URL="http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
22
 
22
 
23
 # do replaces in URL
23
 # do replaces in URL
24
-__urlencode __USER "$username"	# encode username, might be email or something like this
25
-__urlencode __PASS "$password"	# encode password, might have special chars for security reason
26
-__URL=$(echo $__URL | sed -e "s#\[USERNAME\]#$__USER#g" -e "s#\[PASSWORD\]#$__PASS#g" \
24
+__URL=$(echo $__URL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
27
 			       -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
25
 			       -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
28
 [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
26
 [ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
29
 
27
 
30
-__do_transfer __ANSWER "$__URL"
31
-__ERR=$?
32
-[ $__ERR -gt 0 ] && {
33
-	verbose_echo "\n!!!!!!!!! ERROR =: Error sending update to DDNS Provider\n"
34
-	return 1
35
-}
36
-verbose_echo "   update send =: DDNS Provider answered\n$__ANSWER"
37
-return 0
28
+do_transfer __ANSWER "$__URL" || return 1
29
+
30
+write_log 7 "DDNS Provider answered:\n$__ANSWER"
31
+
32
+# analyse provider answers
33
+# "good [IP_ADR]"	= successful
34
+# "nochg [IP_ADR]"	= no change but OK
35
+echo "$__ANSWER" | grep -E "good|nochg" >/dev/null 2>&1
36
+return $?	# "0" if "good" or "nochg" found
37
+