From: Jo-Philipp Wich Date: Sat, 1 Jan 2011 16:52:37 +0000 (+0000) Subject: [packages] ddns-scripts: use /proc/uptime as time reference, this makes it immune... X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=5f34699f00a1c77a33c6e4f37c421f48a7378d54;p=openwrt%2Fsvn-archive%2Farchive.git [packages] ddns-scripts: use /proc/uptime as time reference, this makes it immune against time warps (#8557) SVN-Revision: 24869 --- diff --git a/net/ddns-scripts/Makefile b/net/ddns-scripts/Makefile index af14e5395e..add0ee8220 100644 --- a/net/ddns-scripts/Makefile +++ b/net/ddns-scripts/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ddns-scripts PKG_VERSION:=1.0.0 -PKG_RELEASE:=10 +PKG_RELEASE:=11 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) diff --git a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh index 0e2ab7fade..19effeffae 100644 --- a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh +++ b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh @@ -122,3 +122,10 @@ start_daemon_for_all_ddns_sections() /usr/lib/ddns/dynamic_dns_updater.sh $section 0 > /dev/null 2>&1 & done } + +monotonic_time() +{ + local uptime + read uptime < /proc/uptime + echo "${uptime%%.*}" +} diff --git a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh index 1cab8aa7d8..a58b307294 100755 --- a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh +++ b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh @@ -206,7 +206,7 @@ echo $$ > /var/run/dynamic_dns/$service_id.pid #determine when the last update was -current_time=$(date +%s) +current_time=$(monotonic_time) last_update=$(( $current_time - (2*$force_interval_seconds) )) if [ -e "/var/run/dynamic_dns/$service_id.update" ] then @@ -231,7 +231,7 @@ do current_ip=$(get_current_ip) - current_time=$(date +%s) + current_time=$(monotonic_time) time_since_update=$(($current_time - $last_update)) @@ -270,7 +270,7 @@ do verbose_echo "" #save the time of the update - current_time=$(date +%s) + current_time=$(monotonic_time) last_update=$current_time time_since_update='0' registered_ip=$current_ip