Browse Source

ddns-scripts: Update to version 2.1.0-3

- removed special handling for dynamic_dns_helper.sh and url_escape.sed in Makefile/postinst
- minor fixes in logging
- allow retry_count of "0" to run infinite retrys on error
	-- https://dev.openwrt.org/ticket/18382
- changed naming of .dat and .err file to have one per section, not one per process
- defer hotplug helper from 25-ddns to 95-ddns (according initscript START=95)
	-- https://github.com/openwrt/packages/issues/568 (#568)
- fix commandline for busybox wget
	-- https://dev.openwrt.org/ticket/18411
	-- https://dev.openwrt.org/ticket/18437
	-- https://github.com/openwrt/packages/issues/605 (#605)
- remove checking answer from ddns provider because there are to many different.
	Some providers do not follow API from dyndns.com

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

+ 24
- 5
net/ddns-scripts/CHANGELOG View File

1
+Version 2.1.0-3
2
+Date	2014-12-07
3
+
4
+- removed special handling for dynamic_dns_helper.sh and url_escape.sed in Makefile/postinst
5
+- minor fixes in logging
6
+- allow retry_count of "0" to run infinite retrys on error
7
+	-- https://dev.openwrt.org/ticket/18382
8
+- changed naming of .dat and .err file to have one per section, not one per process
9
+- defer hotplug helper from 25-ddns to 95-ddns (according initscript START=95) 
10
+	-- https://github.com/openwrt/packages/issues/568 (#568)
11
+- fix commandline for busybox wget
12
+	-- https://dev.openwrt.org/ticket/18411
13
+	-- https://dev.openwrt.org/ticket/18437
14
+	-- https://github.com/openwrt/packages/issues/605 (#605)
15
+- remove checking answer from ddns provider because there are to many different. 
16
+Many providers did not follow API from dyndns.com 
17
+
18
+--------------------------------------------------------------------------------
1
 Version 2.1.0-2
19
 Version 2.1.0-2
2
 Date	2014-11-15
20
 Date	2014-11-15
3
 
21
 
4
 - moved /usr/lib/ddns/dynamic_dns_lucihelper.sh from luci-app-ddns into this package
22
 - moved /usr/lib/ddns/dynamic_dns_lucihelper.sh from luci-app-ddns into this package
5
-	(Github openwrt/luci issue 251)
6
-	(OpenWrt Trac tickets 18326 18347)
23
+	-- https://github.com/openwrt/luci/issue/251
24
+	-- https://dev.openwrt.org/ticket/18326
25
+	-- https://dev.openwrt.org/ticket/18347
7
 - fix: dynamic_dns_update.sh did not loop
26
 - fix: dynamic_dns_update.sh did not loop
8
-	(OpenWrt Trac ticket 18336)
27
+	-- https://dev.openwrt.org/ticket/18336
9
 - add provider cloudflare.com IPv4 and IPv6 (Thanks to Paul for support and testing)
28
 - add provider cloudflare.com IPv4 and IPv6 (Thanks to Paul for support and testing)
10
-	(OpenWrt Trac ticket 12500)
29
+	-- https://dev.openwrt.org/ticket/12500
11
 - modified detection, if dynamic_dns_fuctions are used by dynamic_dns_lucihelper.sh
30
 - modified detection, if dynamic_dns_fuctions are used by dynamic_dns_lucihelper.sh
12
 - redirect stdout of wget,curl,host,nslookup,nc etc to /tmp/ddns_$$.dat and *.err instead of variables
31
 - redirect stdout of wget,curl,host,nslookup,nc etc to /tmp/ddns_$$.dat and *.err instead of variables
13
 - extended error detection in get_local_ip function
32
 - extended error detection in get_local_ip function
14
 - modified verify of option ip_script to allow parameters, when calling
33
 - modified verify of option ip_script to allow parameters, when calling
15
 - add provider selfhost.de IPv4
34
 - add provider selfhost.de IPv4
16
 - add provider no-ip.pl (nothing to do with no-ip.com)
35
 - add provider no-ip.pl (nothing to do with no-ip.com)
17
-	(Github openwrt/packages issue #542)
36
+	-- https://github.com/openwrt/packages/issues/542 (#542)
18
 	IPv4 (tested) and also added for
37
 	IPv4 (tested) and also added for
19
 	IPv6 (NOT tested) because client IP is autodetected be provider
38
 	IPv6 (NOT tested) because client IP is autodetected be provider
20
 - add getlocalip_sample.sh as sample script for usage of
39
 - add getlocalip_sample.sh as sample script for usage of

+ 3
- 11
net/ddns-scripts/Makefile View File

2
 
2
 
3
 PKG_NAME:=ddns-scripts
3
 PKG_NAME:=ddns-scripts
4
 PKG_VERSION:=2.1.0
4
 PKG_VERSION:=2.1.0
5
-PKG_RELEASE:=2
5
+PKG_RELEASE:=3
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)
19
 endef
19
 endef
20
 
20
 
21
 define Package/ddns-scripts/description
21
 define Package/ddns-scripts/description
22
-	A highly configurable set of scripts for doing dynamic dns updates.
23
-	NEW in this version:
22
+A highly configurable set of scripts for doing dynamic dns updates.
24
 	- IPv6 support
23
 	- IPv6 support
25
 	- force communication to IPv4 or IPv6 only
24
 	- force communication to IPv4 or IPv6 only
26
 	- DNS server support
25
 	- DNS server support
29
 	- Proxy server support
28
 	- Proxy server support
30
 	- log file support
29
 	- log file support
31
 	- support to run once
30
 	- support to run once
31
+Version: $(PKG_VERSION)-$(PKG_RELEASE)
32
 endef
32
 endef
33
 
33
 
34
 define Build/Prepare
34
 define Build/Prepare
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
 
66
 
67
-	# remove old sed script file
68
-	[ -f /usr/lib/ddns/url_escape.sed ] && rm -f /usr/lib/ddns/url_escape.sed
69
-
70
-	# luci updates are not in sync with ddns-script updates !!!
71
-	# if old luci-app-ddns then errors during install because exist from differnt package
72
-	# copy dynamic_dns_helper.tmp.sh -> dynamic_dns_helper.sh
73
-	cp -f /usr/lib/ddns/dynamic_dns_lucihelper.tmp.sh /usr/lib/ddns/dynamic_dns_lucihelper.sh
74
-
75
 	# add new section "ddns" "global" if not exists
67
 	# add new section "ddns" "global" if not exists
76
 	uci -q get ddns.global > /dev/null || uci -q set ddns.global='ddns'
68
 	uci -q get ddns.global > /dev/null || uci -q set ddns.global='ddns'
77
 	uci -q get ddns.global.date_format > /dev/null || uci -q set ddns.global.date_format='%F %R'
69
 	uci -q get ddns.global.date_format > /dev/null || uci -q set ddns.global.date_format='%F %R'

net/ddns-scripts/files/etc/hotplug.d/iface/25-ddns → net/ddns-scripts/files/etc/hotplug.d/iface/95-ddns View File


+ 34
- 31
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh View File

34
 
34
 
35
 # directory to store run information to.
35
 # directory to store run information to.
36
 RUNDIR=$(uci -q get ddns.global.run_dir) || RUNDIR="/var/run/ddns"
36
 RUNDIR=$(uci -q get ddns.global.run_dir) || RUNDIR="/var/run/ddns"
37
+[ -d $RUNDIR ] || mkdir -p -m755 $RUNDIR
37
 # NEW # directory to store log files
38
 # NEW # directory to store log files
38
 LOGDIR=$(uci -q get ddns.global.log_dir) || LOGDIR="/var/log/ddns"
39
 LOGDIR=$(uci -q get ddns.global.log_dir) || LOGDIR="/var/log/ddns"
40
+[ -d $LOGDIR ] || mkdir -p -m755 $LOGDIR
39
 LOGFILE=""		# NEW # logfile can be enabled as new option
41
 LOGFILE=""		# NEW # logfile can be enabled as new option
40
 PIDFILE=""		# pid file
42
 PIDFILE=""		# pid file
41
 UPDFILE=""		# store UPTIME of last update
43
 UPDFILE=""		# store UPTIME of last update
42
-DATFILE="/tmp/ddns_$$.dat"	# save stdout data of WGet and other extern programs called
43
-ERRFILE="/tmp/ddns_$$.err"	# save stderr output of WGet and other extern programs called
44
+DATFILE=""		# save stdout data of WGet and other extern programs called
45
+ERRFILE=""		# save stderr output of WGet and other extern programs called
44
 
46
 
45
 # number of lines to before rotate logfile
47
 # number of lines to before rotate logfile
46
 LOGLINES=$(uci -q get ddns.global.log_lines) || LOGLINES=250
48
 LOGLINES=$(uci -q get ddns.global.log_lines) || LOGLINES=250
224
 	[ $VERBOSE_MODE -gt 0 -o $__EXIT -gt 0 ] && echo -e "$__MSG"
226
 	[ $VERBOSE_MODE -gt 0 -o $__EXIT -gt 0 ] && echo -e "$__MSG"
225
 	# write to logfile
227
 	# write to logfile
226
 	if [ ${use_logfile:-1} -eq 1 -o $VERBOSE_MODE -gt 1 ]; then
228
 	if [ ${use_logfile:-1} -eq 1 -o $VERBOSE_MODE -gt 1 ]; then
227
-		[ -d $LOGDIR ] || mkdir -p -m 755 $LOGDIR
228
 		echo -e "$__MSG" >> $LOGFILE
229
 		echo -e "$__MSG" >> $LOGFILE
229
 		# VERBOSE_MODE > 1 then NO loop so NO truncate log to $LOGLINES lines
230
 		# VERBOSE_MODE > 1 then NO loop so NO truncate log to $LOGLINES lines
230
 		[ $VERBOSE_MODE -gt 1 ] || sed -i -e :a -e '$q;N;'$LOGLINES',$D;ba' $LOGFILE
231
 		[ $VERBOSE_MODE -gt 1 ] || sed -i -e :a -e '$q;N;'$LOGLINES',$D;ba' $LOGFILE
302
 		awk ' gsub("\x27", "\"") { if ($1~/^[^\"]*$/) $1="\""$1"\"" }; { if ( $NF~/^[^\"]*$/) $NF="\""$NF"\""  }; { print $0 }')
303
 		awk ' gsub("\x27", "\"") { if ($1~/^[^\"]*$/) $1="\""$1"\"" }; { if ( $NF~/^[^\"]*$/) $NF="\""$NF"\""  }; { print $0 }')
303
 
304
 
304
 	IFS=$__NEWLINE_IFS
305
 	IFS=$__NEWLINE_IFS
305
-	for __LINE in $__SERVICES
306
-	do
306
+	for __LINE in $__SERVICES; do
307
 		#grep out proper parts of data and use echo to remove quotes
307
 		#grep out proper parts of data and use echo to remove quotes
308
 		__NAME=$(echo $__LINE | grep -o "^[\t ]*\"[^\"]*\"" | xargs -r -n1 echo)
308
 		__NAME=$(echo $__LINE | grep -o "^[\t ]*\"[^\"]*\"" | xargs -r -n1 echo)
309
 		__DATA=$(echo $__LINE | grep -o "\"[^\"]*\"[\t ]*$" | xargs -r -n1 echo)
309
 		__DATA=$(echo $__LINE | grep -o "\"[^\"]*\"[\t ]*$" | xargs -r -n1 echo)
459
 	# command error
459
 	# command error
460
 	[ $__ERR -gt 0 ] && {
460
 	[ $__ERR -gt 0 ] && {
461
 		write_log 3 "DNS Resolver Error - BusyBox nslookup Error '$__ERR'"
461
 		write_log 3 "DNS Resolver Error - BusyBox nslookup Error '$__ERR'"
462
-		write_log 7 "Error:\n$(cat $ERRFILE)"
462
+		write_log 7 "$(cat $ERRFILE)"
463
 		return 2
463
 		return 2
464
 	}
464
 	}
465
 	# extract IP address
465
 	# extract IP address
499
 		__ERR=$?
499
 		__ERR=$?
500
 		[ $__ERR -eq 0 ] && return 0
500
 		[ $__ERR -eq 0 ] && return 0
501
 		write_log 3 "Connect error - BusyBox nc (netcat) Error '$__ERR'"
501
 		write_log 3 "Connect error - BusyBox nc (netcat) Error '$__ERR'"
502
-		write_log 7 "Error:\n$(cat $ERRFILE)"
502
+		write_log 7 "$(cat $ERRFILE)"
503
 		return 3
503
 		return 3
504
 	else		# nc compiled without extensions (no timeout support)
504
 	else		# nc compiled without extensions (no timeout support)
505
 		__RUNPROG="timeout 2 -- /usr/bin/nc $__IP $__PORT </dev/null >$DATFILE 2>$ERRFILE"
505
 		__RUNPROG="timeout 2 -- /usr/bin/nc $__IP $__PORT </dev/null >$DATFILE 2>$ERRFILE"
533
 		elif [ $__ERR -ne 0 ]; then
533
 		elif [ $__ERR -ne 0 ]; then
534
 			__CNT=$(( $__CNT + 1 ))	# increment error counter
534
 			__CNT=$(( $__CNT + 1 ))	# increment error counter
535
 			# if error count > retry_count leave here
535
 			# if error count > retry_count leave here
536
-			[ $__CNT -gt $retry_count ] && \
536
+			[ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \
537
 				write_log 14 "Verify DNS server '$1' failed after $retry_count retries"
537
 				write_log 14 "Verify DNS server '$1' failed after $retry_count retries"
538
 
538
 
539
 			write_log 4 "Verify DNS server '$1' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
539
 			write_log 4 "Verify DNS server '$1' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
593
 		elif [ $__ERR -gt 0 ]; then
593
 		elif [ $__ERR -gt 0 ]; then
594
 			__CNT=$(( $__CNT + 1 ))	# increment error counter
594
 			__CNT=$(( $__CNT + 1 ))	# increment error counter
595
 			# if error count > retry_count leave here
595
 			# if error count > retry_count leave here
596
-			[ $__CNT -gt $retry_count ] && \
596
+			[ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \
597
 				write_log 14 "Verify Proxy server '$1' failed after $retry_count retries"
597
 				write_log 14 "Verify Proxy server '$1' failed after $retry_count retries"
598
 
598
 
599
 			write_log 4 "Verify Proxy server '$1' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
599
 			write_log 4 "Verify Proxy server '$1' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
637
 		# disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set)
637
 		# disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set)
638
 		[ -z "$proxy" ] && __PROG="$__PROG --no-proxy"
638
 		[ -z "$proxy" ] && __PROG="$__PROG --no-proxy"
639
 
639
 
640
-		__RUNPROG="$__PROG $__URL"	# build final command
640
+		__RUNPROG="$__PROG '$__URL'"	# build final command
641
 		__PROG="GNU Wget"		# reuse for error logging
641
 		__PROG="GNU Wget"		# reuse for error logging
642
 
642
 
643
 	# 2nd choice is cURL IPv4/IPv6/HTTPS
643
 	# 2nd choice is cURL IPv4/IPv6/HTTPS
671
 				write_log 13 "cURL: libcurl compiled without Proxy support"
671
 				write_log 13 "cURL: libcurl compiled without Proxy support"
672
 		fi
672
 		fi
673
 
673
 
674
-		__RUNPROG="$__PROG $__URL"	# build final command
674
+		__RUNPROG="$__PROG '$__URL'"	# build final command
675
 		__PROG="cURL"			# reuse for error logging
675
 		__PROG="cURL"			# reuse for error logging
676
 
676
 
677
 	# busybox Wget (did not support neither IPv6 nor HTTPS)
677
 	# busybox Wget (did not support neither IPv6 nor HTTPS)
686
 		# disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set)
686
 		# disable proxy if no set (there might be .wgetrc or .curlrc or wrong environment set)
687
 		[ -z "$proxy" ] && __PROG="$__PROG -Y off"
687
 		[ -z "$proxy" ] && __PROG="$__PROG -Y off"
688
 
688
 
689
-		__RUNPROG="$__PROG $__URL 2>$ERRFILE"	# build final command
690
-		__PROG="Busybox Wget"			# reuse for error logging
689
+		__RUNPROG="$__PROG '$__URL' 2>$ERRFILE"		# build final command
690
+		__PROG="Busybox Wget"				# reuse for error logging
691
 
691
 
692
 	else
692
 	else
693
 		write_log 13 "Neither 'Wget' nor 'cURL' installed or executable"
693
 		write_log 13 "Neither 'Wget' nor 'cURL' installed or executable"
695
 
695
 
696
 	while : ; do
696
 	while : ; do
697
 		write_log 7 "#> $__RUNPROG"
697
 		write_log 7 "#> $__RUNPROG"
698
-		$__RUNPROG			# DO transfer
698
+		eval $__RUNPROG			# DO transfer
699
 		__ERR=$?			# save error code
699
 		__ERR=$?			# save error code
700
 		[ $__ERR -eq 0 ] && return 0	# no error leave
700
 		[ $__ERR -eq 0 ] && return 0	# no error leave
701
 		[ $LUCI_HELPER ] && return 1	# no retry if called by LuCI helper script
701
 		[ $LUCI_HELPER ] && return 1	# no retry if called by LuCI helper script
711
 
711
 
712
 		__CNT=$(( $__CNT + 1 ))	# increment error counter
712
 		__CNT=$(( $__CNT + 1 ))	# increment error counter
713
 		# if error count > retry_count leave here
713
 		# if error count > retry_count leave here
714
-		[ $__CNT -gt $retry_count ] && \
714
+		[ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \
715
 			write_log 14 "Transfer failed after $retry_count retries"
715
 			write_log 14 "Transfer failed after $retry_count retries"
716
 
716
 
717
 		write_log 4 "Transfer failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
717
 		write_log 4 "Transfer failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
750
 
750
 
751
 		write_log 7 "DDNS Provider answered:\n$(cat $DATFILE)"
751
 		write_log 7 "DDNS Provider answered:\n$(cat $DATFILE)"
752
 
752
 
753
-		# analyse provider answers
754
-		# "good [IP_ADR]"	= successful
755
-		# "nochg [IP_ADR]"	= no change but OK
756
-		grep -E "good|nochg" $DATFILE >/dev/null 2>&1
757
-		return $?	# "0" if "good" or "nochg" found
753
+		return 0
754
+		# TODO analyse providers answer
755
+		# "good" or "nochg"		= dyndns.com compatible API
756
+		# grep -i -E "good|nochg" $DATFILE >/dev/null 2>&1
757
+		# return $?	# "0" if found
758
 	fi
758
 	fi
759
 }
759
 }
760
 
760
 
846
 		}
846
 		}
847
 
847
 
848
 		[ $LUCI_HELPER ] && return 1	# no retry if called by LuCI helper script
848
 		[ $LUCI_HELPER ] && return 1	# no retry if called by LuCI helper script
849
+
850
+		write_log 7 "Data detected:\n$(cat $DATFILE)"
851
+
849
 		[ $VERBOSE_MODE -gt 1 ] && {
852
 		[ $VERBOSE_MODE -gt 1 ] && {
850
 			# VERBOSE_MODE > 1 then NO retry
853
 			# VERBOSE_MODE > 1 then NO retry
851
 			write_log 4 "Get local IP via '$ip_source' failed - Verbose Mode: $VERBOSE_MODE - NO retry on error"
854
 			write_log 4 "Get local IP via '$ip_source' failed - Verbose Mode: $VERBOSE_MODE - NO retry on error"
854
 
857
 
855
 		__CNT=$(( $__CNT + 1 ))	# increment error counter
858
 		__CNT=$(( $__CNT + 1 ))	# increment error counter
856
 		# if error count > retry_count leave here
859
 		# if error count > retry_count leave here
857
-		[ $__CNT -gt $retry_count ] && \
860
+		[ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \
858
 			write_log 14 "Get local IP via '$ip_source' failed after $retry_count retries"
861
 			write_log 14 "Get local IP via '$ip_source' failed after $retry_count retries"
859
-
860
 		write_log 4 "Get local IP via '$ip_source' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
862
 		write_log 4 "Get local IP via '$ip_source' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
861
 		sleep $RETRY_SECONDS &
863
 		sleep $RETRY_SECONDS &
862
 		PID_SLEEP=$!
864
 		PID_SLEEP=$!
908
 		__ERR=$?
910
 		__ERR=$?
909
 		if [ $__ERR -ne 0 ]; then
911
 		if [ $__ERR -ne 0 ]; then
910
 			write_log 3 "$__PROG error: '$__ERR'"
912
 			write_log 3 "$__PROG error: '$__ERR'"
911
-			write_log 7 "Error:\n$(cat $ERRFILE)"
913
+			write_log 7 "$(cat $ERRFILE)"
912
 		else
914
 		else
913
 			if [ "$__PROG" = "BIND host" ]; then
915
 			if [ "$__PROG" = "BIND host" ]; then
914
 				__DATA=$(cat $DATFILE | awk -F "address " '/has/ {print $2; exit}' )
916
 				__DATA=$(cat $DATFILE | awk -F "address " '/has/ {print $2; exit}' )
934
 
936
 
935
 		__CNT=$(( $__CNT + 1 ))	# increment error counter
937
 		__CNT=$(( $__CNT + 1 ))	# increment error counter
936
 		# if error count > retry_count leave here
938
 		# if error count > retry_count leave here
937
-		[ $__CNT -gt $retry_count ] && \
939
+		[ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \
938
 			write_log 14 "Get registered/public IP for '$domain' failed after $retry_count retries"
940
 			write_log 14 "Get registered/public IP for '$domain' failed after $retry_count retries"
939
 
941
 
940
 		write_log 4 "Get registered/public IP for '$domain' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
942
 		write_log 4 "Get registered/public IP for '$domain' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
966
 	[ $PID_SLEEP -ne 0 ] && kill -$1 $PID_SLEEP 2>/dev/null	# kill pending sleep if exist
968
 	[ $PID_SLEEP -ne 0 ] && kill -$1 $PID_SLEEP 2>/dev/null	# kill pending sleep if exist
967
 
969
 
968
 	case $1 in
970
 	case $1 in
969
-		0)	if [ $__ERR -eq 0 ]; then
971
+		 0)	if [ $__ERR -eq 0 ]; then
970
 				write_log 5 "PID '$$' exit normal at $(eval $DATE_PROG)\n"
972
 				write_log 5 "PID '$$' exit normal at $(eval $DATE_PROG)\n"
971
 			else
973
 			else
972
 				write_log 4 "PID '$$' exit WITH ERROR '$__ERR' at $(eval $DATE_PROG)\n"
974
 				write_log 4 "PID '$$' exit WITH ERROR '$__ERR' at $(eval $DATE_PROG)\n"
973
 			fi ;;
975
 			fi ;;
974
-		1)	write_log 6 "PID '$$' received 'SIGHUP' at $(eval $DATE_PROG)"
975
-			eval "$0 $SECTION_ID $VERBOSE_MODE &"	# reload config via restarting script
976
-			exit 0 ;;
977
-		2)	write_log 5 "PID '$$' terminated by 'SIGINT' at $(eval $DATE_PROG)\n";;
978
-		3)	write_log 5 "PID '$$' terminated by 'SIGQUIT' at $(eval $DATE_PROG)\n";;
976
+		 1)	write_log 6 "PID '$$' received 'SIGHUP' at $(eval $DATE_PROG)"
977
+			# reload config via starting the script again 
978
+			eval "/usr/lib/ddns/dynamic_dns_updater.sh $SECTION_ID $VERBOSE_MODE &"
979
+			exit 0 ;;	# and leave this one
980
+		 2)	write_log 5 "PID '$$' terminated by 'SIGINT' at $(eval $DATE_PROG)\n";;
981
+		 3)	write_log 5 "PID '$$' terminated by 'SIGQUIT' at $(eval $DATE_PROG)\n";;
979
 		15)	write_log 5 "PID '$$' terminated by 'SIGTERM' at $(eval $DATE_PROG)\n";;
982
 		15)	write_log 5 "PID '$$' terminated by 'SIGTERM' at $(eval $DATE_PROG)\n";;
980
-		*)	write_log 13 "Unhandled signal '$1' in 'trap_handler()'";;
983
+		 *)	write_log 13 "Unhandled signal '$1' in 'trap_handler()'";;
981
 	esac
984
 	esac
982
 
985
 
983
 	__PIDS=$(pgrep -P $$)	# get my childs (pgrep prints with "newline")
986
 	__PIDS=$(pgrep -P $$)	# get my childs (pgrep prints with "newline")

net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.tmp.sh → net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.sh View File

22
 # preset some variables, wrong or not set in dynamic_dns_functions.sh
22
 # preset some variables, wrong or not set in dynamic_dns_functions.sh
23
 SECTION_ID="lucihelper"
23
 SECTION_ID="lucihelper"
24
 LOGFILE="$LOGDIR/$SECTION_ID.log"
24
 LOGFILE="$LOGDIR/$SECTION_ID.log"
25
+DATFILE="$RUNDIR/$SECTION_ID.dat"	# save stdout data of WGet and other extern programs called
26
+ERRFILE="$RUNDIR/$SECTION_ID.err"	# save stderr output of WGet and other extern programs called
25
 VERBOSE_MODE=0		# no console logging
27
 VERBOSE_MODE=0		# no console logging
26
 # global variables normally set by reading DDNS UCI configuration
28
 # global variables normally set by reading DDNS UCI configuration
27
 use_syslog=0		# no syslog
29
 use_syslog=0		# no syslog

+ 18
- 22
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh View File

44
 # set file names
44
 # set file names
45
 PIDFILE="$RUNDIR/$SECTION_ID.pid"	# Process ID file
45
 PIDFILE="$RUNDIR/$SECTION_ID.pid"	# Process ID file
46
 UPDFILE="$RUNDIR/$SECTION_ID.update"	# last update successful send (system uptime)
46
 UPDFILE="$RUNDIR/$SECTION_ID.update"	# last update successful send (system uptime)
47
+DATFILE="$RUNDIR/$SECTION_ID.dat"	# save stdout data of WGet and other extern programs called
48
+ERRFILE="$RUNDIR/$SECTION_ID.err"	# save stderr output of WGet and other extern programs called
47
 LOGFILE="$LOGDIR/$SECTION_ID.log"	# log file
49
 LOGFILE="$LOGDIR/$SECTION_ID.log"	# log file
48
 
50
 
49
 # VERBOSE_MODE > 1 delete logfile if exist to create an empty one
51
 # VERBOSE_MODE > 1 delete logfile if exist to create an empty one
98
 #
100
 #
99
 # retry_interval	if error was detected retry in
101
 # retry_interval	if error was detected retry in
100
 # retry_unit		'days' 'hours' 'minutes' 'seconds'
102
 # retry_unit		'days' 'hours' 'minutes' 'seconds'
101
-# retry_count 		#NEW# number of retries before scripts stops
103
+# retry_count 		number of retries before scripts stops
102
 #
104
 #
103
-# use_ipv6		#NEW# detecting/sending IPv6 address
104
-# force_ipversion	#NEW# force usage of IPv4 or IPv6 for the whole detection and update communication
105
-# dns_server		#NEW# using a non default dns server to get Registered IP from Internet
106
-# force_dnstcp		#NEW# force communication with DNS server via TCP instead of default UDP
107
-# proxy			#NEW# using a proxy for communication !!! ALSO used to detect local IP via web => return proxy's IP !!!
108
-# use_logfile		#NEW# self-explanatory "/var/log/ddns/$SECTION_ID.log"
105
+# use_ipv6		detecting/sending IPv6 address
106
+# force_ipversion	force usage of IPv4 or IPv6 for the whole detection and update communication
107
+# dns_server		using a non default dns server to get Registered IP from Internet
108
+# force_dnstcp		force communication with DNS server via TCP instead of default UDP
109
+# proxy			using a proxy for communication !!! ALSO used to detect local IP via web => return proxy's IP !!!
110
+# use_logfile		self-explanatory "/var/log/ddns/$SECTION_ID.log"
109
 #
111
 #
110
 # some functionality needs
112
 # some functionality needs
111
 # - GNU Wget or cURL installed for sending updates to DDNS service
113
 # - GNU Wget or cURL installed for sending updates to DDNS service
138
 # set defaults if not defined
140
 # set defaults if not defined
139
 [ -z "$enabled" ]	  && enabled=0
141
 [ -z "$enabled" ]	  && enabled=0
140
 [ -z "$retry_count" ]	  && retry_count=5
142
 [ -z "$retry_count" ]	  && retry_count=5
141
-[ -z "$use_syslog" ]      && use_syslog=0	# not use syslog
143
+[ -z "$use_syslog" ]      && use_syslog=2	# syslog "Notice"
142
 [ -z "$use_https" ]       && use_https=0	# not use https
144
 [ -z "$use_https" ]       && use_https=0	# not use https
143
-[ -z "$use_logfile" ]     && use_logfile=1	# NEW - use logfile by default
144
-[ -z "$use_ipv6" ]	  && use_ipv6=0		# NEW - use IPv4 by default
145
-[ -z "$force_ipversion" ] && force_ipversion=0	# NEW - default let system decide
146
-[ -z "$force_dnstcp" ]	  && force_dnstcp=0	# NEW - default UDP
145
+[ -z "$use_logfile" ]     && use_logfile=1	# use logfile by default
146
+[ -z "$use_ipv6" ]	  && use_ipv6=0		# use IPv4 by default
147
+[ -z "$force_ipversion" ] && force_ipversion=0	# default let system decide
148
+[ -z "$force_dnstcp" ]	  && force_dnstcp=0	# default UDP
147
 [ -z "$ip_source" ]	  && ip_source="network"
149
 [ -z "$ip_source" ]	  && ip_source="network"
148
 [ "$ip_source" = "network" -a -z "$ip_network" -a $use_ipv6 -eq 0 ] && ip_network="wan"  # IPv4: default wan
150
 [ "$ip_source" = "network" -a -z "$ip_network" -a $use_ipv6 -eq 0 ] && ip_network="wan"  # IPv4: default wan
149
 [ "$ip_source" = "network" -a -z "$ip_network" -a $use_ipv6 -eq 1 ] && ip_network="wan6" # IPv6: default wan6
151
 [ "$ip_source" = "network" -a -z "$ip_network" -a $use_ipv6 -eq 1 ] && ip_network="wan6" # IPv6: default wan6
185
 [ -n "$update_script" -a ! -f "$update_script" ] && write_log 14 "Custom update_script not found!"
187
 [ -n "$update_script" -a ! -f "$update_script" ] && write_log 14 "Custom update_script not found!"
186
 
188
 
187
 #kill old process if it exists & set new pid file
189
 #kill old process if it exists & set new pid file
188
-if [ -d $RUNDIR ]; then
189
-	#if process for section is already running, stop it
190
-	stop_section_processes "$SECTION_ID"
191
-	[ $? -gt 0 ] && write_log 7 "Send 'SIGTERM' to old process" || write_log 7 "No old process"
192
-else
193
-	#make dir since it doesn't exist
194
-	mkdir -p $RUNDIR
195
-	write_log 7 "No old process"
196
-fi
190
+stop_section_processes "$SECTION_ID"
191
+[ $? -gt 0 ] && write_log 7 "Send 'SIGTERM' to old process" || write_log 7 "No old process"
197
 echo $$ > $PIDFILE
192
 echo $$ > $PIDFILE
198
 
193
 
199
 # determine when the last update was
194
 # determine when the last update was
307
 	if [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
302
 	if [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
308
 		if [ $VERBOSE_MODE -le 1 ]; then	# VERBOSE_MODE <=1 then retry
303
 		if [ $VERBOSE_MODE -le 1 ]; then	# VERBOSE_MODE <=1 then retry
309
 			ERR_UPDATE=$(( $ERR_UPDATE + 1 ))
304
 			ERR_UPDATE=$(( $ERR_UPDATE + 1 ))
310
-			[ $ERR_UPDATE -gt $retry_count ] && write_log 14 "Updating IP at DDNS provider failed after $retry_count retries"
305
+			[ $retry_count -gt 0 -a $ERR_UPDATE -gt $retry_count ] && \
306
+				write_log 14 "Updating IP at DDNS provider failed after $retry_count retries"
311
 			write_log 4 "Updating IP at DDNS provider failed - starting retry $ERR_UPDATE/$retry_count"
307
 			write_log 4 "Updating IP at DDNS provider failed - starting retry $ERR_UPDATE/$retry_count"
312
 			continue # loop to beginning
308
 			continue # loop to beginning
313
 		else
309
 		else

+ 5
- 0
net/ddns-scripts/files/usr/lib/ddns/getlocalip_sample.sh View File

10
 #
10
 #
11
 # the script is executed (not parsed) inside get_local_ip() function
11
 # the script is executed (not parsed) inside get_local_ip() function
12
 # of /usr/lib/ddns/dynamic_dns_functions.sh
12
 # of /usr/lib/ddns/dynamic_dns_functions.sh
13
+# 
14
+# useful when this box is the only DDNS client in the network
15
+# IP adresses of "internal" boxes could be detected with this script
16
+# so no need to install ddns client on every "internal" box
17
+# On IPv6 every internal box normally has it's own external IP
13
 #
18
 #
14
 # This script should
19
 # This script should
15
 # 	- return the IP address via stdout	echo -n "...."	!!! without line feed
20
 # 	- return the IP address via stdout	echo -n "...."	!!! without line feed