summaryrefslogtreecommitdiff
path: root/recipes-support/ntp
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2017-01-17 14:32:25 -0600
committerJason Reiss <jreiss@multitech.com>2017-01-17 14:32:25 -0600
commitbf44a677041abcef9f224de290fcd5ad4cf37ea8 (patch)
tree263308ac22db5128374d26c857d12d1a79a251e8 /recipes-support/ntp
parente16cbd0bf5b2985cd78a26a82868d5cd3eb96da2 (diff)
parent3959907c3a6a8d78368de3c624155260a2d418fe (diff)
downloadmeta-mlinux-bf44a677041abcef9f224de290fcd5ad4cf37ea8.tar.gz
meta-mlinux-bf44a677041abcef9f224de290fcd5ad4cf37ea8.tar.bz2
meta-mlinux-bf44a677041abcef9f224de290fcd5ad4cf37ea8.zip
Merge branch 'master' of gitlab.multitech.net:mirrors/meta-mlinux
Diffstat (limited to 'recipes-support/ntp')
-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
-rw-r--r--recipes-support/ntp/ntp_4.2.6p5.bbappend46
4 files changed, 181 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: "
diff --git a/recipes-support/ntp/ntp_4.2.6p5.bbappend b/recipes-support/ntp/ntp_4.2.6p5.bbappend
new file mode 100644
index 0000000..b656256
--- /dev/null
+++ b/recipes-support/ntp/ntp_4.2.6p5.bbappend
@@ -0,0 +1,46 @@
+PR .= ".mlinux1"
+
+SRC_URI += " file://ntpd-init.patch;patchdir=.. \
+ file://ntp.conf.patch;patchdir=.. \
+ file://ntpd-default \
+ "
+FILESEXTRAPATHS_prepend := "${THISDIR}/files"
+
+python do_patch_prepend () {
+ import os
+}
+pkg_postinst_${PN} () {
+ sdir=/var/log/ntpstats
+ if ! [[ -d ${sdir} ]] ; then
+ mkdir -p ${sdir}
+ fi
+ chown ntp:ntp ${sdir}
+ chmod 775 ${sdir}
+
+ drdir=/var/lib/ntp
+ if ! [[ -d ${drdir} ]] ; then
+ mkdir -p ${drdir}
+ fi
+ drfile="${drdir}/ntp.drift"
+ touch ${drfile}
+ chmod 664 ${drfile}
+ chown -R ntp:ntp ${drdir}
+}
+
+
+do_install_prepend() {
+ echo JAK In do_install_append in directory $(pwd), and D is ${D}
+ echo JAK In do_install_append sysconfdir is ${sysconfdir}
+ install -d ${D}${sysconfdir}/default
+ install -m 0644 ${WORKDIR}/ntpd-default ${D}${sysconfdir}/default/ntpd.default
+ echo JAK In do_install_append default is $(ls ${D}cd${sysconfdir}/default/ntpd.default)
+}
+pkg_postinst_${PN}() {
+ update-alternatives --install ${sysconfdir}/default/ntpd ntpd-defaults ${sysconfdir}/default/ntpd.default 10
+}
+
+pkg_postrm_${PN}() {
+ update-alternatives --remove ntpd-defaults ${sysconfdir}/default/ntpd.default
+}
+FILES_${PN} += "${sysconfdir}/default/ntpd.default"
+CONFFILES_${PN} += "${sysconfdir}/default/ntpd.default"