From 8586e2a51b26afec2cecba1ba3c34ed35ae87743 Mon Sep 17 00:00:00 2001 From: Wade Berrier Date: Thu, 6 Nov 2008 21:11:54 +0000 Subject: ntp: add /etc/default/ntpd to control whether to start ntpd and/or ntpdate. Also specify options and servers. --- package/ntp/ntp.mk | 4 ++++ package/ntp/ntp.sysvinit | 15 ++++++++++++--- package/ntp/ntpd.etc.default | 9 +++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 package/ntp/ntpd.etc.default (limited to 'package/ntp') diff --git a/package/ntp/ntp.mk b/package/ntp/ntp.mk index f4515fce9..d3c4c70aa 100644 --- a/package/ntp/ntp.mk +++ b/package/ntp/ntp.mk @@ -67,6 +67,10 @@ ifeq ($(BR2_PACKAGE_NTP_SNTP),y) install -m 755 $(NTP_DIR)/sntp/sntp $(TARGET_DIR)/usr/bin/sntp endif install -m 755 package/ntp/ntp.sysvinit $(TARGET_DIR)/etc/init.d/S49ntp + @if [ ! -f $(TARGET_DIR)/etc/default/ntpd ]; then \ + install -m 755 -d $(TARGET_DIR)/etc/default ; \ + install -m 644 package/ntp/ntpd.etc.default $(TARGET_DIR)/etc/default/ntpd ; \ + fi ntp: uclibc $(TARGET_DIR)/$(NTP_TARGET_BINARY) diff --git a/package/ntp/ntp.sysvinit b/package/ntp/ntp.sysvinit index 4e8f1107f..27389269a 100755 --- a/package/ntp/ntp.sysvinit +++ b/package/ntp/ntp.sysvinit @@ -9,6 +9,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="network time protocol daemon" NAME=ntpd DAEMON=/usr/sbin/$NAME +NTPDATE_BIN=/usr/bin/ntpdate # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 @@ -20,9 +21,17 @@ then fi case "$1" in - start) echo -n "Starting $DESC: $NAME" - start-stop-daemon -S -q -x $DAEMON - echo "." + start) + if test x$NTPDATE = xyes ; then + echo -n "Getting initial time via ntp" + $NTPDATE_BIN $NTPDATE_OPTS $NTPSERVERS > /dev/null 2>&1 + echo "." + fi + if test x$NTPD = xyes ; then + echo -n "Starting $DESC: $NAME" + start-stop-daemon -S -q -x $DAEMON + echo "." + fi ;; stop) echo -n "Stopping $DESC: $NAME" start-stop-daemon -K -q -n $NAME diff --git a/package/ntp/ntpd.etc.default b/package/ntp/ntpd.etc.default new file mode 100644 index 000000000..d32922855 --- /dev/null +++ b/package/ntp/ntpd.etc.default @@ -0,0 +1,9 @@ +# NTP Servers to use for ntpdate +NTPSERVERS="pool.ntp.org" + +# Get initial time via ntpdate? +NTPDATE=no +NTPDATE_OPTS="-t 5" + +# Start the ntp daemon? +NTPD=yes -- cgit v1.2.3