summaryrefslogtreecommitdiff
path: root/recipes-support/ntp/files/ntpd-init.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-support/ntp/files/ntpd-init.patch')
-rw-r--r--recipes-support/ntp/files/ntpd-init.patch96
1 files changed, 96 insertions, 0 deletions
diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch
new file mode 100644
index 0000000..2ef7e0b
--- /dev/null
+++ b/recipes-support/ntp/files/ntpd-init.patch
@@ -0,0 +1,96 @@
+diff -Naur old/ntpd new/ntpd
+--- 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
+ #
++. /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,29 @@
+ }
+ }
+ 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 [[ -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.
++ # 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.
++ /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
++ /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 +52,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 $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
+ ;;