summaryrefslogtreecommitdiff
path: root/recipes-support/ntp
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2019-12-20 17:08:27 -0600
committerJohn Klug <john.klug@multitech.com>2019-12-20 17:08:27 -0600
commit63517b9a1cc2bae8280ae7f977c545f58f2d86c1 (patch)
treed9cf508ebb224541a290ced020d646fe630dc04c /recipes-support/ntp
parente1d699cac9b3ead2da7c7904a873fca6674e9e4d (diff)
downloadmeta-mlinux-63517b9a1cc2bae8280ae7f977c545f58f2d86c1.tar.gz
meta-mlinux-63517b9a1cc2bae8280ae7f977c545f58f2d86c1.tar.bz2
meta-mlinux-63517b9a1cc2bae8280ae7f977c545f58f2d86c1.zip
Do not start ntpd without GPS unless configured
Diffstat (limited to 'recipes-support/ntp')
-rw-r--r--recipes-support/ntp/files/ntpd-init.patch31
-rw-r--r--recipes-support/ntp/ntp_%.bbappend4
2 files changed, 29 insertions, 6 deletions
diff --git a/recipes-support/ntp/files/ntpd-init.patch b/recipes-support/ntp/files/ntpd-init.patch
index e3107e1..3f8129a 100644
--- a/recipes-support/ntp/files/ntpd-init.patch
+++ b/recipes-support/ntp/files/ntpd-init.patch
@@ -1,6 +1,6 @@
diff -Naru orig/ntpd new/ntpd
---- orig/ntpd 2019-03-18 10:49:41.255374972 -0500
-+++ new/ntpd 2019-03-18 11:36:56.635291031 -0500
+--- 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
@@ -17,7 +17,28 @@ diff -Naru orig/ntpd new/ntpd
DAEMON=/usr/sbin/ntpd
PIDFILE=/var/run/ntpd.pid
-@@ -34,13 +36,40 @@
+@@ -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(){
@@ -30,7 +51,7 @@ diff -Naru orig/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 [[ -x /usr/sbin/gpsd_settime ]] && ((GPSD_REQUIRED == 1)) && (( $(/usr/sbin/mts-io-sysfs show capability/gps) == 1 )) && [[ -f "${GNSSRST}" ]]; then
++ 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
@@ -65,7 +86,7 @@ diff -Naru orig/ntpd new/ntpd
}
stopdaemon(){
echo -n "Stopping ntpd: "
-@@ -50,8 +79,22 @@
+@@ -50,8 +93,22 @@
case "$1" in
start)
diff --git a/recipes-support/ntp/ntp_%.bbappend b/recipes-support/ntp/ntp_%.bbappend
index c69eff0..436164a 100644
--- a/recipes-support/ntp/ntp_%.bbappend
+++ b/recipes-support/ntp/ntp_%.bbappend
@@ -1,4 +1,4 @@
-PR .= ".mlinux5"
+PR .= ".mlinux6"
SRC_URI += " file://ntpd-default \
file://ntp.conf.patch;patchdir=.. \
@@ -23,6 +23,8 @@ do_install_append() {
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