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

@@ -0,0 +1,84 @@
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,8 +1,8 @@
1 1
 include $(TOPDIR)/rules.mk
2 2
 
3 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 6
 PKG_LICENSE:=GPL-2.0
7 7
 
8 8
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
@@ -62,7 +62,10 @@ endef
62 62
 define Package/ddns-scripts/postinst
63 63
 	#!/bin/sh
64 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 70
 	# add new section "ddns" "global" if not exists
68 71
 	uci -q get ddns.global > /dev/null || uci -q set ddns.global='ddns'
@@ -79,7 +82,7 @@ endef
79 82
 define Package/ddns-scripts/prerm
80 83
 	#!/bin/sh
81 84
 	# if run within buildroot exit
82
-	[ -n "${IPKG_INSTROOT}" ] && exit 0
85
+	[ -n "$${IPKG_INSTROOT}" ] && exit 0
83 86
 
84 87
 	# stop running scripts
85 88
 	/etc/init.d/ddns disable

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

@@ -1,5 +1,6 @@
1 1
 #
2 2
 # Please read ddns.sample
3
+# or http://wiki.openwrt.org/doc/uci/ddns
3 4
 #
4 5
 config ddns "global"
5 6
 	option date_format "%F %R"
@@ -9,8 +10,8 @@ config ddns "global"
9 10
 
10 11
 
11 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 15
 	option username		"your_username"
15 16
 	option password		"your_password"
16 17
 	option interface	"wan"

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

@@ -127,7 +127,7 @@ config service "myddns"
127 127
 	###########
128 128
 	# use HTTPS for secure communication with you DDNS provider
129 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 131
 	# It's modified by the scripts themselves
132 132
 	# Needs GNU Wget (with SSL support) or cURL to be installed.
133 133
 	# default: "0"	do not use HTTPS
@@ -139,8 +139,8 @@ config service "myddns"
139 139
 	# the transfer program can find them. (might need package CA-certificates)
140 140
 	# if you don't want to verify servers certificate (insecure) you should
141 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 146
 	# for logging and control if everything work fine you can get information inside
@@ -210,11 +210,10 @@ config service "myddns"
210 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 214
 	# local defined name lookup policies (i.e. /etc/resolve.conf etc.)
215 215
 	# Specify here a DNS server to use instead of the defaults.
216 216
 	# you can use hostname or ip address
217
-	# IPv6 address must be in squared brackets "[...]"
218 217
 	# i.e. "google-public-dns-a.google.com"
219 218
 	# default: none
220 219
 #	option dns_server "google-public-dns-a.google.com"
@@ -236,6 +235,7 @@ config service "myddns"
236 235
 	# ip_source='web' (see above) because this request is also 
237 236
 	# send via the configured proxy !!!
238 237
 	# Syntax: [user:password@]proxy:port !port is required !
238
+	# IPv6 address must be in squared brackets "[...]"
239 239
 	# default: none
240 240
 #	option proxy ''
241 241
 
@@ -247,7 +247,7 @@ config service "myddns"
247 247
 	# wait this time before verify if update was successful send.
248 248
 	# !!! checks below 5 minutes make no sense because the Internet 
249 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 251
 	# minimum 5 minutes == 300 seconds
252 252
 	# default 10 minutes
253 253
 	option check_interval	'10'
@@ -256,7 +256,7 @@ config service "myddns"
256 256
 	###########
257 257
 	# force to send an update to service provider, if no change was detected.
258 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 260
 	# minimum needs to be greater or equal check interval (see above)
261 261
 	# A special setting of '0' is allowed, which forces the script to run once.
262 262
 	# It sends an update, verify if update was accepted by DNS 
@@ -276,7 +276,7 @@ config service "myddns"
276 276
 	# if error happen on detecting, sending or updating the
277 277
 	# script will retry the relevant action.
278 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 280
 	# default: 60 seconds
281 281
 	option retry_interval	'60'
282 282
 	option retry_unit	'seconds'

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

@@ -1,8 +1,14 @@
1 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,16 +1,26 @@
1 1
 #!/bin/sh /etc/rc.common
2 2
 START=95
3
+STOP=10
3 4
 
4 5
 boot() {
5 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 19
 start() {
9 20
 	. /usr/lib/ddns/dynamic_dns_functions.sh
10 21
 	start_daemon_for_all_ddns_sections
11 22
 }
12 23
 
13 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,11 +10,12 @@
10 10
 # by Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
11 11
 # to support:
12 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 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 16
 # - the usage of BIND's host command instead of BusyBox's nslookup if installed
17 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 20
 # variables in small chars are read from /etc/config/ddns
20 21
 # variables in big chars are defined inside these scripts as global vars
@@ -38,7 +39,7 @@
38 39
 . /usr/lib/ddns/dynamic_dns_functions.sh	# global vars are also defined here
39 40
 
40 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 44
 # set file names
44 45
 PIDFILE="$RUNDIR/$SECTION_ID.pid"	# Process ID file
@@ -47,15 +48,23 @@ LOGFILE="$LOGDIR/$SECTION_ID.log"	# log file
47 48
 
48 49
 # VERBOSE_MODE > 1 delete logfile if exist to create an empty one
49 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 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 63
 # Leave this comment here, to clearly document variable names that are expected/possible
55 64
 # Use load_all_config_options to load config options, which is a much more flexible solution.
56 65
 #
57 66
 # config_load "ddns"
58
-# config_get <variable> $SECTION_ID <option]>
67
+# config_get <variable> $SECTION_ID <option>
59 68
 #
60 69
 # defined options (also used as variable):
61 70
 # 
@@ -108,23 +117,23 @@ LOGFILE="$LOGDIR/$SECTION_ID.log"	# log file
108 117
 [ "$(uci_get ddns $SECTION_ID)" != "service" ] && {
109 118
 	[ $VERBOSE_MODE -le 1 ] && VERBOSE_MODE=2	# force console out and logfile output
110 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 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 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 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 138
 # set defaults if not defined
130 139
 [ -z "$enabled" ]	  && enabled=0
@@ -142,48 +151,47 @@ verbose_echo "    UCI CONFIG =:\n$(uci -q show ddns.$SECTION_ID | sort)"
142 151
 [ "$ip_source" = "web" -a -z "$ip_url" -a $use_ipv6 -eq 1 ] && ip_url="http://checkipv6.dyndns.com"
143 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 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 166
 fi
154 167
 
155 168
 # compute update interval in seconds
156 169
 get_seconds CHECK_SECONDS ${check_interval:-10} ${check_unit:-"minutes"} # default 10 min
157 170
 get_seconds FORCE_SECONDS ${force_interval:-72} ${force_unit:-"hours"}	 # default 3 days
158 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 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 181
 # or update_script is set inside configuration (custom update script)
167 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 186
 #kill old process if it exists & set new pid file
172 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 191
 else
184 192
 	#make dir since it doesn't exist
185 193
 	mkdir -p $RUNDIR
186
-	verbose_echo "old process id =: PID 'none'"
194
+	write_log 7 "No old process"
187 195
 fi
188 196
 echo $$ > $PIDFILE
189 197
 
@@ -201,242 +209,118 @@ get_uptime CURR_TIME
201 209
 	[ $LAST_TIME -gt $CURR_TIME ] && LAST_TIME=0
202 210
 }
203 211
 if [ $LAST_TIME -eq 0 ]; then
204
-	verbose_echo "   last update =: never"
212
+	write_log 7 "last update: never"
205 213
 else
206 214
 	EPOCH_TIME=$(( $(date +%s) - CURR_TIME + LAST_TIME ))
207 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 217
 fi
210 218
 
211 219
 # we need time here because hotplug.d is fired by netifd
212 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 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 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 234
 		export HTTP_PROXY="http://$proxy"
259 235
 		export HTTPS_PROXY="http://$proxy"
260 236
 		export http_proxy="http://$proxy"
261 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 241
 # let's check if there is already an IP registered at the web
288 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 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 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 251
 	# prepare update
333
-	# never updated or forced immediate then NEXT_TIME = 0 
252
+	# never updated or forced immediate then NEXT_TIME = 0
334 253
 	[ $FORCE_SECONDS -eq 0 -o $LAST_TIME -eq 0 ] \
335 254
 		&& NEXT_TIME=0 \
336 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 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 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 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 267
 		fi
350
-		# only send if VERBOSE_MODE < 3
268
+
351 269
 		ERR_LAST=0
352 270
 		[ $VERBOSE_MODE -lt 3 ] && {
353
-			send_update "$LOCAL_IP" 
271
+			# only send if VERBOSE_MODE < 3
272
+			send_update "$LOCAL_IP"
354 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 284
 			echo $LAST_TIME > $UPDFILE	# save LASTTIME to file
375 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 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 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 304
 	# IP's are still different
414 305
 	if [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
415 306
 		if [ $VERBOSE_MODE -le 1 ]; then	# VERBOSE_MODE <=1 then retry
416 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 310
 			continue # loop to beginning
421 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 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 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,45 +1,54 @@
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 27
 "dyndns.org"		"http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]"
12 28
 "changeip.com"		"http://[USERNAME]:[PASSWORD]@nic.changeip.com/nic/update?u=[USERNAME]&p=[PASSWORD]&cmd=update&hostname=[DOMAIN]&ip=[IP]"
13 29
 "zoneedit.com"		"http://[USERNAME]:[PASSWORD]@dynamic.zoneedit.com/auth/dynamic.html?host=[DOMAIN]&dnsto=[IP]"
14 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 37
 #freedns.afraid.org is weird, you just need an update code, for which we use the password variable
21 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 40
 # DNS Max and resellers' update urls
32 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 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 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 47
 # DNSdynamic.org
39 48
 "dnsdynamic.org"	"http://[USERNAME]:[PASSWORD]@www.dnsdynamic.org/api/?hostname=[DOMAIN]&myip=[IP]"
40 49
 
41 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 53
 # OVH
45 54
 "ovh.com" "http://[USERNAME]:[PASSWORD]@www.ovh.com/nic/update?system=dyndns&hostname=[DOMAIN]&myip=[IP]"
@@ -56,7 +65,7 @@
56 65
 "namecheap.com" "http://dynamicdns.park-your-domain.com/update?host=[USERNAME]&domain=[DOMAIN]&password=[PASSWORD]&ip=[IP]"
57 66
 
58 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 70
 # Winco DDNS
62 71
 "ddns.com.br"	"http://[DOMAIN]:[PASSWORD]@members.ddns.com.br/nic/update?hostname=[DOMAIN]&myip=[IP]"
@@ -75,3 +84,6 @@
75 84
 
76 85
 # MyDNS.JP
77 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,32 +1,34 @@
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 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 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 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

@@ -0,0 +1,47 @@
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,22 +16,22 @@
16 16
 #
17 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 20
 # tested with spdns.de
21 21
 local __URL="http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
22 22
 
23 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 25
 			       -e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
28 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
+