chrony: import from oldpackages
authorMiroslav Lichvar <mlichvar0@gmail.com>
Tue, 22 Sep 2015 18:54:41 +0000 (20:54 +0200)
committerSteven Barth <steven@midlink.org>
Tue, 13 Oct 2015 08:10:53 +0000 (10:10 +0200)
Signed-off-by: Miroslav Lichvar <mlichvar0@gmail.com>
net/chrony/Makefile [new file with mode: 0644]
net/chrony/files/chrony.conf [new file with mode: 0644]
net/chrony/files/chrony.config [new file with mode: 0644]
net/chrony/files/chrony.hotplug [new file with mode: 0644]
net/chrony/files/chrony.keys [new file with mode: 0644]
net/chrony/files/chronyd.init [new file with mode: 0644]
net/chrony/files/ntpd.config [new file with mode: 0644]
net/chrony/files/ntpd.hotplug [new file with mode: 0644]
net/chrony/files/ntpd.init [new file with mode: 0644]
net/chrony/patches/001-crosscompile.patch [new file with mode: 0644]
net/chrony/patches/002-ipv6_disabled_fixes.patch [new file with mode: 0644]

diff --git a/net/chrony/Makefile b/net/chrony/Makefile
new file mode 100644 (file)
index 0000000..9b0f7e7
--- /dev/null
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2006-2015 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:=chrony
+PKG_VERSION:=2.1.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://download.tuxfamily.org/chrony/
+PKG_MD5SUM:=15e470a51ab6e09e65bc0a2fbc5299af
+
+PKG_MAINTAINER:=Miroslav Lichvar <mlichvar0@gmail.com>
+PKG_LICENSE:=GPL-2.0
+PKG_LICENSE_FILES:=COPYING
+
+PKG_BUILD_DEPENDS:=+pps-tools
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/chrony
+  SUBMENU:=Time Synchronization
+  SECTION:=net
+  CATEGORY:=Network
+  DEPENDS:=+libcap
+  USERID:=chrony=323:chrony=323
+  TITLE:=A versatile NTP client and server
+  URL:=http://chrony.tuxfamily.org/
+endef
+
+define Package/chrony/description
+       An NTP client and server designed to perform well in a wide range
+       of conditions. It can synchronize the system clock with NTP servers,
+       reference clocks, and manual input using wristwatch and keyboard.
+endef
+
+define Package/chrony/conffiles
+/etc/chrony/chrony.conf
+/etc/chrony/chrony.keys
+/etc/config/chrony
+endef
+
+CONFIGURE_ARGS+= \
+       --host-machine=$(shell echo $(GNU_TARGET_NAME) | sed -e 's/-.*//') \
+       --host-release="" \
+       --host-system=Linux \
+       --sysconfdir=/etc/chrony \
+       --prefix=/usr \
+       --disable-readline \
+       --disable-rtc \
+       --disable-asyncdns \
+       --with-user=chrony
+
+CONFIGURE_VARS+=CPPFLAGS=-DNDEBUG
+
+define Package/chrony/install
+       $(INSTALL_DIR) $(1)/usr/bin/
+       $(INSTALL_DIR) $(1)/usr/sbin/
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/chronyd $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/chronyc $(1)/usr/bin
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_DIR) $(1)/etc/chrony
+       $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+       $(INSTALL_BIN) ./files/chrony.hotplug $(1)/etc/hotplug.d/iface/20-chrony
+       $(INSTALL_BIN) ./files/chronyd.init $(1)/etc/init.d/chronyd
+       $(INSTALL_CONF) ./files/chrony.config $(1)/etc/config/chrony
+       $(INSTALL_CONF) ./files/chrony.conf $(1)/etc/chrony/chrony.conf
+       $(INSTALL_CONF) ./files/chrony.keys $(1)/etc/chrony/chrony.keys
+endef
+
+$(eval $(call BuildPackage,chrony))
diff --git a/net/chrony/files/chrony.conf b/net/chrony/files/chrony.conf
new file mode 100644 (file)
index 0000000..da0aa60
--- /dev/null
@@ -0,0 +1,12 @@
+# This file is included from config file generated from /etc/config/chrony
+
+# Log clock errors above 0.5 seconds
+logchange 0.5
+
+# Don't log client accesses
+noclientlog
+
+# Password config for chronyc
+keyfile /etc/chrony/chrony.keys
+commandkey 1
+generatecommandkey
diff --git a/net/chrony/files/chrony.config b/net/chrony/files/chrony.config
new file mode 100644 (file)
index 0000000..56d2b88
--- /dev/null
@@ -0,0 +1,11 @@
+config pool
+       option hostname '2.openwrt.pool.ntp.org'
+       option maxpoll '12'
+       option iburst 'yes'
+
+config allow
+       option interface 'lan'
+
+config makestep
+       option threshold '1.0'
+       option limit '3'
diff --git a/net/chrony/files/chrony.hotplug b/net/chrony/files/chrony.hotplug
new file mode 100644 (file)
index 0000000..4084336
--- /dev/null
@@ -0,0 +1,6 @@
+COMMAND=/usr/bin/chronyc
+
+[ -x $COMMAND ] || exit 0
+
+[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && $COMMAND -a online
+[ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan" ] && $COMMAND -a offline
diff --git a/net/chrony/files/chrony.keys b/net/chrony/files/chrony.keys
new file mode 100644 (file)
index 0000000..f5f6319
--- /dev/null
@@ -0,0 +1 @@
+# Keys for NTP authentication and chronyc commands
diff --git a/net/chrony/files/chronyd.init b/net/chrony/files/chronyd.init
new file mode 100644 (file)
index 0000000..9be3a90
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=60
+USE_PROCD=1
+PROG=/usr/sbin/chronyd
+CONFIGFILE=/var/etc/chrony.conf
+
+handle_source() {
+       local cfg=$1 sourcetype=$2 hostname minpoll maxpoll iburst
+
+       config_get hostname "$cfg" hostname
+       [ -z "$hostname" ] && return
+       config_get minpoll "$cfg" minpoll
+       config_get maxpoll "$cfg" maxpoll
+       config_get_bool iburst "$cfg" iburst 0
+       echo $(
+               echo $sourcetype $hostname
+               [ -n "$minpoll" ] && echo minpoll $minpoll
+               [ -n "$maxpoll" ] && echo maxpoll $maxpoll
+               [ "$iburst" = "1" ] && echo iburst
+       ) >> $CONFIGFILE
+}
+
+handle_allow() {
+       local cfg=$1 iface wan_iface wan6_iface subnet subnets subnets6
+
+       network_find_wan wan_iface true
+       network_find_wan6 wan6_iface true
+       config_get iface "$cfg" interface
+
+       if [ "$wan_iface" = "$iface" ]; then
+               echo allow >> $CONFIGFILE
+       else
+               network_get_subnets subnets $iface || \
+                       network_get_subnets subnets6 $iface || continue
+               for subnet in $subnets $subnets6; do
+                       echo allow $subnet >> $CONFIGFILE
+               done
+       fi
+}
+
+handle_makestep() {
+       local cfg=$1 threshold limit
+
+       config_get threshold "$cfg" threshold
+       config_get limit "$cfg" limit
+       [ -z "$threshold" -o -z "$limit" ] && return
+       echo makestep $threshold $limit >> $CONFIGFILE
+}
+
+start_service() {
+       . /lib/functions/network.sh
+
+       procd_open_instance
+       procd_set_param command $PROG -n -f $CONFIGFILE
+       procd_set_param file $CONFIGFILE
+       procd_set_param file /etc/chrony/chrony.conf
+       procd_close_instance
+
+       echo include /etc/chrony/chrony.conf > $CONFIGFILE
+
+       config_load ntpd
+       config_foreach handle_source server server
+       config_foreach handle_source pool pool
+       config_foreach handle_source peer peer
+       config_foreach handle_allow allow
+       config_foreach handle_makestep makestep
+}
diff --git a/net/chrony/files/ntpd.config b/net/chrony/files/ntpd.config
new file mode 100644 (file)
index 0000000..7a3b6fd
--- /dev/null
@@ -0,0 +1,6 @@
+# Generic NTP configuration
+# Time servers and network(s) that may access the time service
+
+config ntpd
+       option TimeServers      "0.openwrt.pool.ntp.org 1.openwrt.pool.ntp.org 2.openwrt.pool.ntp.org 3.openwrt.pool.ntp.org"
+       option ClientAccessFrom "lan"
diff --git a/net/chrony/files/ntpd.hotplug b/net/chrony/files/ntpd.hotplug
new file mode 100644 (file)
index 0000000..4084336
--- /dev/null
@@ -0,0 +1,6 @@
+COMMAND=/usr/bin/chronyc
+
+[ -x $COMMAND ] || exit 0
+
+[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && $COMMAND -a online
+[ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan" ] && $COMMAND -a offline
diff --git a/net/chrony/files/ntpd.init b/net/chrony/files/ntpd.init
new file mode 100644 (file)
index 0000000..3450185
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=60
+
+start() {
+       [ ! -f /var/run/chronyd.pid ] && (
+               /usr/sbin/chronyd -f /etc/chrony/chrony.conf
+
+               local NTP_SERVERS
+               local NTP_SERVER
+               local CLIENT_NETWORKS
+               local NETNAME
+               config_load ntpd
+               config_get NTP_SERVERS $CONFIG_SECTION TimeServers
+               config_get CLIENT_NETWORKS $CONFIG_SECTION ClientAccessFrom
+
+               . /lib/functions/network.sh
+
+               # Define servers with the iburst option to speed up the initial
+               # synchronization and allow clients to access the server
+               (
+                       for NTP_SERVER in $NTP_SERVERS; do
+                               echo add server $NTP_SERVER iburst
+                       done
+
+                       for NETNAME in $CLIENT_NETWORKS; do
+                               local subnet
+                               if network_get_subnet subnet "$NETNAME"; then
+                                       echo allow $subnet
+                               fi
+                       done
+               ) | chronyc -a > /dev/null 2>&1
+       )
+}
+
+stop() {
+       [ -r /var/run/chronyd.pid ] && PID=$(cat /var/run/chronyd.pid)
+       [ -n "$PID" ] && kill $PID
+}
+
+restart() {
+       stop
+       while [ -r /var/run/chronyd.pid ] ; do sleep 1; done
+       start
+}
diff --git a/net/chrony/patches/001-crosscompile.patch b/net/chrony/patches/001-crosscompile.patch
new file mode 100644 (file)
index 0000000..d712e06
--- /dev/null
@@ -0,0 +1,25 @@
+--- a/configure
++++ b/configure
+@@ -254,6 +254,13 @@ do
+     --host-machine=* )
+       MACHINE=`echo $option | sed -e 's/^.*=//;'`
+     ;;
++    --target=* )
++      TARGET=`echo $option | sed -e 's/[^=]*=//;'`
++      OPERATINGSYSTEM=`echo $TARGET | sed -e 's/.*-//;'`
++      MACHINE=`echo $TARGET | sed -e 's/-.*//;'`
++      VERSION=""
++      SYSTEM=${OPERATINGSYSTEM}-${MACHINE}
++    ;;
+     --help | -h )
+       usage
+       exit 0
+@@ -287,7 +294,7 @@ case $SYSTEM in
+         ;;
+     esac
+     ;;
+-    Linux* )
++    Linux* | linux* )
+         EXTRA_OBJECTS="sys_linux.o wrap_adjtimex.o"
+         try_linuxcaps=1
+         try_rtc=1
diff --git a/net/chrony/patches/002-ipv6_disabled_fixes.patch b/net/chrony/patches/002-ipv6_disabled_fixes.patch
new file mode 100644 (file)
index 0000000..629d2c7
--- /dev/null
@@ -0,0 +1,34 @@
+--- a/ntp_io.c
++++ b/ntp_io.c
+@@ -355,6 +355,7 @@ read_from_socket(void *anything)
+       }
+ #endif
++#ifdef HAVE_IPV6
+ #ifdef IPV6_PKTINFO
+       if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO) {
+         struct in6_pktinfo ipi;
+@@ -365,6 +366,7 @@ read_from_socket(void *anything)
+         remote_addr.local_ip_addr.family = IPADDR_INET6;
+       }
+ #endif
++#endif
+ #ifdef SO_TIMESTAMP
+       if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SO_TIMESTAMP) {
+@@ -466,6 +468,7 @@ send_packet(void *packet, int packetlen,
+   }
+ #endif
++#ifdef HAVE_IPV6
+ #ifdef IPV6_PKTINFO
+   if (remote_addr->local_ip_addr.family == IPADDR_INET6) {
+     struct cmsghdr *cmsg;
+@@ -484,6 +487,7 @@ send_packet(void *packet, int packetlen,
+         sizeof(ipi->ipi6_addr.s6_addr));
+   }
+ #endif
++#endif
+ #if 0
+     LOG(LOGS_INFO, LOGF_NtpIO, "sending to %s:%d from %s",