blob: 76c34bf74aed09353396478d4fb72e06c066a180 [file] [log] [blame]
Denys Vlasenko4fc82e02010-01-13 22:07:34 +01001#!/bin/sh
2
Denys Vlasenko24928ff2010-01-25 19:30:16 +01003# 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 Vlasenko4fc82e02010-01-13 22:07:34 +010010
11dt=`date '+%Y-%m-%d %H:%M:%S'`
12
13if test x"$stratum" != x"" \
14&& test x"$poll_interval" != x"" \
15&& test 4 -ge "$stratum" \
16&& test 128 -le "$poll_interval" \
17; then
Denys Vlasenko24928ff2010-01-25 19:30:16 +010018 echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
Denys Vlasenko4fc82e02010-01-13 22:07:34 +010019 echo "$dt: $1"\
20 "freq_drift_ppm=$freq_drift_ppm"\
21 "offset=$offset"\
22 "stratum=$stratum"\
23 "poll_interval=$poll_interval,"\
Denys Vlasenko24928ff2010-01-25 19:30:16 +010024 "setting hardware clock"\
25 >>"$0.log.$$"
26 mv -- "$0.log.$$" "$0.log"
Denys Vlasenko4fc82e02010-01-13 22:07:34 +010027 exec hwclock --systohc
28fi
29
Denys Vlasenko24928ff2010-01-25 19:30:16 +010030echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
Denys Vlasenko4fc82e02010-01-13 22:07:34 +010031echo "$dt: $1"\
32 "freq_drift_ppm=$freq_drift_ppm"\
33 "offset=$offset"\
34 "stratum=$stratum"\
35 "poll_interval=$poll_interval"\
Denys Vlasenko24928ff2010-01-25 19:30:16 +010036 >>"$0.log.$$"
37mv -- "$0.log.$$" "$0.log"