2 # Note that there is no provision to prevent several copies of the script
3 # to be run in quick succession. In fact, it happens rather often
4 # if initial syncronization results in a step.
5 # You will see "step" and then "stratum" script runs, sometimes
6 # as close as only 0.002 seconds apart.
8 # Script should be ready to deal with this.
10 # For other parts of the system which prefer to run only on the stable clock
11 echo "$1" >rundir/sync_status
13 dt=`date '+%Y-%m-%d %H:%M:%S'`
15 echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
17 if test x"$1" = x"unsync" \
19 # No replies for our NTP requests were seen for some time.
21 # Among more mundate cases like network outages, this happens
22 # if we ran for a LONG time (days) and ntp server's IP has changed.
23 # ntpd has no code to re-resolve peers' addresses to IPs,
27 "syncronization lost, restarting ntpd"\
29 mv -- "$0.log.$$" "$0.log"
34 if test x"$stratum" != x"" \
35 && test x"$poll_interval" != x"" \
36 && test 4 -ge "$stratum" \
37 && test 128 -le "$poll_interval" \
40 "freq_drift_ppm=$freq_drift_ppm"\
43 "poll_interval=$poll_interval,"\
44 "setting hardware clock"\
46 mv -- "$0.log.$$" "$0.log"
47 exec hwclock --systohc
51 "freq_drift_ppm=$freq_drift_ppm"\
54 "poll_interval=$poll_interval"\
56 mv -- "$0.log.$$" "$0.log"