summaryrefslogtreecommitdiff
path: root/recipes-support/ntp/files
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-support/ntp/files')
-rw-r--r--recipes-support/ntp/files/ntp.conf.patch52
-rw-r--r--recipes-support/ntp/files/ntpd-default31
-rw-r--r--recipes-support/ntp/files/ntpd-init.patch52
3 files changed, 135 insertions, 0 deletions
diff --git a/recipes-support/ntp/files/ntp.conf.patch b/recipes-support/ntp/files/ntp.conf.patch
new file mode 100644
index 0000000..691d039
--- /dev/null
+++ b/recipes-support/ntp/files/ntp.conf.patch
@@ -0,0 +1,52 @@
+diff -Naur old/ntp.conf new/ntp.conf
+--- old/ntp.conf 2017-01-17 12:00:15.560426583 -0600
++++ new/ntp.conf 2017-01-17 12:02:11.968426337 -0600
+@@ -1,16 +1,44 @@
+-# This is the most basic ntp configuration file
+ # The driftfile must remain in a place specific to this
+ # machine - it records the machine specific clock error
+-driftfile /etc/ntp.drift
++# Driftfile must be in a directory owned by ntp
++driftfile /var/lib/ntp/ntp.drift
++
++# The following code is for evaluating the timeserver.
++# Remove the # to activate the statistics
++# statistics loopstats
++# statistics peerstats
++# statsdir /var/log/ntpstats
++# filegen peerstats file peerstats type day link enable
++# filegen loopstats file loopstats type day link enable
++
++# This is the US timeserver pool. You should use a pool
++# close to your location.
++#pool us.pool.ntp.org iburst
++
+ # This should be a server that is close (in IP terms)
+ # to the machine. Add other servers as required.
+-# Unless you un-comment the line below ntpd will sync
+-# only against the local system clock.
+ #
+ # server time.server.example.com
+ #
++
++restrict default kod nomodify notrap nopeer noquery
++restrict -6 default kod nomodify notrap nopeer noquery
++restrict 127.0.0.1 mask 255.255.255.0
++restrict -6 ::1
++
++# GPS Serial data reference (NTP0)
++# This sets the GPS 80 milliseconds slower than the PPS.
++server 127.127.28.0
++fudge 127.127.28.0 time1 0.080 refid GPS
++
++# GPS PPS reference (NTP2)
++server 127.127.28.2 prefer
++fudge 127.127.28.2 time1 0.000 refid PPS
++
+ # Using local hardware clock as fallback
+ # Disable this when using ntpd -q -g -x as ntpdate or it will sync to itself
++# The stratum should be a high value so this does not get chosen
++# except in dire circumstances.
+ server 127.127.1.0
+ fudge 127.127.1.0 stratum 14
+ # Defining a default security setting
diff --git a/recipes-support/ntp/files/ntpd-default b/recipes-support/ntp/files/ntpd-default
new file mode 100644
index 0000000..4811f46
--- /dev/null
+++ b/recipes-support/ntp/files/ntpd-default
@@ -0,0 +1,31 @@
+# The GPSD_* parameters in this file are ignored
+# if the uBlox GPS is not present.
+
+# Require a GPS lock/fix before starting NTP
+# This is needed if we are not using NTP servers.
+# NTP will not work with the GPS if the GPS is not
+# locked before starting.
+# See /etc/default/gpsd for the states required.
+GPSD_REQUIRED=1
+
+# Number of seconds between testing for a GPS
+# lock prior to calling ntpd.
+GPSD_WAIT_TIME=120
+
+# Since the HW Clock could be off by a second or
+# so, our GPS might get marked as a false ticker
+# if we do not set the system clock to the GPS
+# first. The current correct way to do this
+# according to the ntp doc is ntpd -gq -c conffile
+# which must be done before ntpd is started.
+# conffile should exclude the local clock, so it is
+# ignored while doing the initial sync.
+# ntpd -gq apparently does not work with the GPS
+# when tested with the clock more than one day off
+# and no ntpd. The gps shared memory is never polled.
+#
+# If there is a uBlox GPS present, the time is
+# read from the GPS to initialize the system time
+# before NTP is started.
+SET_SYSTEM_CLOCK=1
+
diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch
new file mode 100644
index 0000000..05a6a8e
--- /dev/null
+++ b/recipes-support/ntp/files/ntpd-init.patch
@@ -0,0 +1,52 @@
+--- old/ntpd 2017-01-12 18:10:40.208157197 -0600
++++ new/ntpd 2017-01-12 18:14:27.952154318 -0600
+@@ -1,6 +1,8 @@
+-#! /bin/sh
++#! /bin/bash
+ #
++. /etc/default/ntpd
+ PATH=/sbin:/bin:/usr/bin:/usr/sbin
++GNSSRST=/sys/devices/platform/mts-io/gnss-reset
+
+ # ntpd init.d script for ntpdc from ntp.isc.org
+ test -x /usr/sbin/ntpd -a -r /etc/ntp.conf || exit 0
+@@ -18,13 +20,32 @@
+ }
+ }
+ startdaemon(){
+- # The -g option allows ntpd to step the time to correct it just
+- # once. The daemon will exit if the clock drifts too much after
+- # this. If ntpd seems to disappear after a while assume TICKADJ
+- # above is set to a totally incorrect value.
+- echo -n "Starting ntpd: "
+- start-stop-daemon --start -x /usr/sbin/ntpd -- -u ntp:ntp -p /var/run/ntp.pid "$@"
+- echo "done"
++ /usr/sbin/start-stop-daemon -N -20 --start -x /usr/sbin/ntpd --test -- -u ntp:ntp -p /var/run/ntp.pid "$@" \
++ || return 1
++ if ((GPSD_REQUIRED == 1)) && [[ -L /dev/gps0 ]] && [[ -f "${GNSSRST}" ]]; then
++ . /etc/default/gpsd
++ # Could not get ntpd -gq to work with the GPS.
++ # So read the GPS time directly and set the system
++ # clock.
++ if ((SET_SYSTEM_CLOCK == 1)) && /usr/sbin/gpsd_ubx_settime ; then
++ # System time set by the GPS.
++ /usr/sbin/start-stop-daemon -N -20 --start -x /usr/sbin/ntpd -- -u ntp:ntp -p /var/run/ntp.pid "$@"
++ else
++ # Need a GPS fix before startint ntp.
++ /usr/sbin/start-stop-daemon -b -n z1e9d3qb -N -20 --start -x /bin/bash -- -c "sleep $GPSD_WAIT_TIME;/etc/init.d/ntpd start"
++ fi
++ else
++ if ((SET_SYSTEM_CLOCK == 1)) ; then
++ ntpd -gq
++ shift
++ fi
++
++ # The -g option allows ntpd to step the time to correct it just
++ # once. The daemon will exit if the clock drifts too much after
++ # this. If ntpd seems to disappear after a while assume TICKADJ
++ # above is set to a totally incorrect value.
++ /usr/sbin/start-stop-daemon -N -20 --start -x /usr/sbin/ntpd -- -u ntp:ntp -p /var/run/ntp.pid "$@"
++ fi
+ }
+ stopdaemon(){
+ echo -n "Stopping ntpd: "