aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-03-31 22:00:55 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-03-31 22:00:55 +0200
commit1186894f773e13ab9ca2b3e05a194e9b88796fbe (patch)
tree0921c07594ad42f0ab7cf147de97539fa64d92d7 /examples
parent9472e8a86fa1837bccec9e25dd18fd3c88c5e209 (diff)
downloadbusybox-1186894f773e13ab9ca2b3e05a194e9b88796fbe.tar.gz
update example ntp.script
Handle an interesting corner case when NTP server is reachable... but on a different IP now. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/var_service/ntpd/ntp.script21
1 files changed, 19 insertions, 2 deletions
diff --git a/examples/var_service/ntpd/ntp.script b/examples/var_service/ntpd/ntp.script
index 76c34bf74..8542181eb 100755
--- a/examples/var_service/ntpd/ntp.script
+++ b/examples/var_service/ntpd/ntp.script
@@ -10,12 +10,30 @@
dt=`date '+%Y-%m-%d %H:%M:%S'`
+echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
+
+if test x"$1" = x"unsync" \
+; then
+ # No replies for our NTP requests were seen for some time.
+ #
+ # Among more mundate cases like network outages, this happens
+ # if we ran for a LONG time (days) and ntp server's IP has changed.
+ # ntpd has no code to re-resolve peers' addresses to IPs,
+ # we need to help it:
+ #
+ echo "$dt: $1"\
+ "syncronization lost, restarting ntpd"\
+ >>"$0.log.$$"
+ mv -- "$0.log.$$" "$0.log"
+ kill $PPID
+ exit
+fi
+
if test x"$stratum" != x"" \
&& test x"$poll_interval" != x"" \
&& test 4 -ge "$stratum" \
&& test 128 -le "$poll_interval" \
; then
- echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
echo "$dt: $1"\
"freq_drift_ppm=$freq_drift_ppm"\
"offset=$offset"\
@@ -27,7 +45,6 @@ if test x"$stratum" != x"" \
exec hwclock --systohc
fi
-echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
echo "$dt: $1"\
"freq_drift_ppm=$freq_drift_ppm"\
"offset=$offset"\