source: MondoRescue/branches/3.3/mindi-busybox/examples/var_service/ntpd/ntp.script@ 3621

Last change on this file since 3621 was 3621, checked in by Bruno Cornec, 7 years ago

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/bin/sh
2
3# Note that there is no provision to prevent several copies of the script
4# to be run in quick succession. In fact, it happens rather often
5# if initial syncronization results in a step.
6# You will see "step" and then "stratum" script runs, sometimes
7# as close as only 0.002 seconds apart.
8#
9# Script should be ready to deal with this.
10
11dt=`date '+%Y-%m-%d %H:%M:%S'`
12
13echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
14
15if 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
30fi
31
32if test x"$stratum" != x"" \
33&& test x"$poll_interval" != x"" \
34&& test 4 -ge "$stratum" \
35&& test 128 -le "$poll_interval" \
36; then
37 echo "$dt: $1"\
38 "freq_drift_ppm=$freq_drift_ppm"\
39 "offset=$offset"\
40 "stratum=$stratum"\
41 "poll_interval=$poll_interval,"\
42 "setting hardware clock"\
43 >>"$0.log.$$"
44 mv -- "$0.log.$$" "$0.log"
45 exec hwclock --systohc
46fi
47
48echo "$dt: $1"\
49 "freq_drift_ppm=$freq_drift_ppm"\
50 "offset=$offset"\
51 "stratum=$stratum"\
52 "poll_interval=$poll_interval"\
53 >>"$0.log.$$"
54mv -- "$0.log.$$" "$0.log"
Note: See TracBrowser for help on using the repository browser.