summaryrefslogtreecommitdiff
path: root/recipes-support/ntp
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2017-02-02 19:15:04 -0600
committerJohn Klug <john.klug@multitech.com>2017-02-02 19:15:04 -0600
commit966a43ef05d4f2a47535e7db42e5ce53500795a0 (patch)
tree0c271da411c8586404b56636cfd9dac1db46d1f6 /recipes-support/ntp
parent511a09c088ffcca591b8793a9d1ad7e4f9ff3994 (diff)
downloadmeta-mlinux-966a43ef05d4f2a47535e7db42e5ce53500795a0.tar.gz
meta-mlinux-966a43ef05d4f2a47535e7db42e5ce53500795a0.tar.bz2
meta-mlinux-966a43ef05d4f2a47535e7db42e5ce53500795a0.zip
create statsdir, drift file for ntp
Diffstat (limited to 'recipes-support/ntp')
-rw-r--r--recipes-support/ntp/files/ntp.conf.patch23
-rw-r--r--recipes-support/ntp/files/ntp.init.patch190
-rw-r--r--recipes-support/ntp/files/ntpd-default2
-rw-r--r--recipes-support/ntp/files/ntpd-init.patch20
-rw-r--r--recipes-support/ntp/ntp_4.2.6p5.bbappend25
5 files changed, 221 insertions, 39 deletions
diff --git a/recipes-support/ntp/files/ntp.conf.patch b/recipes-support/ntp/files/ntp.conf.patch
index 2d0fdd8..bb1dcfe 100644
--- a/recipes-support/ntp/files/ntp.conf.patch
+++ b/recipes-support/ntp/files/ntp.conf.patch
@@ -1,7 +1,7 @@
diff -Naur old/ntp.conf new/ntp.conf
---- old/ntp.conf 2017-02-01 12:51:59.766760466 -0600
-+++ new/ntp.conf 2017-02-01 14:46:23.005239689 -0600
-@@ -1,16 +1,58 @@
+--- old/ntp.conf 2017-02-02 19:09:54.524791189 -0600
++++ new/ntp.conf 2017-02-02 19:06:41.744669788 -0600
+@@ -1,16 +1,47 @@
-# 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
@@ -11,6 +11,9 @@ diff -Naur old/ntp.conf new/ntp.conf
+
+# The following code is for evaluating the timeserver.
+# Remove the # to activate the statistics
++# statsdir must start in column 1 for the initscript to
++# create the directory, in case it is volatile.
++#
+# statistics loopstats
+# statistics peerstats
+# statsdir /var/log/ntpstats
@@ -36,24 +39,10 @@ diff -Naur old/ntp.conf new/ntp.conf
+
+# GPS Serial data reference (NTP0)
+# This sets the GPS 50 milliseconds slower than the PPS.
-+# "true" says we don't trust the system clock.
-+# If we are depending on the GPS for timing,
-+# we don't want ntp to mark the GPS as a falseticker
-+# because of a performance issue.
-+# If the GPS is marked as a false ticker
-+# due to a bad timestamp from the system
-+# clock (possibly because the system was
-+# too busy to process an interrupt),
-+# the GPS will be ignored, and if we are
-+# depending on the GPS for leap second, it
-+# will not happen.
+server 127.127.28.0 true
+fudge 127.127.28.0 time1 0.050 refid GPS
+
+# GPS PPS reference (NTP2)
-+# If we are depending on the PPS for timing,
-+# we don't want ntp to mark the PPS as a falseticker
-+# because of a performance issue.
+server 127.127.28.2 prefer true
+fudge 127.127.28.2 time1 0.000 refid PPS
+
diff --git a/recipes-support/ntp/files/ntp.init.patch b/recipes-support/ntp/files/ntp.init.patch
new file mode 100644
index 0000000..b60d8ca
--- /dev/null
+++ b/recipes-support/ntp/files/ntp.init.patch
@@ -0,0 +1,190 @@
+diff -Naur old/ntpd new/ntpd
+--- old/ntpd 2017-02-02 18:00:38.415645575 -0600
++++ new/ntpd 2017-02-02 18:14:50.986092592 -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: "
+@@ -34,24 +55,37 @@
+
+ case "$1" in
+ start)
+- settick
+- startdaemon -g
++ if ! [[ $ENABLED =~ ^[yY][eE][sS]$ ]] ; then
++ exit 0
++ fi
++ if [[ -n "$CONFIGFILE" ]] ; then
++ $CONFIGOPT="-c ${CONFIGFILE}"
++ STATSDIR=$(grep "^statsdir" ${CONFIGFILE} | sed -r 's/[^[:SPACE:]]+[[:SPACE:]]//')
++ if ! [[ -d ${STATSDIR} ]] ; then
++ mkdir -m 0755 -p ${STATSDIR}
++ fi
++ if [[ -d ${STATSDIR} ]] ; then
++ chown ntp:ntp ${STATSDIR}
++ fi
++ fi
++ settick
++ startdaemon -g $CONFIGOPT
+ ;;
+ stop)
+- stopdaemon
++ stopdaemon
+ ;;
+ force-reload)
+- stopdaemon
+- settick
++ stopdaemon
++ settick
+ startdaemon -g
+ ;;
+ restart)
+- # Don't reset the tick here
++ # Don't reset the tick here
+ stopdaemon
+ startdaemon -g
+ ;;
+ reload)
+- # Must do this by hand, but don't do -g
++ # Must do this by hand, but don't do -g
+ stopdaemon
+ startdaemon
+ ;;
+diff -Naur old/ntpd.orig new/ntpd.orig
+--- old/ntpd.orig 2017-02-02 17:58:25.316767036 -0600
++++ new/ntpd.orig 1969-12-31 18:00:00.000000000 -0600
+@@ -1,88 +0,0 @@
+-#! /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
+-# rcS contains TICKADJ
+-test -r /etc/default/rcS && . /etc/default/rcS
+-
+-# Functions to do individual actions
+-settick(){
+- # If TICKADJ is set we *must* adjust it before we start, because the
+- # driftfile relies on the correct setting
+- test -n "$TICKADJ" -a -x /usr/sbin/tickadj && {
+- echo -n "Setting tick to $TICKADJ: "
+- /usr/sbin/tickadj "$TICKADJ"
+- echo "done"
+- }
+-}
+-startdaemon(){
+- /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: "
+- start-stop-daemon --stop -p /var/run/ntp.pid
+- echo "done"
+-}
+-
+-case "$1" in
+- start)
+- if ! [[ $ENABLED =~ ^[yY][eE][sS]$ ]] ; then
+- exit 0
+- fi
+- settick
+- startdaemon -g
+- ;;
+- stop)
+- stopdaemon
+- ;;
+- force-reload)
+- stopdaemon
+- settick
+- startdaemon -g
+- ;;
+- restart)
+- # Don't reset the tick here
+- stopdaemon
+- startdaemon -g
+- ;;
+- reload)
+- # Must do this by hand, but don't do -g
+- stopdaemon
+- startdaemon
+- ;;
+- *)
+- echo "Usage: ntpd { start | stop | restart | reload }" >&2
+- exit 1
+- ;;
+-esac
+-
+-exit 0
diff --git a/recipes-support/ntp/files/ntpd-default b/recipes-support/ntp/files/ntpd-default
index 65e2119..ed7a6ec 100644
--- a/recipes-support/ntp/files/ntpd-default
+++ b/recipes-support/ntp/files/ntpd-default
@@ -1,5 +1,7 @@
ENABLED="yes"
+CONFIGFILE=/etc/ntp.conf
+
# The GPSD_* parameters in this file are ignored
# if the uBlox GPS is not present.
diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch
index 41c7549..9516084 100644
--- a/recipes-support/ntp/files/ntpd-init.patch
+++ b/recipes-support/ntp/files/ntpd-init.patch
@@ -1,6 +1,6 @@
diff -Naur old/ntpd new/ntpd
---- old/ntpd 2017-01-17 16:26:47.427368196 -0600
-+++ new/ntpd 2017-01-20 16:26:52.154738981 -0600
+--- old/ntpd 2017-02-02 18:00:38.415645575 -0600
++++ new/ntpd 2017-02-02 19:01:39.766215168 -0600
@@ -1,6 +1,8 @@
-#! /bin/sh
+#! /bin/bash
@@ -51,16 +51,28 @@ diff -Naur old/ntpd new/ntpd
}
stopdaemon(){
echo -n "Stopping ntpd: "
-@@ -34,24 +55,27 @@
+@@ -34,24 +55,38 @@
case "$1" in
start)
- settick
+- startdaemon -g
+ if ! [[ $ENABLED =~ ^[yY][eE][sS]$ ]] ; then
+ exit 0
+ fi
++ if [[ -n "$CONFIGFILE" ]] ; then
++ CONFIGOPT="-c ${CONFIGFILE}"
++ STATSDIR=$(grep "^statsdir" ${CONFIGFILE} | sed -r 's/[^[:space:]]+[[:space:]]//')
++ if ((${#STATSDIR} > 0)) && ! [[ -d ${STATSDIR} ]] ; then
++ echo Make ${STATSDIR}
++ mkdir -m 0755 -p ${STATSDIR}
++ fi
++ if [[ -d ${STATSDIR} ]] ; then
++ chown ntp:ntp ${STATSDIR} >/dev/null 2>&1
++ fi
++ fi
+ settick
- startdaemon -g
++ startdaemon -g $CONFIGOPT
;;
stop)
- stopdaemon
diff --git a/recipes-support/ntp/ntp_4.2.6p5.bbappend b/recipes-support/ntp/ntp_4.2.6p5.bbappend
index a72f7bd..8460fda 100644
--- a/recipes-support/ntp/ntp_4.2.6p5.bbappend
+++ b/recipes-support/ntp/ntp_4.2.6p5.bbappend
@@ -10,29 +10,18 @@ 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
+do_install_append() {
+ install -d ${D}${sysconfdir}/default
+ install -m 0644 ${WORKDIR}/ntpd-default ${D}${sysconfdir}/default/ntpd.default
+
+ drdir=${D}${localstatedir}/lib/ntp
+ install -d -m 0755 -p ${drdir}
drfile="${drdir}/ntp.drift"
touch ${drfile}
chmod 664 ${drfile}
chown -R ntp:ntp ${drdir}
}
-
-
-do_install_prepend() {
- install -d ${D}${sysconfdir}/default
- install -m 0644 ${WORKDIR}/ntpd-default ${D}${sysconfdir}/default/ntpd.default
-}
pkg_postinst_${PN}_append() {
update-alternatives --install ${sysconfdir}/default/ntpd ntpd-defaults ${sysconfdir}/default/ntpd.default 10
}
@@ -40,5 +29,5 @@ pkg_postinst_${PN}_append() {
pkg_postrm_${PN}_append() {
update-alternatives --remove ntpd-defaults ${sysconfdir}/default/ntpd.default
}
-FILES_${PN} += "${sysconfdir}/default/ntpd.default"
+FILES_${PN} += "${sysconfdir}/default/ntpd.default ${localstatedir}/lib/*"
CONFFILES_${PN} += "${sysconfdir}/default/ntpd.default"