diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-03-31 22:00:55 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-03-31 22:00:55 +0200 |
commit | 1186894f773e13ab9ca2b3e05a194e9b88796fbe (patch) | |
tree | 0921c07594ad42f0ab7cf147de97539fa64d92d7 /examples/var_service/ntpd | |
parent | 9472e8a86fa1837bccec9e25dd18fd3c88c5e209 (diff) | |
download | busybox-w32-1186894f773e13ab9ca2b3e05a194e9b88796fbe.tar.gz busybox-w32-1186894f773e13ab9ca2b3e05a194e9b88796fbe.tar.bz2 busybox-w32-1186894f773e13ab9ca2b3e05a194e9b88796fbe.zip |
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/var_service/ntpd')
-rwxr-xr-x | examples/var_service/ntpd/ntp.script | 21 |
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 @@ | |||
10 | 10 | ||
11 | dt=`date '+%Y-%m-%d %H:%M:%S'` | 11 | dt=`date '+%Y-%m-%d %H:%M:%S'` |
12 | 12 | ||
13 | echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$" | ||
14 | |||
15 | if test x"$1" = x"unsync" \ | ||
16 | ; then | ||
17 | # No replies for our NTP requests were seen for some time. | ||
18 | # | ||
19 | # Among more mundate cases like network outages, this happens | ||
20 | # if we ran for a LONG time (days) and ntp server's IP has changed. | ||
21 | # ntpd has no code to re-resolve peers' addresses to IPs, | ||
22 | # we need to help it: | ||
23 | # | ||
24 | echo "$dt: $1"\ | ||
25 | "syncronization lost, restarting ntpd"\ | ||
26 | >>"$0.log.$$" | ||
27 | mv -- "$0.log.$$" "$0.log" | ||
28 | kill $PPID | ||
29 | exit | ||
30 | fi | ||
31 | |||
13 | if test x"$stratum" != x"" \ | 32 | if test x"$stratum" != x"" \ |
14 | && test x"$poll_interval" != x"" \ | 33 | && test x"$poll_interval" != x"" \ |
15 | && test 4 -ge "$stratum" \ | 34 | && test 4 -ge "$stratum" \ |
16 | && test 128 -le "$poll_interval" \ | 35 | && test 128 -le "$poll_interval" \ |
17 | ; then | 36 | ; then |
18 | echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$" | ||
19 | echo "$dt: $1"\ | 37 | echo "$dt: $1"\ |
20 | "freq_drift_ppm=$freq_drift_ppm"\ | 38 | "freq_drift_ppm=$freq_drift_ppm"\ |
21 | "offset=$offset"\ | 39 | "offset=$offset"\ |
@@ -27,7 +45,6 @@ if test x"$stratum" != x"" \ | |||
27 | exec hwclock --systohc | 45 | exec hwclock --systohc |
28 | fi | 46 | fi |
29 | 47 | ||
30 | echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$" | ||
31 | echo "$dt: $1"\ | 48 | echo "$dt: $1"\ |
32 | "freq_drift_ppm=$freq_drift_ppm"\ | 49 | "freq_drift_ppm=$freq_drift_ppm"\ |
33 | "offset=$offset"\ | 50 | "offset=$offset"\ |