From 966a43ef05d4f2a47535e7db42e5ce53500795a0 Mon Sep 17 00:00:00 2001 From: John Klug Date: Thu, 2 Feb 2017 19:15:04 -0600 Subject: create statsdir, drift file for ntp --- recipes-support/ntp/files/ntpd-init.patch | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'recipes-support/ntp/files/ntpd-init.patch') 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 -- cgit v1.2.3 From efbee987abfb77ac30d7e482736c53146e685bc5 Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 3 Feb 2017 12:45:28 -0600 Subject: Add ntpd -gq to set the clock from the GPS --- recipes-support/ntp/files/ntpd-init.patch | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'recipes-support/ntp/files/ntpd-init.patch') diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch index 9516084..3ff2823 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-02-02 18:00:38.415645575 -0600 -+++ new/ntpd 2017-02-02 19:01:39.766215168 -0600 +--- old/ntpd 2017-02-03 10:11:28.136849640 -0600 ++++ new/ntpd 2017-02-03 10:33:58.537991855 -0600 @@ -1,6 +1,8 @@ -#! /bin/sh +#! /bin/bash @@ -11,7 +11,7 @@ diff -Naur old/ntpd new/ntpd # 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 @@ +@@ -18,13 +20,29 @@ } } startdaemon(){ @@ -26,32 +26,29 @@ diff -Naur old/ntpd new/ntpd + || 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. ++ # System time set by the GPS. Should be within 2 seconds. ++ # -x option below allows 600 seconds of error. Without -x ++ # we need 128mS accurace, which is not provided by ++ # gpsd_ubx_settime. ++ ntpd -gq + /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. ++ # 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 + if ((SET_SYSTEM_CLOCK == 1)) ; then ++ # Sets the clock and exits. + 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,38 @@ +@@ -34,24 +52,38 @@ case "$1" in start) -- cgit v1.2.3 From 5a7f59302b63aad3b09772bf5bf9b55d78f10399 Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 3 Feb 2017 13:21:46 -0600 Subject: Remove redundant ntpd -gq --- recipes-support/ntp/files/ntpd-init.patch | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'recipes-support/ntp/files/ntpd-init.patch') diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch index 3ff2823..d1c3a84 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-02-03 10:11:28.136849640 -0600 -+++ new/ntpd 2017-02-03 10:33:58.537991855 -0600 ++++ new/ntpd 2017-02-03 13:19:42.629257684 -0600 @@ -1,6 +1,8 @@ -#! /bin/sh +#! /bin/bash @@ -11,7 +11,7 @@ diff -Naur old/ntpd new/ntpd # 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,29 @@ +@@ -18,13 +20,25 @@ } } startdaemon(){ @@ -27,11 +27,7 @@ diff -Naur old/ntpd new/ntpd + if ((GPSD_REQUIRED == 1)) && [[ -L /dev/gps0 ]] && [[ -f "${GNSSRST}" ]]; then + . /etc/default/gpsd + if ((SET_SYSTEM_CLOCK == 1)) && /usr/sbin/gpsd_ubx_settime ; then -+ # System time set by the GPS. Should be within 2 seconds. -+ # -x option below allows 600 seconds of error. Without -x -+ # we need 128mS accurace, which is not provided by -+ # gpsd_ubx_settime. -+ ntpd -gq ++ # System time was just 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. Try again later. @@ -48,7 +44,7 @@ diff -Naur old/ntpd new/ntpd } stopdaemon(){ echo -n "Stopping ntpd: " -@@ -34,24 +52,38 @@ +@@ -34,24 +48,38 @@ case "$1" in start) -- cgit v1.2.3 From 8097da2837488c31472d29f28a5585058ccf846f Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 3 Feb 2017 18:16:48 -0600 Subject: ntpd -pq added back in --- recipes-support/ntp/files/ntpd-init.patch | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'recipes-support/ntp/files/ntpd-init.patch') diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch index d1c3a84..42fbbe5 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-02-03 10:11:28.136849640 -0600 -+++ new/ntpd 2017-02-03 13:19:42.629257684 -0600 ++++ new/ntpd 2017-02-03 10:33:58.537991855 -0600 @@ -1,6 +1,8 @@ -#! /bin/sh +#! /bin/bash @@ -11,7 +11,7 @@ diff -Naur old/ntpd new/ntpd # 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,25 @@ +@@ -18,13 +20,29 @@ } } startdaemon(){ @@ -27,7 +27,11 @@ diff -Naur old/ntpd new/ntpd + if ((GPSD_REQUIRED == 1)) && [[ -L /dev/gps0 ]] && [[ -f "${GNSSRST}" ]]; then + . /etc/default/gpsd + if ((SET_SYSTEM_CLOCK == 1)) && /usr/sbin/gpsd_ubx_settime ; then -+ # System time was just set by the GPS. ++ # 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 + /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. Try again later. @@ -44,7 +48,7 @@ diff -Naur old/ntpd new/ntpd } stopdaemon(){ echo -n "Stopping ntpd: " -@@ -34,24 +48,38 @@ +@@ -34,24 +52,38 @@ case "$1" in start) -- cgit v1.2.3 From 0dd115625c6e0d57796cb43e22513dab1577bb80 Mon Sep 17 00:00:00 2001 From: John Klug Date: Mon, 6 Feb 2017 09:31:03 -0600 Subject: Do not error if gpsd is not installed --- recipes-support/ntp/files/ntpd-init.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'recipes-support/ntp/files/ntpd-init.patch') diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch index 42fbbe5..2ef7e0b 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-02-03 10:11:28.136849640 -0600 -+++ new/ntpd 2017-02-03 10:33:58.537991855 -0600 +--- old/ntpd 2017-02-06 09:21:52.607908299 -0600 ++++ new/ntpd 2017-02-06 09:22:52.417169090 -0600 @@ -1,6 +1,8 @@ -#! /bin/sh +#! /bin/bash @@ -24,7 +24,7 @@ diff -Naur old/ntpd new/ntpd - 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 ++ if [[ -x /usr/sbin/gpsd_ubx_settime ]] && ((GPSD_REQUIRED == 1)) && [[ -L /dev/gps0 ]] && [[ -f "${GNSSRST}" ]]; then + . /etc/default/gpsd + if ((SET_SYSTEM_CLOCK == 1)) && /usr/sbin/gpsd_ubx_settime ; then + # We just set the system time by the GPS. Should be within 2 seconds. -- cgit v1.2.3