Fixing ntpd time syncing problem
authorAngelo Compagnucci <angelo.compagnucci@gmail.com>
Tue, 10 Jun 2014 12:58:40 +0000 (14:58 +0200)
committerPeter Korsgaard <peter@korsgaard.com>
Wed, 9 Jul 2014 14:00:28 +0000 (16:00 +0200)
Add ntp.conf file to make ntpd syncing.
Starting ntpd daemon with -g to sync time also with big offsets.
Removes the use of deprecated ntpdate command for initial time sync.

[Peter: drop unused NTPDATE_BIN variable]
Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Acked-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Tested-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
package/ntp/S49ntp
package/ntp/ntp.mk
package/ntp/ntpd.etc.conf [new file with mode: 0644]
package/ntp/ntpd.etc.default

index 7b929e94929081722f9f3b376915fb1f370d0a87..6f9ec75045b1dbd6facde8fafca697bfbe70b451 100755 (executable)
@@ -7,7 +7,6 @@ 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,14 +19,8 @@ fi
 
 case "$1" in
   start)
-       if [ -x $NTPDATE_BIN ] ; then
-               echo -n "Getting initial time via ntp"
-               $NTPDATE_BIN $NTPDATE_OPTS $NTPSERVERS > /dev/null 2>&1
-               echo "."
-       fi
-
        echo -n "Starting $DESC: $NAME"
-       start-stop-daemon -S -q -x $DAEMON
+       start-stop-daemon -S -q -x $DAEMON -- -g
        echo "."
        ;;
   stop) echo -n "Stopping $DESC: $NAME"
index fe6b04b0a0b8b4675a49fb2ba8fc6f734060bc79..b60e623a0239639f7e8f75b08cba4130c02af76c 100644 (file)
@@ -52,6 +52,7 @@ NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_TICKADJ) += util/tickadj
 define NTP_INSTALL_TARGET_CMDS
        $(if $(BR2_PACKAGE_NTP_NTPD), install -m 755 $(@D)/ntpd/ntpd $(TARGET_DIR)/usr/sbin/ntpd)
        test -z "$(NTP_INSTALL_FILES_y)" || install -m 755 $(addprefix $(@D)/,$(NTP_INSTALL_FILES_y)) $(TARGET_DIR)/usr/bin/
+       $(INSTALL) -m 644 package/ntp/ntpd.etc.conf $(TARGET_DIR)/etc/ntp.conf
        @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 ; \
diff --git a/package/ntp/ntpd.etc.conf b/package/ntp/ntpd.etc.conf
new file mode 100644 (file)
index 0000000..6a2b88c
--- /dev/null
@@ -0,0 +1,8 @@
+server 0.pool.ntp.org iburst
+server 1.pool.ntp.org iburst
+
+restrict default kod nomodify notrap nopeer noquery
+restrict -6 default kod nomodify notrap nopeer noquery
+
+restrict 127.0.0.1
+restrict -6 ::1
index d3292285552219b1ab20cddfe6adadbe53649d3c..94e2bc2a54f4931c5fecaed6e1dc0e54c07b5100 100644 (file)
@@ -1,9 +1,2 @@
-# 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