summaryrefslogtreecommitdiff
path: root/recipes-support/ntp
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-support/ntp')
-rw-r--r--recipes-support/ntp/files/logtime.patch73
-rw-r--r--recipes-support/ntp/files/ntp.conf.patch69
-rw-r--r--recipes-support/ntp/files/ntpd-default35
-rw-r--r--recipes-support/ntp/files/ntpd-init.patch113
-rw-r--r--recipes-support/ntp/ntp_%.bbappend37
5 files changed, 0 insertions, 327 deletions
diff --git a/recipes-support/ntp/files/logtime.patch b/recipes-support/ntp/files/logtime.patch
deleted file mode 100644
index bb253f4..0000000
--- a/recipes-support/ntp/files/logtime.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-# The logtime test is used to compare the kernel realtime
-# clock and the kernel monotonic clock, so that leap
-# second may be observed.
-diff -Naru old/tests/ntpd/logtime.c new/tests/ntpd/logtime.c
---- old/tests/ntpd/logtime.c 1969-12-31 18:00:00.000000000 -0600
-+++ new/tests/ntpd/logtime.c 2017-05-30 13:22:11.827179154 -0500
-@@ -0,0 +1,44 @@
-+#include <time.h>
-+#include <stdio.h>
-+#include <unistd.h>
-+#include <stdarg.h>
-+#include <syslog.h>
-+/*
-+ * Generate a log messages 4 times per second
-+ * to verify leap second. The CLOCK_MONOTONIC_RAW
-+ * is the time since boot unaffected by adjustments.
-+ *
-+ * CLOCK_REALTIME is the UTC clock, which is affected
-+ * by leap seconds.
-+ *
-+ * Program does not exit.
-+ *
-+ */
-+main()
-+{
-+ openlog("CTST",0,LOG_LOCAL2);
-+ while(1) {
-+ struct timespec ts,unused,ep;
-+ if (clock_gettime(CLOCK_MONOTONIC,&ts) == 0) {
-+
-+ if(ts.tv_nsec < 750000000)
-+ ts.tv_nsec += 250000000;
-+ else {
-+ ts.tv_nsec -= 750000000;
-+ ts.tv_sec += 1;
-+ }
-+ clock_nanosleep(CLOCK_MONOTONIC,TIMER_ABSTIME,&ts,&unused);
-+ clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
-+ ts.tv_nsec /= 1000000;
-+ clock_gettime(CLOCK_REALTIME,&ep);
-+ ep.tv_nsec /= 1000000;
-+ syslog(LOG_NOTICE,"epoch: %lu.%3.3ld boot: %lu.%3.3ld",
-+ ep.tv_sec,ep.tv_nsec,
-+ ts.tv_sec,ts.tv_nsec);
-+
-+ }
-+
-+
-+ }
-+
-+}
-diff -Naru old/tests/ntpd/Makefile.am new/tests/ntpd/Makefile.am
---- old/tests/ntpd/Makefile.am 2017-05-30 13:31:45.124160267 -0500
-+++ new/tests/ntpd/Makefile.am 2017-05-30 16:53:59.784755988 -0500
-@@ -29,6 +29,7 @@
- test-ntp_restrict \
- test-ntp_scanner \
- test-ntp_signd \
-+ logtime \
- $(NULL)
-
-
-@@ -191,8 +192,8 @@
- ## check-libntp.mf - automake fragment
- ## slightly adapted for deeper directory
-
--BUILT_SOURCES += check-libntpd check-libntp check-libunity
--CLEANFILES += check-libntpd check-libntp check-libunity
-+BUILT_SOURCES += check-libntpd check-libntp check-libunity logtime
-+CLEANFILES += check-libntpd check-libntp check-libunity logtime
-
- check-libntpd: ../../ntpd/libntpd.a
- @echo stamp > $@
diff --git a/recipes-support/ntp/files/ntp.conf.patch b/recipes-support/ntp/files/ntp.conf.patch
deleted file mode 100644
index 3d7a652..0000000
--- a/recipes-support/ntp/files/ntp.conf.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-diff -Naru old/ntp.conf new/ntp.conf
---- old/ntp.conf 2017-07-18 17:48:59.436221921 -0500
-+++ new/ntp.conf 2017-07-18 18:00:54.392325489 -0500
-@@ -1,17 +1,59 @@
--# 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 /var/lib/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
-+# 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
-+# 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 50 milliseconds slower than the PPS.
-+server 127.127.28.0 true
-+fudge 127.127.28.0 time1 0.050 refid GPS
-+
-+# GPS PPS reference (NTP2)
-+server 127.127.28.2 prefer true
-+fudge 127.127.28.2 time1 0.000 refid PPS
-+
-+# orphanwait says that after 30 seconds, we can't find a server, we
-+# will use the local clock. This means ntp will hang for 30 seconds
-+# during boot if we are not configured for an NTP server.
-+tos orphanwait 30
-+
- # Using local hardware clock as fallback
--# Disable this when using ntpd -q -g -x as ntpdate or it will sync to itself
--server 127.127.1.0
-+
-+# minpoll of 5 means 2^5 seconds or 32 seconds. So first we wait 30
-+# seconds if we can't get a response from another server, and then
-+# if we don't get the response, we will use the local clock after
-+# a 32 second poll interval. So the NTP will hold up the boot for
-+# 32 seconds if we don't have a good NTP server.
-+server 127.127.1.0 minpoll 5
-+# the local clock should always be set to a high stratum
-+# (low priority), since it
-+# is the system clock, which is not a good choice.
- fudge 127.127.1.0 stratum 14
- # Defining a default security setting
- restrict default
diff --git a/recipes-support/ntp/files/ntpd-default b/recipes-support/ntp/files/ntpd-default
deleted file mode 100644
index ed7a6ec..0000000
--- a/recipes-support/ntp/files/ntpd-default
+++ /dev/null
@@ -1,35 +0,0 @@
-ENABLED="yes"
-
-CONFIGFILE=/etc/ntp.conf
-
-# 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
deleted file mode 100644
index 3f8129a..0000000
--- a/recipes-support/ntp/files/ntpd-init.patch
+++ /dev/null
@@ -1,113 +0,0 @@
-diff -Naru orig/ntpd new/ntpd
---- orig/ntpd 2019-12-20 15:28:43.002031942 -0600
-+++ new/ntpd 2019-12-20 15:32:59.138024359 -0600
-@@ -1,4 +1,4 @@
--#! /bin/sh
-+#! /bin/bash
-
- ### BEGIN INIT INFO
- # Provides: ntp
-@@ -9,7 +9,9 @@
- # Short-Description: Start NTP daemon
- ### END INIT INFO
-
-+. /etc/default/ntpd
- PATH=/sbin:/bin:/usr/bin:/usr/sbin
-+GNSSRST=/sys/devices/platform/mts-io/gnss-reset
-
- DAEMON=/usr/sbin/ntpd
- PIDFILE=/var/run/ntpd.pid
-@@ -22,6 +24,20 @@
-
- # Source function library.
- . /etc/init.d/functions
-+has_gps=0
-+if [[ -f /sys/devices/platform/mts-io/capability/gps ]] ; then
-+ has_gps=$(cat /sys/devices/platform/mts-io/capability/gps)
-+fi
-+
-+if (( has_gps == 0 )) ; then
-+ if [[ -n ${CONFIGFILE_sha256} ]] ; then
-+ NEWCONFIGFILE_sha256=$(sha256sum $CONFIGFILE)
-+ if [[ $NEWCONFIGFILE_sha256 =~ $CONFIGFILE_sha256 ]] ; then
-+ logger -p daemon.notice -s -t etc_ntpd "No GPS, need to configure /etc/ntp.conf"
-+ exit 0
-+ fi
-+ fi
-+fi
-
- # Functions to do individual actions
- settick(){
-@@ -34,13 +50,40 @@
- }
- }
- 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 --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -u ntp:ntp -p $PIDFILE "$@"
-- 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 [[ -x /usr/sbin/gpsd_settime ]] && ((GPSD_REQUIRED == 1)) && (( has_gps == 1 )) && [[ -f "${GNSSRST}" ]]; then
-+ . /etc/default/gpsd
-+ [[ ${VERBOSE} != no ]] && logger -t 'etc_ntpd' -p daemon.info 'Have a GPS and it is required'
-+ if ((SET_SYSTEM_CLOCK == 1)) && /usr/sbin/gpsd_settime ; then
-+ [[ ${VERBOSE} != no ]] && logger -t 'etc_ntpd' -p daemon.info 'Need to set the time next with ntpd'
-+ # We just set the system time by the GPS. Should be within 2 seconds.
-+ # Now that we are close to the correct system time, we
-+ # use the ntpd one shot option to get to less than
-+ # 250mS error so that we don't waste time adjusting the clock.
-+ /usr/sbin/ntpd -gq
-+ echo -n "Starting ntpd: "
-+ start-stop-daemon -N -20 --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -u ntp:ntp -p $PIDFILE "$@"
-+ echo "done"
-+ else
-+ [[ ${VERBOSE} != no ]] && logger -t 'etc_ntpd' -p daemon.info 'Clock not set, try later'
-+ # Need a GPS fix before startint ntp. Try again later.
-+ /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
-+ # 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.
-+ if ((SET_SYSTEM_CLOCK == 1)) ; then
-+ # Sets the clock and exits.
-+ ntpd -gq
-+ shift
-+ fi
-+ echo -n "Starting ntpd: "
-+ start-stop-daemon -N -20 --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -u ntp:ntp -p $PIDFILE "$@"
-+ echo "done"
-+ fi
- }
- stopdaemon(){
- echo -n "Stopping ntpd: "
-@@ -50,8 +93,22 @@
-
- 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 $CONFIGOPT
- ;;
- stop)
- stopdaemon
diff --git a/recipes-support/ntp/ntp_%.bbappend b/recipes-support/ntp/ntp_%.bbappend
deleted file mode 100644
index 436164a..0000000
--- a/recipes-support/ntp/ntp_%.bbappend
+++ /dev/null
@@ -1,37 +0,0 @@
-PR .= ".mlinux6"
-
-SRC_URI += " file://ntpd-default \
- file://ntp.conf.patch;patchdir=.. \
- file://ntpd-init.patch;patchdir=.. \
- file://logtime.patch \
- "
-FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
-
-RDEPENDS_${PN} += "bash"
-
-python do_patch_prepend () {
- import os
-}
-
-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}
- tmp=$(sha256sum ${D}${sysconfdir}/ntp.conf | sed 's/ .*//')
- echo "CONFIGFILE_sha256=${tmp}" >> ${D}${sysconfdir}/default/ntpd.default
-}
-pkg_postinst_${PN}_append() {
- update-alternatives --install ${sysconfdir}/default/ntpd ntpd-defaults ${sysconfdir}/default/ntpd.default 10
-}
-
-pkg_postrm_${PN}_append() {
- update-alternatives --remove ntpd-defaults ${sysconfdir}/default/ntpd.default
-}
-FILES_${PN} += "${sysconfdir}/default/ntpd.default ${localstatedir}/lib/*"
-CONFFILES_${PN} += "${sysconfdir}/default/ntpd.default"