Denys Vlasenko | 4fc82e0 | 2010-01-13 22:07:34 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denys Vlasenko | 24928ff | 2010-01-25 19:30:16 +0100 | [diff] [blame] | 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. |
Denys Vlasenko | 4fc82e0 | 2010-01-13 22:07:34 +0100 | [diff] [blame] | 10 | |
| 11 | dt=`date '+%Y-%m-%d %H:%M:%S'` |
| 12 | |
| 13 | if test x"$stratum" != x"" \ |
| 14 | && test x"$poll_interval" != x"" \ |
| 15 | && test 4 -ge "$stratum" \ |
| 16 | && test 128 -le "$poll_interval" \ |
| 17 | ; then |
Denys Vlasenko | 24928ff | 2010-01-25 19:30:16 +0100 | [diff] [blame] | 18 | echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$" |
Denys Vlasenko | 4fc82e0 | 2010-01-13 22:07:34 +0100 | [diff] [blame] | 19 | echo "$dt: $1"\ |
| 20 | "freq_drift_ppm=$freq_drift_ppm"\ |
| 21 | "offset=$offset"\ |
| 22 | "stratum=$stratum"\ |
| 23 | "poll_interval=$poll_interval,"\ |
Denys Vlasenko | 24928ff | 2010-01-25 19:30:16 +0100 | [diff] [blame] | 24 | "setting hardware clock"\ |
| 25 | >>"$0.log.$$" |
| 26 | mv -- "$0.log.$$" "$0.log" |
Denys Vlasenko | 4fc82e0 | 2010-01-13 22:07:34 +0100 | [diff] [blame] | 27 | exec hwclock --systohc |
| 28 | fi |
| 29 | |
Denys Vlasenko | 24928ff | 2010-01-25 19:30:16 +0100 | [diff] [blame] | 30 | echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$" |
Denys Vlasenko | 4fc82e0 | 2010-01-13 22:07:34 +0100 | [diff] [blame] | 31 | echo "$dt: $1"\ |
| 32 | "freq_drift_ppm=$freq_drift_ppm"\ |
| 33 | "offset=$offset"\ |
| 34 | "stratum=$stratum"\ |
| 35 | "poll_interval=$poll_interval"\ |
Denys Vlasenko | 24928ff | 2010-01-25 19:30:16 +0100 | [diff] [blame] | 36 | >>"$0.log.$$" |
| 37 | mv -- "$0.log.$$" "$0.log" |