diff options
author | John Klug <john.klug@multitech.com> | 2018-02-26 12:14:33 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2018-02-26 12:14:33 -0600 |
commit | 78bc4779060e71824740fc66777fd243bb96b96c (patch) | |
tree | 5933e5f9b6d01c90bf30b75c1e38225139c3e6cd /recipes-support/ntp | |
parent | 405147cbb51f85ab50fac961e06abd3c769e65c7 (diff) | |
download | meta-mlinux-78bc4779060e71824740fc66777fd243bb96b96c.tar.gz meta-mlinux-78bc4779060e71824740fc66777fd243bb96b96c.tar.bz2 meta-mlinux-78bc4779060e71824740fc66777fd243bb96b96c.zip |
Add some optional debug to /etc/init.d/ntpd
Diffstat (limited to 'recipes-support/ntp')
-rw-r--r-- | recipes-support/ntp/files/ntpd-init.patch | 160 |
1 files changed, 149 insertions, 11 deletions
diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch index 1890e07..e7667bc 100644 --- a/recipes-support/ntp/files/ntpd-init.patch +++ b/recipes-support/ntp/files/ntpd-init.patch @@ -1,6 +1,135 @@ -diff -Naru old/ntpd up/ntpd ---- old/ntpd 2017-05-30 11:08:30.368920821 -0500 -+++ up/ntpd 2017-05-30 11:52:42.965527343 -0500 +diff -Naru orig/mtadm@pand: new/mtadm@pand: +--- orig/mtadm@pand: 1969-12-31 18:00:00.000000000 -0600 ++++ new/mtadm@pand: 2018-02-26 11:36:57.317460809 -0600 +@@ -0,0 +1,125 @@ ++#! /bin/bash ++ ++### BEGIN INIT INFO ++# Provides: ntp ++# Required-Start: $network $remote_fs $syslog ++# Required-Stop: $network $remote_fs $syslog ++# Default-Start: 2 3 4 5 ++# Default-Stop: ++# 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 ++ ++# ntpd init.d script for ntpdc from ntp.isc.org ++test -x $DAEMON -a -r /etc/ntp.conf || exit 0 ++ ++# rcS contains TICKADJ ++test -r /etc/default/rcS && . /etc/default/rcS ++ ++# Source function library. ++. /etc/init.d/functions ++ ++# 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 [[ -x /usr/sbin/gpsd_ubx_settime ]] && ((GPSD_REQUIRED == 1)) && [[ -L /dev/gps0 ]] && [[ -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_ubx_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 ++ start-stop-daemon -N -20 --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -u ntp:ntp -p $PIDFILE "$@" ++ 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: " ++ start-stop-daemon --stop --quiet --oknodo -p $PIDFILE ++ echo "done" ++} ++ ++case "$1" in ++ start) ++ 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 ++ ;; ++ 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 ++ ;; ++ status) ++ status /usr/sbin/ntpd; ++ exit $? ++ ;; ++ *) ++ echo "Usage: ntpd { start | stop | status | restart | reload }" >&2 ++ exit 1 ++ ;; ++esac ++ ++exit 0 +diff -Naru orig/ntpd new/ntpd +--- orig/ntpd 2018-02-26 09:29:21.561687456 -0600 ++++ new/ntpd 2018-02-26 12:10:07.113401901 -0600 @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash @@ -17,7 +146,7 @@ diff -Naru old/ntpd up/ntpd DAEMON=/usr/sbin/ntpd PIDFILE=/var/run/ntpd.pid -@@ -34,13 +36,35 @@ +@@ -34,13 +36,40 @@ } } startdaemon(){ @@ -32,27 +161,32 @@ diff -Naru old/ntpd up/ntpd + || return 1 + if [[ -x /usr/sbin/gpsd_ubx_settime ]] && ((GPSD_REQUIRED == 1)) && [[ -L /dev/gps0 ]] && [[ -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_ubx_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 -+ # 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 -N -20 --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -u ntp:ntp -p $PIDFILE "$@" + echo "done" @@ -60,10 +194,12 @@ diff -Naru old/ntpd up/ntpd } stopdaemon(){ echo -n "Stopping ntpd: " -@@ -50,6 +74,20 @@ +@@ -50,8 +79,22 @@ case "$1" in start) +- settick +- startdaemon -g + if ! [[ $ENABLED =~ ^[yY][eE][sS]$ ]] ; then + exit 0 + fi @@ -78,6 +214,8 @@ diff -Naru old/ntpd up/ntpd + chown ntp:ntp ${STATSDIR} >/dev/null 2>&1 + fi + fi - settick - startdaemon -g ++ settick ++ startdaemon -g $CONFIGOPT ;; + stop) + stopdaemon |