diff options
author | John Klug <john.klug@multitech.com> | 2017-01-23 12:32:29 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2017-01-23 12:32:29 -0600 |
commit | 077ac5882dac3d1ff33af36550df173bb5af8217 (patch) | |
tree | 17364c835c8fed319548b1fa127de48d81eaa6f1 /recipes-support | |
parent | d35110e29ce7806177b2e15704fca18896881b7d (diff) | |
parent | 599b7325d9eec4eeaf818ff9bd8f5f7a3d7638e2 (diff) | |
download | meta-mlinux-077ac5882dac3d1ff33af36550df173bb5af8217.tar.gz meta-mlinux-077ac5882dac3d1ff33af36550df173bb5af8217.tar.bz2 meta-mlinux-077ac5882dac3d1ff33af36550df173bb5af8217.zip |
Merge branch 'master' of gitlab.multitech.net:mirrors/meta-mlinux
Diffstat (limited to 'recipes-support')
-rw-r--r-- | recipes-support/ntp/files/ntp.conf.patch | 17 | ||||
-rw-r--r-- | recipes-support/ntp/files/ntpd-default | 33 | ||||
-rw-r--r-- | recipes-support/ntp/files/ntpd-init.patch | 92 | ||||
-rw-r--r-- | recipes-support/ntp/ntp_4.2.6p5.bbappend | 18 |
4 files changed, 143 insertions, 17 deletions
diff --git a/recipes-support/ntp/files/ntp.conf.patch b/recipes-support/ntp/files/ntp.conf.patch index 499dac5..2fd26ef 100644 --- a/recipes-support/ntp/files/ntp.conf.patch +++ b/recipes-support/ntp/files/ntp.conf.patch @@ -1,7 +1,7 @@ -diff -u old/ntp.conf new/ntp.conf ---- old/ntp.conf 2016-12-21 08:36:33.887646960 -0600 -+++ new/ntp.conf 2016-12-21 08:37:41.115645756 -0600 -@@ -1,7 +1,20 @@ +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 @@ -23,22 +23,21 @@ diff -u old/ntp.conf new/ntp.conf + # 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 -@@ -9,8 +22,26 @@ +-# Unless you un-comment the line below ntpd will sync +-# only against the local system clock. # # server time.server.example.com # + -+logfile /var/log/ntp.log -+ +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 50 milliseconds slower than the PPS. +server 127.127.28.0 -+fudge 127.127.28.0 time1 0.080 refid GPS ++fudge 127.127.28.0 time1 0.050 refid GPS + +# GPS PPS reference (NTP2) +server 127.127.28.2 prefer diff --git a/recipes-support/ntp/files/ntpd-default b/recipes-support/ntp/files/ntpd-default new file mode 100644 index 0000000..65e2119 --- /dev/null +++ b/recipes-support/ntp/files/ntpd-default @@ -0,0 +1,33 @@ +ENABLED="yes" + +# 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 index fc388f8..41c7549 100644 --- a/recipes-support/ntp/files/ntpd-init.patch +++ b/recipes-support/ntp/files/ntpd-init.patch @@ -1,11 +1,87 @@ ---- old/ntpd 2016-12-19 18:11:58.022663976 -0600 -+++ new/ntpd 2016-12-19 18:12:56.618663852 -0600 -@@ -23,7 +23,7 @@ - # this. If ntpd seems to disappear after a while assume TICKADJ - # above is set to a totally incorrect value. - echo -n "Starting ntpd: " +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 +@@ -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 "$@" -+ start-stop-daemon -N -20 --start -x /usr/sbin/ntpd -- -u ntp:ntp -p /var/run/ntp.pid "$@" - echo "done" +- 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,27 @@ + + case "$1" in + start) +- settick ++ if ! [[ $ENABLED =~ ^[yY][eE][sS]$ ]] ; then ++ exit 0 ++ fi ++ settick + startdaemon -g + ;; + 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 --git a/recipes-support/ntp/ntp_4.2.6p5.bbappend b/recipes-support/ntp/ntp_4.2.6p5.bbappend index 7928608..b656256 100644 --- a/recipes-support/ntp/ntp_4.2.6p5.bbappend +++ b/recipes-support/ntp/ntp_4.2.6p5.bbappend @@ -2,6 +2,7 @@ PR .= ".mlinux1" SRC_URI += " file://ntpd-init.patch;patchdir=.. \ file://ntp.conf.patch;patchdir=.. \ + file://ntpd-default \ " FILESEXTRAPATHS_prepend := "${THISDIR}/files" @@ -26,3 +27,20 @@ pkg_postinst_${PN} () { 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" |