Bladeren bron

ntpclient: Import from oldpackages, update version, copyright and license info, add pkg maintainer.

Signed-off-by: Ted Hess <thess@kitschensync.net>
Ted Hess 10 jaren geleden
bovenliggende
commit
c839c2119b

+ 57
- 0
net/ntpclient/Makefile Bestand weergeven

@@ -0,0 +1,57 @@
1
+#
2
+# Copyright (C) 2006-2014 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=ntpclient
11
+PKG_VERSION:=2010_365
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
15
+PKG_SOURCE_URL:=http://doolittle.icarus.com/ntpclient/
16
+PKG_MD5SUM:=a64689398f2df8933ee0d8da246e9eaa
17
+
18
+PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>
19
+
20
+PKG_LICENSE:=GPL-2.0
21
+
22
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-2010
23
+
24
+include $(INCLUDE_DIR)/package.mk
25
+
26
+define Package/ntpclient
27
+  SUBMENU:=Time Synchronization
28
+  SECTION:=net
29
+  CATEGORY:=Network
30
+  TITLE:=NTP (Network Time Protocol) client
31
+  URL:=http://doolittle.icarus.com/ntpclient/
32
+  DEPENDS:=+librt
33
+endef
34
+
35
+define Package/ntpclient/description
36
+	NTP client for setting system time from NTP servers.
37
+endef
38
+
39
+define Package/ntpclient/conffiles
40
+/etc/config/ntpclient
41
+endef
42
+
43
+MAKE_FLAGS += \
44
+	all adjtimex
45
+
46
+define Package/ntpclient/install
47
+	$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
48
+	$(INSTALL_DATA) ./files/ntpclient.hotplug $(1)/etc/hotplug.d/iface/20-ntpclient
49
+	$(INSTALL_DIR) $(1)/etc/config
50
+	$(INSTALL_CONF) ./files/ntpclient.config $(1)/etc/config/ntpclient
51
+	$(INSTALL_DIR) $(1)/usr/sbin
52
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/ntpclient $(1)/usr/sbin/
53
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/adjtimex $(1)/usr/sbin/
54
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/rate.awk $(1)/usr/sbin/
55
+endef
56
+
57
+$(eval $(call BuildPackage,ntpclient))

+ 23
- 0
net/ntpclient/files/ntpclient.config Bestand weergeven

@@ -0,0 +1,23 @@
1
+config ntpserver
2
+	option hostname '0.openwrt.pool.ntp.org'
3
+	option port     '123'
4
+
5
+config ntpserver
6
+	option hostname '1.openwrt.pool.ntp.org'
7
+	option port     '123'
8
+
9
+config ntpserver
10
+	option hostname '2.openwrt.pool.ntp.org'
11
+	option port     '123'
12
+
13
+config ntpserver
14
+	option hostname '3.openwrt.pool.ntp.org'
15
+	option port     '123'
16
+
17
+config ntpdrift
18
+	option freq     '0'
19
+
20
+config ntpclient
21
+	option interval	600
22
+	#option count	10
23
+	#option interface wan

+ 78
- 0
net/ntpclient/files/ntpclient.hotplug Bestand weergeven

@@ -0,0 +1,78 @@
1
+#!/bin/sh
2
+# Copyright (C) 2006-2014 OpenWrt.org
3
+
4
+. /lib/functions.sh
5
+
6
+unset SERVER
7
+unset PORT
8
+unset INTERVAL
9
+unset COUNT
10
+unset INTERFACE_GLOBAL
11
+
12
+NTPC=`which ntpclient`
13
+
14
+check_server() {
15
+	local hostname
16
+	local port
17
+	local interface
18
+	[ -n "$SERVER" ] && return
19
+	config_get hostname $1 hostname
20
+	config_get port $1 port
21
+	config_get interface $1 interface
22
+
23
+	[ -z "$interface" ] && interface=$INTERFACE_GLOBAL
24
+
25
+	[ -n "$interface" ] && {
26
+		# $INTERFACE is passed from hotplug event
27
+		[ "$interface" = "$INTERFACE" ] || return
28
+	}
29
+
30
+	[ -z "$hostname" ] && return
31
+	$NTPC -c 1 -p ${port:-123} -i 2 -h $hostname > /dev/null && { SERVER=$hostname; PORT=${port:-123}; }
32
+}
33
+
34
+set_drift() {
35
+	config_get freq $1 freq
36
+	[ -n "$freq" ] && adjtimex -f $freq >/dev/null
37
+}
38
+
39
+start_ntpclient() {
40
+	config_foreach set_drift ntpdrift
41
+	config_foreach check_server ntpserver
42
+	[ -z "$SERVER" ] && exit 0
43
+	logger starting ntpclient
44
+	$NTPC ${COUNT:+-c $COUNT} ${INTERVAL:+-i $INTERVAL} -s -l -D -p $PORT -h $SERVER 2> /dev/null
45
+}
46
+
47
+stop_ntpclient() {
48
+	logger stopping ntpclient
49
+	killall ntpclient
50
+}
51
+
52
+load_settings() {
53
+	local interval
54
+	local count
55
+	local iface
56
+	
57
+	config_get interval $1 interval
58
+	config_get count $1 count
59
+	config_get interface $1 interface
60
+	
61
+	[ -n "$count" ] && COUNT=$count
62
+	[ -n "$interval" ] && INTERVAL=$interval
63
+	[ -n "$interface" ] && INTERFACE_GLOBAL=$interface
64
+}
65
+
66
+config_load ntpclient
67
+config_foreach load_settings ntpclient
68
+
69
+NTP_RUNNING=`ps  | grep $NTPC | grep -v grep`
70
+
71
+case "${ACTION:-ifup}" in
72
+	ifup)
73
+		[ -z "$NTP_RUNNING" ] && start_ntpclient 
74
+	;;
75
+	ifdown)
76
+		[ -n "$NTP_RUNNING" ] && stop_ntpclient 
77
+	;;
78
+esac

+ 22
- 0
net/ntpclient/patches/100-daemon.patch Bestand weergeven

@@ -0,0 +1,22 @@
1
+--- a/ntpclient.c
2
++++ b/ntpclient.c
3
+@@ -611,7 +611,7 @@ int main(int argc, char *argv[]) {
4
+ 	ntpc.cross_check=1;
5
+ 
6
+ 	for (;;) {
7
+-		c = getopt( argc, argv, "c:" DEBUG_OPTION "f:g:h:i:lp:q:" REPLAY_OPTION "st");
8
++		c = getopt( argc, argv, "c:" DEBUG_OPTION "f:g:h:i:lp:q:" REPLAY_OPTION "stD");
9
+ 		if (c == EOF) break;
10
+ 		switch (c) {
11
+ 			case 'c':
12
+@@ -660,6 +660,10 @@ int main(int argc, char *argv[]) {
13
+ 				(ntpc.cross_check)=0;
14
+ 				break;
15
+ 
16
++			case 'D':
17
++				daemon(0, 0);
18
++				break;
19
++
20
+ 			default:
21
+ 				usage(argv[0]);
22
+ 				exit(1);