1 |
ottxor 13/12/02 13:32:12 |
2 |
|
3 |
Added: openntpd.init.d-20080406-r6 |
4 |
openntpd-20080406-pidfile.patch |
5 |
openntpd.conf.d-20080406-r6 |
6 |
Log: |
7 |
added pidfile support (bug #493082), fixed ignored NTPD_OPTS for USE=syslog (bug #493032) |
8 |
|
9 |
(Portage version: 2.2.7/cvs/Linux x86_64, signed Manifest commit with key C2000586) |
10 |
|
11 |
Revision Changes Path |
12 |
1.1 net-misc/openntpd/files/openntpd.init.d-20080406-r6 |
13 |
|
14 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openntpd/files/openntpd.init.d-20080406-r6?rev=1.1&view=markup |
15 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openntpd/files/openntpd.init.d-20080406-r6?rev=1.1&content-type=text/plain |
16 |
|
17 |
Index: openntpd.init.d-20080406-r6 |
18 |
=================================================================== |
19 |
#!/sbin/runscript |
20 |
# Copyright 1999-2013 Gentoo Foundation |
21 |
# Distributed under the terms of the GNU General Public License v2 |
22 |
# $Header: /var/cvsroot/gentoo-x86/net-misc/openntpd/files/openntpd.init.d-20080406-r6,v 1.1 2013/12/02 13:32:12 ottxor Exp $ |
23 |
|
24 |
name="OpenNTPD" |
25 |
command="/usr/sbin/ntpd" |
26 |
pidfile="/run/ntpd.pid" |
27 |
command_args="-p ${pidfile} ${NTPD_OPTS}" |
28 |
|
29 |
depend() { |
30 |
need net |
31 |
after ntp-client |
32 |
use dns logger |
33 |
} |
34 |
|
35 |
|
36 |
|
37 |
1.1 net-misc/openntpd/files/openntpd-20080406-pidfile.patch |
38 |
|
39 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openntpd/files/openntpd-20080406-pidfile.patch?rev=1.1&view=markup |
40 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openntpd/files/openntpd-20080406-pidfile.patch?rev=1.1&content-type=text/plain |
41 |
|
42 |
Index: openntpd-20080406-pidfile.patch |
43 |
=================================================================== |
44 |
adding a -p option to openntpd to create a pidfile |
45 |
|
46 |
https://bugs.gentoo.org/show_bug.cgi?id=493082 |
47 |
|
48 |
diff -u -r openntpd-20080406p.orig/ntpd.8 openntpd-20080406p/ntpd.8 |
49 |
--- openntpd-20080406p.orig/ntpd.8 2013-12-01 12:49:49.773116316 -0800 |
50 |
+++ openntpd-20080406p/ntpd.8 2013-12-01 13:27:39.417324497 -0800 |
51 |
@@ -25,6 +25,7 @@ |
52 |
.Bk -words |
53 |
.Op Fl dnSsv |
54 |
.Op Fl f Ar file |
55 |
+.Op Fl p Ar file |
56 |
.Ek |
57 |
.Sh DESCRIPTION |
58 |
The |
59 |
@@ -63,13 +64,16 @@ |
60 |
.Xr ntpd.conf 5 . |
61 |
.Pp |
62 |
The options are as follows: |
63 |
-.Bl -tag -width "-f fileXXX" |
64 |
+.Bl -tag -width "-p fileXXX" |
65 |
.It Fl d |
66 |
Do not daemonize. |
67 |
If this option is specified, |
68 |
.Nm |
69 |
will run in the foreground and log to |
70 |
.Em stderr . |
71 |
+.It Fl p Ar file |
72 |
+Write pid to |
73 |
+.Ar file |
74 |
.It Fl f Ar file |
75 |
Use |
76 |
.Ar file |
77 |
diff -u -r openntpd-20080406p.orig/ntpd.c openntpd-20080406p/ntpd.c |
78 |
--- openntpd-20080406p.orig/ntpd.c 2013-12-01 12:49:49.774116176 -0800 |
79 |
+++ openntpd-20080406p/ntpd.c 2013-12-01 13:31:43.964616270 -0800 |
80 |
@@ -78,7 +78,7 @@ |
81 |
{ |
82 |
extern char *__progname; |
83 |
|
84 |
- fprintf(stderr, "usage: %s [-dnSsv] [-f file]\n", __progname); |
85 |
+ fprintf(stderr, "usage: %s [-dnSsv] [-f file] [-p file]\n", __progname); |
86 |
exit(1); |
87 |
} |
88 |
|
89 |
@@ -105,7 +105,7 @@ |
90 |
log_init(1); /* log to stderr until daemonized */ |
91 |
res_init(); /* XXX */ |
92 |
|
93 |
- while ((ch = getopt(argc, argv, "df:nsSv")) != -1) { |
94 |
+ while ((ch = getopt(argc, argv, "df:np:sSv")) != -1) { |
95 |
switch (ch) { |
96 |
case 'd': |
97 |
lconf.debug = 1; |
98 |
@@ -116,6 +116,9 @@ |
99 |
case 'n': |
100 |
lconf.noaction = 1; |
101 |
break; |
102 |
+ case 'p': |
103 |
+ lconf.pid_file = optarg; |
104 |
+ break; |
105 |
case 's': |
106 |
lconf.settime = 1; |
107 |
break; |
108 |
@@ -157,9 +160,17 @@ |
109 |
reset_adjtime(); |
110 |
if (!lconf.settime) { |
111 |
log_init(lconf.debug); |
112 |
- if (!lconf.debug) |
113 |
+ if (!lconf.debug) { |
114 |
if (daemon(1, 0)) |
115 |
fatal("daemon"); |
116 |
+ else if (lconf.pid_file != NULL) { |
117 |
+ FILE *f = fopen(lconf.pid_file, "w"); |
118 |
+ if (f == NULL) |
119 |
+ fatal("couldn't open pid file"); |
120 |
+ fprintf(f, "%ld\n", (long) getpid()); |
121 |
+ fclose(f); |
122 |
+ } |
123 |
+ } |
124 |
} else |
125 |
timeout = SETTIME_TIMEOUT * 1000; |
126 |
|
127 |
@@ -201,9 +212,17 @@ |
128 |
log_init(lconf.debug); |
129 |
log_debug("no reply received in time, skipping initial " |
130 |
"time setting"); |
131 |
- if (!lconf.debug) |
132 |
+ if (!lconf.debug) { |
133 |
if (daemon(1, 0)) |
134 |
fatal("daemon"); |
135 |
+ else if (lconf.pid_file != NULL) { |
136 |
+ FILE *f = fopen(lconf.pid_file, "w"); |
137 |
+ if (f == NULL) |
138 |
+ fatal("couldn't open pid file"); |
139 |
+ fprintf(f, "%ld\n", (long) getpid()); |
140 |
+ fclose(f); |
141 |
+ } |
142 |
+ } |
143 |
} |
144 |
|
145 |
if (nfds > 0 && (pfd[PFD_PIPE].revents & POLLOUT)) |
146 |
@@ -242,6 +261,8 @@ |
147 |
msgbuf_clear(&ibuf->w); |
148 |
free(ibuf); |
149 |
log_info("Terminating"); |
150 |
+ if (lconf.pid_file != NULL) |
151 |
+ unlink(lconf.pid_file); |
152 |
return (0); |
153 |
} |
154 |
|
155 |
@@ -316,9 +337,17 @@ |
156 |
memcpy(&d, imsg.data, sizeof(d)); |
157 |
ntpd_settime(d); |
158 |
/* daemonize now */ |
159 |
- if (!lconf->debug) |
160 |
+ if (!lconf->debug) { |
161 |
if (daemon(1, 0)) |
162 |
fatal("daemon"); |
163 |
+ else if (lconf->pid_file != NULL) { |
164 |
+ FILE *f = fopen(lconf->pid_file, "w"); |
165 |
+ if (f == NULL) |
166 |
+ fatal("couldn't open pid file"); |
167 |
+ fprintf(f, "%ld\n", (long) getpid()); |
168 |
+ fclose(f); |
169 |
+ } |
170 |
+ } |
171 |
lconf->settime = 0; |
172 |
break; |
173 |
case IMSG_HOST_DNS: |
174 |
diff -u -r openntpd-20080406p.orig/ntpd.h openntpd-20080406p/ntpd.h |
175 |
--- openntpd-20080406p.orig/ntpd.h 2013-12-01 12:49:49.773116316 -0800 |
176 |
+++ openntpd-20080406p/ntpd.h 2013-12-01 12:54:02.023313872 -0800 |
177 |
@@ -178,6 +178,7 @@ |
178 |
u_int8_t debug; |
179 |
u_int32_t scale; |
180 |
u_int8_t noaction; |
181 |
+ char *pid_file; |
182 |
}; |
183 |
|
184 |
struct buf { |
185 |
|
186 |
|
187 |
|
188 |
1.1 net-misc/openntpd/files/openntpd.conf.d-20080406-r6 |
189 |
|
190 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openntpd/files/openntpd.conf.d-20080406-r6?rev=1.1&view=markup |
191 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openntpd/files/openntpd.conf.d-20080406-r6?rev=1.1&content-type=text/plain |
192 |
|
193 |
Index: openntpd.conf.d-20080406-r6 |
194 |
=================================================================== |
195 |
# /etc/conf.d/ntpd: config file for openntpd's ntpd |
196 |
|
197 |
# See ntpd(8) man page ... some popular options: |
198 |
# -s Set the time immediately at startup |
199 |
# (Note: may cause up to a 15 second startup delay |
200 |
# if ntp servers not reachable) |
201 |
NTPD_OPTS="" |