ntpd: import from packages
authorPeter Wagner <tripolar@gmx.at>
Mon, 16 Jun 2014 09:47:24 +0000 (11:47 +0200)
committerPeter Wagner <tripolar@gmx.at>
Mon, 16 Jun 2014 09:54:42 +0000 (11:54 +0200)
Signed-off-by: Peter Wagner <tripolar@gmx.at>
net/ntpd/Makefile [new file with mode: 0644]
net/ntpd/files/ntp.conf [new file with mode: 0644]
net/ntpd/files/ntpd.hotplug [new file with mode: 0644]
net/ntpd/files/ntpd.init [new file with mode: 0644]
net/ntpd/files/ntpdate.init [new file with mode: 0644]

diff --git a/net/ntpd/Makefile b/net/ntpd/Makefile
new file mode 100644 (file)
index 0000000..881887c
--- /dev/null
@@ -0,0 +1,194 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ntp
+PKG_VERSION:=4.2.6p5
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/
+PKG_MD5SUM:=00df80a84ec9528fcfb09498075525bc
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_BUILD_DEPENDS:=libelf1
+PKG_FIXUP:=autoreconf
+PKG_LIBTOOL_PATHS:=. sntp
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ntpd/Default
+  SUBMENU:=Time Synchronization
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=ISC ntp
+  MAINTAINER:=Peter Wagner <tripolar@gmx.at>
+  URL:=http://www.ntp.org/
+  DEPENDS:=+libcap
+endef
+
+define Package/ntpd/Default/description
+ The ISC ntp suite is a collection of tools used to synchronize the
+ system clock with remote NTP time servers and run/montior local NTP
+ servers.
+endef
+
+define Package/ntpd
+$(call Package/ntpd/Default)
+  TITLE+= server
+  VARIANT:=nossl
+endef
+
+define Package/ntpd/description
+$(call Package/ntpd/Default/description)
+ .
+ This package contains the ntpd server.
+endef
+
+define Package/ntpd-ssl
+$(call Package/ntpd/Default)
+  TITLE+= server (with OpenSSL support)
+  VARIANT:=ssl
+  DEPENDS+= +libopenssl
+endef
+
+define Package/ntpd-ssl/description
+$(call Package/ntpd/Default/description)
+ .
+ This package contains the ntpd server with OpenSSL support.
+endef
+
+define Package/ntpdate
+$(call Package/ntpd/Default)
+  TITLE+=date
+  VARIANT:=nossl
+endef
+
+define Package/ntpdate/description
+$(call Package/ntpd/Default/description)
+ .
+ This package contains ntpdate.
+endef
+
+define Package/ntp-utils
+$(call Package/ntpd/Default)
+  TITLE+= utilities
+  VARIANT:=nossl
+endef
+
+define Package/ntp-utils/description
+$(call Package/ntpd/Default/description)
+ .
+ This package contains ntpdc, ntpq and ntptime.
+endef
+
+define Package/ntp-keygen
+$(call Package/ntpd/Default)
+  TITLE+=keygen
+  VARIANT:=nossl
+endef
+
+define Package/ntp-keygen/description
+$(call Package/ntpd/Default/description)
+ .
+ This package contains the ntp-keygen.
+endef
+
+define Package/ntp-keygen-ssl
+$(call Package/ntpd/Default)
+  TITLE+=keygen (with OpenSSL support)
+  VARIANT:=ssl
+  DEPENDS+= +libopenssl
+endef
+
+define Package/ntp-keygen-ssl/description
+$(call Package/ntpd/Default/description)
+ .
+ This package contains the ntp-keygen with OpenSSL support.
+endef
+
+define Package/ntpd/conffiles
+/etc/ntp.conf
+endef
+
+CONFIGURE_VARS += \
+       ac_cv_header_md5_h=no \
+       ac_cv_lib_rt_sched_setscheduler=no \
+       ac_cv_header_dns_sd_h=no
+
+CONFIGURE_ARGS += \
+       --disable-all-clocks \
+       --disable-parse-clocks \
+       --without-ntpsnmpd \
+       --without-lineeditlibs \
+       --enable-NMEA \
+       --enable-LOCAL-CLOCK \
+       --enable-SHM \
+       --enable-linuxcaps
+
+ifeq ($(BUILD_VARIANT),ssl)
+  CONFIGURE_ARGS += \
+       --with-crypto \
+       --with-openssl-incdir="$(STAGING_DIR)/usr/include" \
+       --with-openssl-libdir="$(STAGING_DIR)/usr/lib"
+endif
+
+define Package/ntpd/install
+       $(INSTALL_DIR) $(1)/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ntpd/ntpd $(1)/sbin/
+       $(INSTALL_DIR) $(1)/etc
+       $(INSTALL_CONF) ./files/ntp.conf $(1)/etc/
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/ntpd.init $(1)/etc/init.d/ntpd
+       $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+       $(INSTALL_BIN) ./files/ntpd.hotplug $(1)/etc/hotplug.d/iface/20-ntpd
+endef
+
+define Package/ntpd/postinst
+#!/bin/sh
+[ -L "$${IPKG_INSTROOT}/usr/sbin/ntpd" ] && rm -f "$${IPKG_INSTROOT}/usr/sbin/ntpd"
+exit 0
+endef
+
+define Package/ntpd/postrm
+#!/bin/sh
+/bin/busybox ntpd -h 2>&1 | grep -q BusyBox && ln -sf ../../bin/busybox /usr/sbin/ntpd
+exit 0
+endef
+
+Package/ntpd-ssl/conffiles = $(Package/ntpd/conffiles)
+Package/ntpd-ssl/install = $(Package/ntpd/install)
+
+define Package/ntpdate/install
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ntpdate/ntpdate $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/ntpdate.init $(1)/etc/init.d/ntpdate
+endef
+
+define Package/ntp-utils/install
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ntpdc/ntpdc $(1)/usr/sbin/
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ntpq/ntpq $(1)/usr/sbin/
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/util/ntptime $(1)/usr/sbin/
+endef
+
+define Package/ntp-keygen/install
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/util/ntp-keygen $(1)/usr/sbin/
+endef
+
+Package/ntp-keygen-ssl/install = $(Package/ntp-keygen/install)
+
+$(eval $(call BuildPackage,ntpd))
+$(eval $(call BuildPackage,ntpd-ssl))
+$(eval $(call BuildPackage,ntpdate))
+$(eval $(call BuildPackage,ntp-utils))
+$(eval $(call BuildPackage,ntp-keygen))
+$(eval $(call BuildPackage,ntp-keygen-ssl))
diff --git a/net/ntpd/files/ntp.conf b/net/ntpd/files/ntp.conf
new file mode 100644 (file)
index 0000000..8bfb8e3
--- /dev/null
@@ -0,0 +1,26 @@
+# use a random selection of 4 public stratum 2 servers
+# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers
+
+#restrict default nomodify notrap noquery
+#restrict default noquery
+
+restrict 127.0.0.1
+
+driftfile  /var/lib/ntp/ntp.drift
+
+server 0.openwrt.pool.ntp.org iburst
+server 1.openwrt.pool.ntp.org iburst
+server 2.openwrt.pool.ntp.org iburst
+server 3.openwrt.pool.ntp.org iburst
+
+
+# GPS(NMEA)+PPS
+#server 127.127.20.0 minpoll 4 prefer
+#fudge 127.127.20.0 flag3 1 flag2 0
+
+# SMA PPS
+#server 127.127.28.0 minpoll 4 prefer
+#fudge 127.127.28.0 refid PPS flag3 1
+
+#server 192.168.1.253
+
diff --git a/net/ntpd/files/ntpd.hotplug b/net/ntpd/files/ntpd.hotplug
new file mode 100644 (file)
index 0000000..992628f
--- /dev/null
@@ -0,0 +1,10 @@
+NAME=ntpd
+CONFIG=/etc/ntp.conf
+COMMAND=/usr/sbin/$NAME
+
+[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
+        [ -x $COMMAND ] && [ -r $CONFIG ] && {
+               killall ntpd
+               /etc/init.d/ntpd start
+        } &
+}
diff --git a/net/ntpd/files/ntpd.init b/net/ntpd/files/ntpd.init
new file mode 100644 (file)
index 0000000..05c317e
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=65
+STOP=65
+
+USE_PROCD=1
+
+start_service() {
+#      ln -sf /dev/ttyS0 /dev/gps0
+#      /usr/sbin/setgarmin -d /dev/gps -c /etc/setgarmin.conf
+       user_exists ntp 123 || user_add ntp 123 123 ntp /var/lib/ntp
+       group_exists ntp 123 || group_add ntp 123
+       mkdir -p /var/lib/ntp
+       chown -R ntp:ntp /var/lib/ntp
+
+       procd_open_instance
+       procd_set_param command /sbin/ntpd -g -u ntp:ntp -p /var/run/ntpd.pid -n
+       procd_close_instance
+}
diff --git a/net/ntpd/files/ntpdate.init b/net/ntpd/files/ntpdate.init
new file mode 100644 (file)
index 0000000..2f33210
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2008 OpenWrt.org
+
+START=60
+
+STEP_SERVERS="0.openwrt.pool.ntp.org 1.openwrt.pool.ntp.org 2.openwrt.pool.ntp.org"
+TIMEOUT="2" # in seconds
+
+start() {
+       for s in $STEP_SERVERS ; do
+               /usr/sbin/ntpdate -s -b -u -t "$TIMEOUT" "$s" && break
+       done
+}