[oe-commits] Jeremy Lainé : ntp-4.2.4p7: invoke ntpdate using if-up .d, not an init script

git version control git at git.openembedded.org
Wed Nov 4 12:05:28 UTC 2009


Module: openembedded.git
Branch: martin_jansa/xorg-7.5
Commit: d62c9c524449adadd7af3bc76f1230e227b5b0c6
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=d62c9c524449adadd7af3bc76f1230e227b5b0c6

Author: Jeremy Lainé <jeremy.laine at m4x.org>
Date:   Tue Nov  3 17:20:53 2009 +0100

ntp-4.2.4p7: invoke ntpdate using if-up.d, not an init script

* provide an if-up.d script for ntpdate (based on Debian's)
* remove invocation of update-rc.d busybox-cron, this should
  definitely not be part of the ntpdate package

---

 recipes/ntp/ntp-4.2.4p7/ntpdate |   45 +++++++++++++++++++++++++++++++++++++++
 recipes/ntp/ntp_4.2.4p7.bb      |   10 ++++----
 2 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/recipes/ntp/ntp-4.2.4p7/ntpdate b/recipes/ntp/ntp-4.2.4p7/ntpdate
new file mode 100755
index 0000000..5b139ed
--- /dev/null
+++ b/recipes/ntp/ntp-4.2.4p7/ntpdate
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+PATH=/sbin:/bin:/usr/bin
+
+test -x /usr/bin/ntpdate || exit 0
+
+if test -f /etc/default/ntpdate ; then
+. /etc/default/ntpdate
+else
+NTPSERVERS="pool.ntp.org"
+fi
+
+test -n "$NTPSERVERS" || exit 0
+
+# This is a heuristic:  The idea is that if a static interface is brought
+# up, that is a major event, and we can put in some extra effort to fix
+# the system time.  Feel free to change this, especially if you regularly
+# bring up new network interfaces.
+if [ "$METHOD" = static ]; then
+	OPTS="-b"
+fi
+
+if [ "$METHOD" = loopback ]; then
+	exit 0
+fi
+
+(
+
+LOCKFILE=/var/lock/ntpdate
+
+# Avoid running more than one at a time
+if [ -x /usr/bin/lockfile-create ]; then
+	lockfile-create $LOCKFILE
+	lockfile-touch $LOCKFILE &
+	LOCKTOUCHPID="$!"
+fi
+
+/usr/bin/ntpdate -s $OPTS $NTPSERVERS 2>/dev/null || :
+
+if [ -x /usr/bin/lockfile-create ] ; then
+	kill $LOCKTOUCHPID
+	lockfile-remove $LOCKFILE
+fi
+
+) &
diff --git a/recipes/ntp/ntp_4.2.4p7.bb b/recipes/ntp/ntp_4.2.4p7.bb
index 5e24e8a..4109c40 100644
--- a/recipes/ntp/ntp_4.2.4p7.bb
+++ b/recipes/ntp/ntp_4.2.4p7.bb
@@ -1,6 +1,6 @@
 require ntp.inc
 
-PR = "r0"
+PR = "r1"
 
 SRC_URI = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/${P}.tar.gz \
 	file://tickadj.c.patch;patch=1 \
@@ -17,24 +17,24 @@ FILES_${PN}-bin = "${bindir}/ntp-wait ${bindir}/ntpdc ${bindir}/ntpq ${bindir}/n
 FILES_${PN} = "${bindir}/ntpd ${sysconfdir}/ntp.conf ${sysconfdir}/init.d/ntpd"
 FILES_${PN}-tickadj = "${bindir}/tickadj"
 FILES_ntp-utils = "${bindir}/*"
+FILES_ntpdate = "${bindir}/ntpdate ${sysconfdir}/network/if-up.d/ntpdate"
 
 do_install_append() {
 	install -d ${D}/${sysconfdir}/init.d
 	install -m 644 ${WORKDIR}/ntp.conf ${D}/${sysconfdir}
-	install -m 755 ${WORKDIR}/ntpdate ${D}/${sysconfdir}/init.d
 	install -m 755 ${WORKDIR}/ntpd ${D}/${sysconfdir}/init.d
+	install -d ${D}/${sysconfdir}/network/if-up.d
+	install -m 755 ${WORKDIR}/ntpdate ${D}/${sysconfdir}/network/if-up.d
 }
 
 pkg_postinst_ntpdate() {
 if test "x$D" != "x"; then
 	exit 1
 else
-	if ! grep -q ntpdate /etc/cron/crontabs/root; then
+	if ! grep -q -s ntpdate /etc/cron/crontabs/root; then
 		echo "adding crontab"
 		test -d /etc/cron/crontabs || mkdir -p /etc/cron/crontabs
 		echo "30 * * * *    /usr/bin/ntpdate -s -u pool.ntp.org" >> /etc/cron/crontabs/root
 	fi
-	update-rc.d -s busybox-cron defaults
-	update-rc.d -s ntpdate defaults 30
 fi
 }





More information about the Openembedded-commits mailing list