Codebase list openrc / 6c3275c
Merge tag '0.27' into debian release 0.27 Benda Xu 6 years ago
128 changed file(s) with 2775 addition(s) and 1260 deletion(s). Raw diff Collapse all Expand all
0 commit caacedc0a82285fb2d25c6d3473f154044c7ad66
1 Author: William Hubbs <w.d.hubbs@gmail.com>
2 Commit: William Hubbs <w.d.hubbs@gmail.com>
3
4 man: update openrc-shutdown man page
5
6 Add the new wtmp options and fix some cross references.
7
8 commit 84d140a1f6abf95a4170d13527152d3ab14e6613
9 Author: William Hubbs <w.d.hubbs@gmail.com>
10 Commit: William Hubbs <w.d.hubbs@gmail.com>
11
12 scripts/shutdown: pass --single to openrc-shutdown
13
14 Sysvinit shutdown has a default of single user mode, but openrc-shutdown
15 makes you choose a default action. Because of this, the shutdown wrapper
16 needs to pass --single to openrc-shutdown.
17
18 commit ee886c44824b1dd892eaff2c6da666286e61bc73
19 Author: William Hubbs <w.d.hubbs@gmail.com>
20 Commit: William Hubbs <w.d.hubbs@gmail.com>
21
22 openrc-shutdown: add --single option and clean up option processing
23
24 commit 1801561c2d36c330df7fd02c7508f503a61ff5ba
25 Author: William Hubbs <w.d.hubbs@gmail.com>
26 Commit: William Hubbs <w.d.hubbs@gmail.com>
27
28 init.d/bootmisc: use openrc-shutdown instead of halt to write halt record
29
30 This fixes #139 and fixes #128.
31 and fixes #124.
32
33 commit 7689106aa10f7852b707b4c21ec080ccb2767280
34 Author: William Hubbs <w.d.hubbs@gmail.com>
35 Commit: William Hubbs <w.d.hubbs@gmail.com>
36
37 add support for writing reboot and shutdown records to wtmp
38
39 commit 1564e155b726308200ecd5df315c002bd8b16952
40 Author: William Hubbs <w.d.hubbs@gmail.com>
41 Commit: William Hubbs <w.d.hubbs@gmail.com>
42
43 openrc-init: add optional sysvinit compatibility
44
45 commit 44bac3c3798f7eb9186c3ea8774552aa191bfae7
46 Author: William Hubbs <w.d.hubbs@gmail.com>
47 Commit: William Hubbs <w.d.hubbs@gmail.com>
48
49 Change killprocs to use kill_all instead of killall5
50
51 X-Gentoo-Bug:376977
52 X-Gentoo-Bug-URL:https://bugs.gentoo.org/show_bug.cgi?id=376977
53
54 commit 0ddee9b7d2b8dea810e252ca6a95c457876df120
55 Author: Sergei Trofimovich <slyfox@gentoo.org>
56 Commit: William Hubbs <w.d.hubbs@gmail.com>
57
58 openrc-init: fix buffer overflow in init.ctl
59
60 How to reproduce 1-byte overflow:
61
62 ```
63 $ FEATURES=-test CFLAGS="-fsanitize=address -O0 -ggdb3" emerge -1 openrc
64
65 =================================================================
66 ==1==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff0efd8710
67 at pc 0x000000402076 bp 0x7fff0efd7d50 sp 0x7fff0efd7d40
68 WRITE of size 1 at 0x7fff0efd8710 thread T0
69 #0 0x402075 (/sbin/openrc-init+0x402075)
70 #1 0x3cf6e2070f in __libc_start_main (/lib64/libc.so.6+0x3cf6e2070f)
71 #2 0x4013b8 (/sbin/openrc-init+0x4013b8)
72
73 Address 0x7fff0efd8710 is located in stack of thread T0 at offset 2432 in frame
74 #0 0x401cfb (/sbin/openrc-init+0x401cfb)
75
76 This frame has 3 object(s):
77 [32, 160) 'signals'
78 [192, 344) 'sa'
79 [384, 2432) 'buf' <== Memory access at offset 2432 overflows this variable
80 HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
81 (longjmp and C++ exceptions *are* supported)
82 SUMMARY: AddressSanitizer: stack-buffer-overflow ??:0 ??
83 ```
84
85 The problem here is in the code handling reads from 'init.ctl':
86
87 ```
88 int main(int argc, char **argv) {
89 ...
90 char buf[2048];
91 for (;;) {
92 /* This will block until a command is sent down the pipe... */
93 fifo = fopen(RC_INIT_FIFO, "r");
94 count = fread(buf, 1, 2048, fifo);
95 buf[count] = 0;
96 ...
97 }
98 ```
99
100 `buf[count] = 0;` writes outside the buffer when `fread()` returns non-truncated read.
101
102 This fixes #138.
103
104 commit 688566c535111a141f77caf88db12a4338544f7b
105 Author: Sergei Trofimovich <slyfox@inbox.ru>
106 Commit: Doug Freed <dwfreed@mtu.edu>
107
108 mk/cc.mk: make implicit function declarations fatal (#136)
109
110 Avoids issues with missing prototypes causing truncation of pointers.
111
112 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
113
114 commit 7185e242ffaa8cd1b672fe4726502a196fd779c2
115 Author: Sergei Trofimovich <slyfox@inbox.ru>
116 Commit: Doug Freed <dwfreed@mtu.edu>
117
118 rc-logger.c: fix crash on fclose(NULL) (#137)
119
120 Only close the log if we successfully opened it.
121
122 Reported-by: Brian Evans <grknight@gentoo.org>
123 Tested-by: Brian Evans <grknight@gentoo.org>
124 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
125
126 commit ec27299f4b88daa80261298fafea76ae634744d9
127 Author: William Hubbs <w.d.hubbs@gmail.com>
128 Commit: William Hubbs <w.d.hubbs@gmail.com>
129
130 typo fix
131
132 X-Gentoo-Bug: 618888
133 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=618888
134
135 commit 1ece16bfcd0ab71d2f9fe17a75ee6184e0fa4828
136 Author: William Hubbs <w.d.hubbs@gmail.com>
137 Commit: William Hubbs <w.d.hubbs@gmail.com>
138
139 openrc-shutdown: add dry-run option
140
141 commit 0cfd0dd9ef580ed9dc563ccc164d70efe8f299db
142 Author: William Hubbs <w.d.hubbs@gmail.com>
143 Commit: William Hubbs <w.d.hubbs@gmail.com>
144
145 openrc-shutdown: move to single user mode by default
146
147 To be more compatible with sysvinit, move to single user mode if no
148 options are specified on the command line.
149
150 commit a77ee2e94191ba1a286b8a6835f76556481566ba
151 Author: William Hubbs <w.d.hubbs@gmail.com>
152 Commit: William Hubbs <w.d.hubbs@gmail.com>
153
154 init: add ability to switch to single user mode
155
156 commit 49b8a573a195f4b2cee992cd10678694da0a6f4f
157 Author: William Hubbs <w.d.hubbs@gmail.com>
158 Commit: William Hubbs <w.d.hubbs@gmail.com>
159
160 add kill_all helper
161
162 This is similar to the sysvinit killall5 utility. It should only be used
163 in service scripts, so it will not be installed in the path.
164
165 This closes #129.
166
167 commit a2055af90054f5125cc07d4851b1dc9d16815e7c
168 Author: William Hubbs <w.d.hubbs@gmail.com>
169 Commit: William Hubbs <w.d.hubbs@gmail.com>
170
171 rc_status: calculate time differences in time_t and display seconds in uptime
172
173 commit cbf96967f1b6dc72ae16203dfbbb844bd08e8b6b
174 Author: William Hubbs <w.d.hubbs@gmail.com>
175 Commit: William Hubbs <w.d.hubbs@gmail.com>
176
177 supervise-daemon: save start time and respawn count before dropping privs
178
179 commit f1013037b47cdd6344f1b3ed92b7f84d7fcca01f
180 Author: William Hubbs <w.d.hubbs@gmail.com>
181 Commit: William Hubbs <w.d.hubbs@gmail.com>
182
183 version 0.27
184
185 commit e4bfb4530a86a4ccdff312c857df37fa0da36fd6
186 Author: William Hubbs <w.d.hubbs@gmail.com>
187 Commit: William Hubbs <w.d.hubbs@gmail.com>
188
189 update ChangeLog
190
191 commit 78e0042eccaf5a5554b195ad391b3ab0b8974cf6
192 Author: William Hubbs <w.d.hubbs@gmail.com>
193 Commit: William Hubbs <w.d.hubbs@gmail.com>
194
195 man/rc-status: document changes for supervised daemons
196
197 rc-status now shows the amount of time a supervised daemon has been
198 active as well as the number of times it has been respawned during the
199 current respawn period.
200
201 commit 82e12e309247bc84abf29aca04b3a2dd845fa11b
202 Author: William Hubbs <w.d.hubbs@gmail.com>
203 Commit: William Hubbs <w.d.hubbs@gmail.com>
204
205 rc-status: show uptimes and respawn counts for supervised daemons
206
207 commit 1ebef0d7a38ec0a9635418b75c3aabb564c1577e
208 Author: William Hubbs <w.d.hubbs@gmail.com>
209 Commit: William Hubbs <w.d.hubbs@gmail.com>
210
211 fix to_time_t to honor dst
212
213 commit 6b4050ab9cf9d678a1d6b7af7af7494f8533dbca
214 Author: William Hubbs <w.d.hubbs@gmail.com>
215 Commit: William Hubbs <w.d.hubbs@gmail.com>
216
217 fix from_time_t function
218
219 commit cf5e9aa2bbcdf1783fadeab26586c1134929d928
220 Author: William Hubbs <w.d.hubbs@gmail.com>
221 Commit: William Hubbs <w.d.hubbs@gmail.com>
222
223 Move time_t conversions to rc-misc.c so they can be shared
224
225 commit a3250e77d412f2290e381b9e7569930d95e4fc5b
226 Author: William Hubbs <w.d.hubbs@gmail.com>
227 Commit: William Hubbs <w.d.hubbs@gmail.com>
228
229 supervise-daemon: save start time and respawn count
230
231 This will allow rc-status to display an uptime and restart count for
232 supervised processes.
233
234 commit df027ca4722c8755b23a65db75728b835ccca807
235 Author: William Hubbs <w.d.hubbs@gmail.com>
236 Commit: William Hubbs <w.d.hubbs@gmail.com>
237
238 supervise-daemon: fix our status when we give up on the child process
239
240 commit 4c89e3f5fa1c65ccd0c843f98e4013c2085f243f
241 Author: William Hubbs <w.d.hubbs@gmail.com>
242 Commit: William Hubbs <w.d.hubbs@gmail.com>
243
244 supervise-daemon:create multiple options from --respawn-limit
245
246 This creates --respawn-delay, --respawn-max and --respawn-period. It was
247 suggested that it would be easier to follow if the options were
248 separated.
249
250 This is for #126.
251
252 commit 3673040722b75c0a4d06fbeb272f917c7d1ea7c4
253 Author: William Hubbs <w.d.hubbs@gmail.com>
254 Commit: William Hubbs <w.d.hubbs@gmail.com>
255
256 supervise-daemon: add a --respawn-limit option
257
258 Allow limiting the number of times supervise-daemon will attempt to respawn a
259 daemon once it has died to prevent infinite respawning. Also, set a
260 reasonable default limit (10 times in a 5 second period).
261
262 This is for issue #126.
263
264 commit 96c8ba2fb5f91a711ef5bfcfd8affe0b74ad18fe
265 Author: William Hubbs <w.d.hubbs@gmail.com>
266 Commit: William Hubbs <w.d.hubbs@gmail.com>
267
268 supervise-daemon: mark all open file descriptors FD_CLOEXEC
269
270 commit 47cf1d0c707dc88d216bebc15be3f39d5eb47fa9
271 Author: William Hubbs <w.d.hubbs@gmail.com>
272 Commit: William Hubbs <w.d.hubbs@gmail.com>
273
274 supervise-daemon:remove the controlling tty in the supervisor
275
276 commit 06a6a27e441372164872c7712b80728527a6ec05
277 Author: William Hubbs <w.d.hubbs@gmail.com>
278 Commit: William Hubbs <w.d.hubbs@gmail.com>
279
280 supervise-daemon: fix access to tty_fd and devnull_fd
281
282 Both the child and supervisor need access to these file descriptors.
283
284 commit 5de3798afc55ce147e65926f863ec9c9cef60e79
285 Author: William Hubbs <w.d.hubbs@gmail.com>
286 Commit: William Hubbs <w.d.hubbs@gmail.com>
287
288 supervise-daemon: mark the service started when the supervisor is active
289
290 commit 6ac094a59cf7b51d8527af15b07feca707a635c8
291 Author: William Hubbs <w.d.hubbs@gmail.com>
292 Commit: William Hubbs <w.d.hubbs@gmail.com>
293
294 version 0.26
295
296 commit 84c81ca02d7077a619dc704ff654385846fcd2b4
297 Author: William Hubbs <w.d.hubbs@gmail.com>
298 Commit: William Hubbs <w.d.hubbs@gmail.com>
299
300 update ChangeLog
301
302 commit 0e3f8720984d7d5752a78a4135cd268e4f83b3d7
303 Author: William Hubbs <w.d.hubbs@gmail.com>
304 Commit: William Hubbs <w.d.hubbs@gmail.com>
305
306 init: send term/kill signals as final step of shutdown
307
308 commit 5fd3747b190887d094225547f23007d25e2d9592
309 Author: William Hubbs <w.d.hubbs@gmail.com>
310 Commit: William Hubbs <w.d.hubbs@gmail.com>
311
312 reword the bugs section of the openrc-init man page
313
314 commit 4694900190a9078397bb9083328b68b489af92f4
315 Author: William Hubbs <w.d.hubbs@gmail.com>
316 Commit: William Hubbs <w.d.hubbs@gmail.com>
317
318 init: fix signal handling
319
320 The only signals we handle are SIGINT and SIGCHLD, so block all others
321 and unblock them in the child process before we start a rurnlevel.
322
323 commit 05738bfce120114037d4f02c67ec740813f94b89
324 Author: William Hubbs <w.d.hubbs@gmail.com>
325 Commit: William Hubbs <w.d.hubbs@gmail.com>
326
327 init: add re-exec capability
328
329 This will allow the re-execution of the init process after upgrading
330 OpenRC.
331
332 commit 6f88ee4ec6f59e545346a7422facc3e5b6adac04
333 Author: i.Dark_Templar <darktemplar@dark-templar-archives.net>
334 Commit: William Hubbs <w.d.hubbs@gmail.com>
335
336 bootmisc: do not remove ld-elf32.so.hints
337
338 File /var/run/ld-elf32.so.hints is used on FreeBSD 64bit multilib
339 This fixes #125.
340
341 commit cc51bdca3bac963878141da047e92f125772e14f
342 Author: William Hubbs <w.d.hubbs@gmail.com>
343 Commit: William Hubbs <w.d.hubbs@gmail.com>
344
345 Add attribution to openrc-init.c and openrc-shutdown.c
346
347 commit 13ca79856e5836117e469c3edbcfd4bf47b6bab0
348 Author: William Hubbs <w.d.hubbs@gmail.com>
349 Commit: William Hubbs <w.d.hubbs@gmail.com>
350
351 add init process
352
353 openrc-init.c and openrc-shutdown.c are based on code which was written by
354 James Hammons <jlhamm@acm.org>, so I would like to publically
355 thank him for his work.
356
357 commit 79a9edc73068244ad843f2edbe4206ce696c91c8
358 Author: i.Dark_Templar <darktemplar@dark-templar-archives.net>
359 Commit: i.Dark_Templar <darktemplar@dark-templar-archives.net>
360
361 Fix make install on FreeBSD: don't try to install /etc/init.d/modules twice
362
363 commit 9eb669591e16c5ee0ca07babe058d0b7b2396077
364 Author: Austin English <austinenglish@gmail.com>
365 Commit: William Hubbs <w.d.hubbs@gmail.com>
366
367 start-stop-daemon: warn if calling --start with --retry or --stop with --wait
368
369 This fixes #122
370
371 commit 55a87a30ec845eb725e8a923c8f8eb7aa75baa72
372 Author: William Hubbs <w.d.hubbs@gmail.com>
373 Commit: William Hubbs <w.d.hubbs@gmail.com>
374
375 init.d/agetty.in: add -prefix keyword
376
377 commit a912029462ae988ab4e2a96a0958e54a3c2e822f
378 Author: William Hubbs <w.d.hubbs@gmail.com>
379 Commit: William Hubbs <w.d.hubbs@gmail.com>
380
381 init.d/mount-ro: change dependency on killprocs and savecache to after
382
383 killprocs always succeeds and savecache is not required by mount-ro, so
384 we can just start after both of these have run.
385
386 commit 1e9078279709df2a3617bf1460890ceb1ddfcf59
387 Author: William Hubbs <w.d.hubbs@gmail.com>
388 Commit: William Hubbs <w.d.hubbs@gmail.com>
389
390 agetty-guide: typo fix
391
392 commit 51a292e09b9362f13d5747d4eedaa521ddf9ce72
393 Author: William Hubbs <w.d.hubbs@gmail.com>
394 Commit: William Hubbs <w.d.hubbs@gmail.com>
395
396 init.d: add agetty to ignore patterns
397
398 commit 50fccf47d4bd2ed6e7ea6ff7f72577c8e7b95d0d
399 Author: William Hubbs <w.d.hubbs@gmail.com>
400 Commit: William Hubbs <w.d.hubbs@gmail.com>
401
402 sh/gendepends.sh.in: fix detection of service scripts
403
404 We do not need to care about the path on the shebang line of a service
405 script as long as the shebang line ends with "openrc-run".
406 This fixes #119 and #120.
407
408 commit 9bd63b5d4a16601712a65eb8962214cdd4d26ce5
409 Author: William Hubbs <w.d.hubbs@gmail.com>
410 Commit: William Hubbs <w.d.hubbs@gmail.com>
411
412 update dependencies for clock service
413
414 The clock services had a very long list of "before" dependencies that
415 referred to other services within OpenRC. For ease of maintenance,
416 convert these to "after clock" dependencies in the individual services.
417
418 commit 48db17a93f5e60c0d241f8fb06bfbdd01206fb9c
419 Author: William Hubbs <w.d.hubbs@gmail.com>
420 Commit: William Hubbs <w.d.hubbs@gmail.com>
421
422 update news file
423
424 commit c333707cba356f4cacfd58a6fcc78f7c073dddcd
425 Author: William Hubbs <w.d.hubbs@gmail.com>
426 Commit: William Hubbs <w.d.hubbs@gmail.com>
427
428 Remove all occurances of 'before *' from dependencies
429
430 Using wildcards in dependencies causes issues when rc_parallel is set to
431 yes because it can lead to deadlocks.
432 All dependencies need to be explicit rather than implicit.
433
434 This is the first stage of moving this direction.
435
436 commit 5f5b1f7cbefd0bc14352e86a9c33260266f98d9b
437 Author: William Hubbs <w.d.hubbs@gmail.com>
438 Commit: William Hubbs <w.d.hubbs@gmail.com>
439
440 init.d/sysfs.in: efivarfs tweaks
441
442 Since we check for /sys/firmware/efi/efivars, we do not need to check
443 for /sys/firmware/efi
444
445 Since Failing to mount efivarfs is not critical, we silence the error
446 message from mount.
447
448 commit cfdf56475e600f79a433cd721cadf39114c6c58d
449 Author: William Hubbs <w.d.hubbs@gmail.com>
450 Commit: William Hubbs <w.d.hubbs@gmail.com>
451
452 version 0.25
453
454 commit fde3902d069dfdce9c59555186a5541d6d99c8aa
455 Author: William Hubbs <w.d.hubbs@gmail.com>
456 Commit: William Hubbs <w.d.hubbs@gmail.com>
457
458 update ChangeLog
459
460 commit d7bbb0f5830e1ec4df1ec52714d70ac6b0a81878
461 Author: William Hubbs <w.d.hubbs@gmail.com>
462 Commit: William Hubbs <w.d.hubbs@gmail.com>
463
464 add agetty service
465
466 The agetty service is an alternate way to manage gettys with agetty
467 under Linux which is separate from an external init system.
468
469 commit 21ca2b746cce67e2b3578fb7015c9d4c243e3a0c
470 Author: William Hubbs <w.d.hubbs@gmail.com>
471 Commit: William Hubbs <w.d.hubbs@gmail.com>
472
473 init.d/sysfs: drop modules completely from the dependencies
474
475 This is for #112.
476
477 commit 6a79aef0159d7035778fd852b26ecfac903cd029
478 Author: William Hubbs <w.d.hubbs@gmail.com>
479 Commit: William Hubbs <w.d.hubbs@gmail.com>
480
481 init.d/sysfs: Do not load efivarfs module
482
483 My understanding is that the kernel can autoload this module. If it
484 doesn't, the module should be built in or loaded from an initramfs.
485
486 This fixes https://github.com/openrc/openrc/pulls/112.
487
488 commit 4a269674b765e5267f024fa55c8644480a7304ea
489 Author: William Hubbs <w.d.hubbs@gmail.com>
490 Commit: William Hubbs <w.d.hubbs@gmail.com>
491
492 make sure netmount and localmount start after root
493
494 commit eea4decdd1c84e4b8775a255d8ed85bce5eb40a5
495 Author: William Hubbs <w.d.hubbs@gmail.com>
496 Commit: William Hubbs <w.d.hubbs@gmail.com>
497
498 net-online: typo fix
499
500 commit d4d0f25a4844ecaed43de913e8b729e7a2e894db
501 Author: William Hubbs <w.d.hubbs@gmail.com>
502 Commit: William Hubbs <w.d.hubbs@gmail.com>
503
504 net-online: updates to make the service more usable
505
506 - switch from attempting to ping the default gateway to a host outside
507 the local network, defaulting to google.com.
508 - along with this, change the name of the variable that requests a ping
509 test to include_ping_test so the meaning is more clear.
510
511 commit 1cb44092fce298004ab4c4547c6fbcac29c5997f
512 Author: William Hubbs <w.d.hubbs@gmail.com>
513 Commit: William Hubbs <w.d.hubbs@gmail.com>
514
515 sh/rc-functions.sh.in: add get_bootparam_value function
516
517 commit 4207e46622f584eb5f0cc10bbfd36f92f001a2e2
518 Author: William Hubbs <w.d.hubbs@gmail.com>
519 Commit: William Hubbs <w.d.hubbs@gmail.com>
520
521 move init.d examples under support and install them
522
523 commit f6ea16159ec8583a6f2182578334aa00578cb080
524 Author: William Hubbs <w.d.hubbs@gmail.com>
525 Commit: William Hubbs <w.d.hubbs@gmail.com>
526
527 scripts: make sure the rc-sstat symlink is always replaced
528
529 commit 9047ea4cb0d0e5e27704369380e128d26c3e86b2
530 Author: William Hubbs <w.d.hubbs@gmail.com>
531 Commit: William Hubbs <w.d.hubbs@gmail.com>
532
533 install support files
534
535 These files have been in the distribution for some time but haven't been
536 installed. They are good examples of how to do things, so we should
537 install them.
538
539 commit d7f5a696c173e7af67dd4b3f90744e0a056441e1
540 Author: William Hubbs <w.d.hubbs@gmail.com>
541 Commit: William Hubbs <w.d.hubbs@gmail.com>
542
543 support: rename all README files to README.md
544
545 commit 6f614cd3f33dbdea3a67ac2fb414b1130674ee04
546 Author: William Hubbs <w.d.hubbs@gmail.com>
547 Commit: William Hubbs <w.d.hubbs@gmail.com>
548
549 Move deptree2dot to the support folder
550
551 Since deptree2dot and the perl requirement are completely optional, we
552 can move this tool to the support folder. This gives the user the option
553 of using it if they have perl installed, and means we do not have an
554 optional runtime dependency on perl.
555
556 Documentation for this tool has also been added to the support folder.
557
558 X-Gentoo-Bug: 600742
559 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=600742
560
561 commit 85c1930acf15b0c9d3c5537fb2b0409c6a11c982
562 Author: William Pitcock <nenolod@dereferenced.org>
563 Commit: William Hubbs <w.d.hubbs@gmail.com>
564
565 test/setup_env: ensure that eval_ecolors is available on the path.
566
567 The test environment previously used the system default paths instead of installing the necessary $PATH environment
568 variable to make finding eval_ecolors work.
569 This closes #117.
570
571 X-Gentoo-Bug: 374191.
572 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=374191.
573
574 commit 96bd0c004c9549e5a2ef64277216a15da6f96a8e
575 Author: Nicolas Porcel <nicolasporcel06@gmail.com>
576 Commit: William Hubbs <w.d.hubbs@gmail.com>
577
578 Fix typo in guide.md
579
580 This fixes #115.
581
582 commit b693af90556ac9b055ba5c6e589066c1e08b2146
583 Author: William Hubbs <w.d.hubbs@gmail.com>
584 Commit: William Hubbs <w.d.hubbs@gmail.com>
585
586 Revert "scripts: do not substitute for @SHELL@ in rc-sstat"
587
588 This reverts commit e2e652e469efa5f3ebcd69828ff16d8f5ad3f1b8.
589
590 commit 6dcb6929869c2f81c1f8d0930191f74fc6dfaa3e
591 Author: Doug Freed <dwfreed@mtu.edu>
592 Commit: William Hubbs <w.d.hubbs@gmail.com>
593
594 start-stop-daemon: allow all standard signals
595
596 Also we define the signalpair_item macro.
597 This fixes #113.
598
599 X-Gentoo-Bug: 604986
600 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604986
601
602 commit e2e652e469efa5f3ebcd69828ff16d8f5ad3f1b8
603 Author: William Hubbs <w.d.hubbs@gmail.com>
604 Commit: William Hubbs <w.d.hubbs@gmail.com>
605
606 scripts: do not substitute for @SHELL@ in rc-sstat
607
608 commit b73941f0c3020e3dbd1684d09685e114c678b520
609 Author: William Hubbs <w.d.hubbs@gmail.com>
610 Commit: William Hubbs <w.d.hubbs@gmail.com>
611
612 mountinfo: make the path to /proc/mounts a constant
613
614 This path should not be hard coded in the open call.
615 Linux prior to 2.4.19 did not have /proc/self/mounts, so for now I'm
616 making this value /proc/mounts everywhere, but that may change to
617 /proc/self/mounts on linux; I'm not sure we should care about <2.4.19.
618
619 X-Gentoo-Bug: 604646
620 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604646
621
622 commit c304522131a795cf882444b5f94e81db4baf65b3
623 Author: Benda Xu <heroxbd@gentoo.org>
624 Commit: William Hubbs <w.d.hubbs@gmail.com>
625
626 Clean up warnings that can use the _unused macro
627
628 X-Gentoo-Bug: 604666
629 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604666
630
631 commit 92325b44ba58a7ca04d88ae8ca202b402b032b43
632 Author: Benda Xu <heroxbd@gentoo.org>
633 Commit: William Hubbs <w.d.hubbs@gmail.com>
634
635 Indentation fixes
636
637 X-Gentoo-Bug: 604666
638 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604666
639
640 commit 074d90f5a4e3b66e532a0becde372acf38346397
641 Author: Benda Xu <heroxbd@gentoo.org>
642 Commit: William Hubbs <w.d.hubbs@gmail.com>
643
644 Drop the use of the _BSD_SOURCE macro on Linux
645
646 X-Gentoo-Bug: 604666
647 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604666
648
649 commit 7056b56b3ccc9cbde4ef8297b923919c49c7c242
650 Author: Benda Xu <heroxbd@gentoo.org>
651 Commit: William Hubbs <w.d.hubbs@gmail.com>
652
653 Drop the use of the _BSD_SOURCE macro on GNU/Hurd
654
655 X-Gentoo-Bug: 604666
656 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604666
657
658 commit d5c3b85e3fbddbba149687244d607fcdae222f95
659 Author: Doug Freed <dwfreed@mtu.edu>
660 Commit: Doug Freed <dwfreed@mtu.edu>
661
662 loopback: drop explicit route for BSD too
663
664 commit 1ab2249448ba24a591b561f53aa64ff3df1e41f6
665 Author: William Hubbs <w.d.hubbs@gmail.com>
666 Commit: William Hubbs <w.d.hubbs@gmail.com>
667
668 version 0.24
669
670 commit a15cff21c63f2ad951af1c59a74fc7d37f78e91b
671 Author: William Hubbs <w.d.hubbs@gmail.com>
672 Commit: William Hubbs <w.d.hubbs@gmail.com>
673
674 update ChangeLog
675
0676 commit 45aa36cc623eeeb15fb6827b57e0c07a37cdef41
1677 Author: Doug Freed <dwfreed@mtu.edu>
2678 Commit: William Hubbs <w.d.hubbs@gmail.com>
9071583 Commit: William Hubbs <w.d.hubbs@gmail.com>
9081584
9091585 increment version to 0.22
910
911 commit 5bfb7d6c77ff533e34e2bbfe5b6e57410d961d70
912 Author: William Hubbs <w.d.hubbs@gmail.com>
913 Commit: William Hubbs <w.d.hubbs@gmail.com>
914
915 Update ChangeLog
916
917 commit 12c8248b5f53879935d4e62ef42023f703c7b636
918 Author: William Hubbs <w.d.hubbs@gmail.com>
919 Commit: William Hubbs <w.d.hubbs@gmail.com>
920
921 update news for 0.21
922
923 commit 820ef6dab674c2878d72edc8ea21e7250b1b5aec
924 Author: William Hubbs <w.d.hubbs@gmail.com>
925 Commit: William Hubbs <w.d.hubbs@gmail.com>
926
927 supervise-daemon: clarify documentation about configuring daemon not to fork
928
929 commit 87884db66767eba6317b506a4d7270dd22721831
930 Author: William Hubbs <w.d.hubbs@gmail.com>
931 Commit: William Hubbs <w.d.hubbs@gmail.com>
932
933 Make deprecation warnings for rc and runscript more visible
934
935 These warnings were inserted in verbose only mode in OpenRC-0.13.A
936 Now, we are making them more visible in preparation for removing these
937 compatibility binaries in the future.
938
939 commit 94077d264e14783e6ca5603d64e9d579fb206c20
940 Author: William Hubbs <w.d.hubbs@gmail.com>
941 Commit: William Hubbs <w.d.hubbs@gmail.com>
942
943 supervise-daemon: log the exit code or signal when a child process dies
944
945 commit 3351c8b4c3027f09003f8ba33e43f46762f5c453
946 Author: William Hubbs <w.d.hubbs@gmail.com>
947 Commit: William Hubbs <w.d.hubbs@gmail.com>
948
949 supervise-daemon.sh: add support for chroot variable
950
951 commit a8214af2fe3aa91930e3270af99cf1d9b7ef5b0a
952 Author: William Hubbs <w.d.hubbs@gmail.com>
953 Commit: William Hubbs <w.d.hubbs@gmail.com>
954
955 start-stop-daemon.sh: fix regression in chroot support
956
957 The support for the chroot variable was broken in 0.16, this fixes that
958 breakage.
959
960 commit 9a372812c78ea8efc55b3dea6a39c2d0559bca45
961 Author: William Hubbs <w.d.hubbs@gmail.com>
962 Commit: William Hubbs <w.d.hubbs@gmail.com>
963
964 guide.md: typo fix
965
966 This fixes #86.
967
968 commit 3fa9015b8e5610d38366f781a08789e34159b0dc
969 Author: Jason Zaman <jason@perfinion.com>
970 Commit: William Hubbs <w.d.hubbs@gmail.com>
971
972 rc-selinux: access check was backwards
973
974 commit 3b5a8b331e81ecd9a9362553c16f4527291d5528
975 Author: William Hubbs <w.d.hubbs@gmail.com>
976 Commit: William Hubbs <w.d.hubbs@gmail.com>
977
978 supervise-daemon: add pam service file
979
980 commit b3a04e797e5e459842c2c239886ab6ea08a8dc29
981 Author: Anthony G. Basile <blueness@gentoo.org>
982 Commit: Anthony G. Basile <blueness@gentoo.org>
983
984 runlevels/Makefile: add support for runlevel ‘nonetwork’
985
986 Traditional System V reserves runlevel 2 for multiuser with no
987 networking. We add support for this which is already defined in
988 the inittab as
989
990 l2:2:wait:/sbin/rc nonetwork
991
992 X-Gentoo-Bug: 533828
993 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=533828
994
995 Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
996
997 commit 92e2f2c7cc958effcec0ef773dda954a153d8e42
998 Author: William Hubbs <w.d.hubbs@gmail.com>
999 Commit: William Hubbs <w.d.hubbs@gmail.com>
1000
1001 killprocs: remove calls to sleep
1002
1003 X-Gentoo-Bug: 487084
1004 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=487084
1005
1006 commit ad23d5b8dbee70815c02271c78f415bcd7088076
1007 Author: William Hubbs <w.d.hubbs@gmail.com>
1008 Commit: William Hubbs <w.d.hubbs@gmail.com>
1009
1010 openrc-run: clean up runscript deprecation message
1011
1012 commit 62410eaf4ba92516a58a550717d7f3faf63bb79f
1013 Author: William Hubbs <w.d.hubbs@gmail.com>
1014 Commit: William Hubbs <w.d.hubbs@gmail.com>
1015
1016 add daemon supervisor
1017
1018 The supervise-daemon process is meant to be a lightweight supervisor
1019 which can monitor and restart a daemon if it crashes.
1020
1021 commit fd80b6fc67ec6a0fe4853167fb67ee40bb51b742
1022 Author: William Hubbs <w.d.hubbs@gmail.com>
1023 Commit: William Hubbs <w.d.hubbs@gmail.com>
1024
1025 localmount/netmount: clean up critical mount processing
1026
1027 Fix a typo and do not fail if a path in critical_mounts is not listed as
1028 a critical mount does not get mounted.
1029
1030 commit 5d130cc45cd334fd38b0c6874bcc81ac74636217
1031 Author: William Hubbs <w.d.hubbs@gmail.com>
1032 Commit: William Hubbs <w.d.hubbs@gmail.com>
1033
1034 localmount/netmount: allow mount points to be marked critical
1035
1036 In previous releases, we either treated no mount points as critical or
1037 all of them.
1038
1039 Now both localmount and netmount support a critical_mounts setting. If
1040 mount points listed in this setting fail to mount, localmount and
1041 netmount will fail.
1042
1043 commit 1c3c2cf6d8cb060d03919297f5fe706f6027a4c6
1044 Author: William Hubbs <w.d.hubbs@gmail.com>
1045 Commit: William Hubbs <w.d.hubbs@gmail.com>
1046
1047 netmount: fix mounting on Linux
1048
1049 Before this commit, on Linux, we were always trying to mount file
1050 systems marked with _netdev, even when the previous mount command
1051 failed. Now, we do not run the second mount if the first fails.
1052
1053 X-Gentoo-Bug: 579876
1054 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=579876
1055
1056 commit 171e856ec8a0a64504b4b4a47ab6181d37fc3dbe
1057 Author: Mike Gilbert <floppym@gentoo.org>
1058 Commit: William Hubbs <w.d.hubbs@gmail.com>
1059
1060 start-stop-daemon: Allow group read/write when creating output files
1061
1062 This allows for better interaction with inherited ACL entries.
1063 This fixes #84.
1064
1065 X-Gentoo-Bug: 577362
1066 X-Gentoo-Bug-URL: https://bugs.gentoo.org/577362
1067
1068 commit beaa71df0ab2cfa61beba4be0303099aa6c75e6a
1069 Author: Dustin C. Hatch <dustin@hatch.name>
1070 Commit: William Hubbs <w.d.hubbs@gmail.com>
1071
1072 binfmt.sh: use read in raw mode
1073
1074 The read builtin in most shells will interpret backslash characters
1075 as escapes, and they are lost when reading binfmt files line-by-line.
1076 This causes magic strings containing backslashes to be mangled and
1077 become invalid, resulting in erroneous 'invalid entry' messages.
1078
1079 The -r option to read disables special handling of backslashes and
1080 keeps all lines intact.
1081
1082 X-Gentoo-Bug: 575114
1083 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=575114
1084
1085 commit 7eaf71176b87ae69bfa622aa621341a19a9d32b0
1086 Author: William Hubbs <w.d.hubbs@gmail.com>
1087 Commit: William Hubbs <w.d.hubbs@gmail.com>
1088
1089 Fix rc_env_allow wildcard usage
1090
1091 Before this commit, using * in rc_env_allow did not work.
1092
1093 This fixes #60.
1094
1095 commit 2c1f6a16e10a45397e0872585dcb0e16684b6cbf
1096 Author: Mike Frysinger <vapier@gentoo.org>
1097 Commit: William Hubbs <w.d.hubbs@gmail.com>
1098
1099 sysfs: mount pstore when available
1100
1101 commit e82653782e1803e3c924aef055113333b18dafd9
1102 Author: Patrick Lauer <patrick@gentoo.org>
1103 Commit: William Hubbs <w.d.hubbs@gmail.com>
1104
1105 Add a basic OpenRC users guide
1106
1107 X-Gentoo-Bug: 513024
1108 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=513024
1109
1110 commit e52b5f59c22283b22e2b5a0d2ab9de6b92a73ebf
1111 Author: William Hubbs <w.d.hubbs@gmail.com>
1112 Commit: William Hubbs <w.d.hubbs@gmail.com>
1113
1114 savecache: stop saving nettree
1115
1116 Netifrc is no longer part of OpenRC, so we shouldn't save its dep tree
1117 as part of savecache.
1118
1119 This should have been removed when netifrc was split out. also, it
1120 might be related to the following bug.
1121
1122 X-Gentoo-Bug: 563720
1123 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=563720
1124
1125 commit 8a7e4d38a74c714e1a532e1b7a53fd2a5c528b63
1126 Author: William Hubbs <w.d.hubbs@gmail.com>
1127 Commit: William Hubbs <w.d.hubbs@gmail.com>
1128
1129 rc-service: add --ifinactive and --ifnotstarted flags
1130
1131 X-Gentoo-Bug: 523174
1132 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=523174
1133
1134 commit 47dd5e37cbf372df3ee0fad2c87226dce5b51587
1135 Author: William Hubbs <w.d.hubbs@gmail.com>
1136 Commit: William Hubbs <w.d.hubbs@gmail.com>
1137
1138 add back deprecation warnings lost during refactoring
1139
1140 commit e277ae57efaba3be3eb619fd00084b116c370231
1141 Author: William Hubbs <w.d.hubbs@gmail.com>
1142 Commit: William Hubbs <w.d.hubbs@gmail.com>
1143
1144 fix tests
1145
1146 X-Gentoo-Bug: 572602
1147 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572602
1148
1149 commit 69f052b611878d771fc3f56ee77639269db9b6e1
1150 Author: William Hubbs <w.d.hubbs@gmail.com>
1151 Commit: William Hubbs <w.d.hubbs@gmail.com>
1152
1153 librc: Complain when a real and virtual service have the same name
1154
1155 commit e4eacf02cae10eca48f6906592981d701b0c1973
1156 Author: William Hubbs <w.d.hubbs@gmail.com>
1157 Commit: William Hubbs <w.d.hubbs@gmail.com>
1158
1159 openrc-run: in verbose mode, log execution of the shell script
1160
1161 This is to show when openrc-run runs the openrc-run.sh script; it is
1162 used for debugging.
1163
1164 commit 30c3561b6b648d60174a22a73555b680d2cc86fc
1165 Author: Colin Booth <colin@heliocat.net>
1166 Commit: William Hubbs <w.d.hubbs@gmail.com>
1167
1168 sh/s6.sh: update s6-svc syntax to be valid for 2.2.0.0+
1169
1170 The s6-svc syntax changed for wait-up, wait-ready, wait-down, and
1171 wait-finished. This changes the s6 handling script to use the current
1172 valid syntax.
1173
1174 This fixes #65.
1175
1176 commit 5f2850366ea0f30f0f9cb6b129b69192c11e74ac
1177 Author: Manuel Rüger <manuel@rueg.eu>
1178 Commit: William Hubbs <w.d.hubbs@gmail.com>
1179
1180 Fix typo
1181
1182 This fixes #70.
1183
1184 commit 1cb7eec31f37db0de11a4b39939fd3fbe17c1e24
1185 Author: Gokturk Yuksek <gokturk@binghamton.edu>
1186 Commit: William Hubbs <w.d.hubbs@gmail.com>
1187
1188 conf.d/bootmisc: typo fix: s/dmesc/dmesg/
1189
1190 This fixes #72.
1191
1192 commit cd7883d25d0a9321b68df1c1e6ad9662306fa9e7
1193 Author: William Hubbs <w.d.hubbs@gmail.com>
1194 Commit: William Hubbs <w.d.hubbs@gmail.com>
1195
1196 localmount: Allow users to control whether errors are ignored
1197
1198 X-Gentoo-Bug: 572138
1199 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572138
1200
1201 commit 62b49b2a3ad1c13012305b4d7281d7f6543c70d7
1202 Author: Doug Freed <dwfreed@mtu.edu>
1203 Commit: William Hubbs <w.d.hubbs@gmail.com>
1204
1205 rc: remove use of magic constant and allow OpenVZ to drop to shell
1206
1207 OpenVZ has had console support for a long time now; allow them to use it
1208 to drop to a shell during interactive boot.
1209
1210 commit 4c814a0a285565bc09d662f602f93dbb938503c6
1211 Author: Doug Freed <dwfreed@mtu.edu>
1212 Commit: William Hubbs <w.d.hubbs@gmail.com>
1213
1214 librc: handle rc_sys="prefix" even if we weren't built with a prefix
1215
1216 This probably isn't needed, but it mimics old behavior.
1217
1218 commit 36dde4e7f21afba36a96837aa86f2b5d2dae3807
1219 Author: Doug Freed <dwfreed@mtu.edu>
1220 Commit: William Hubbs <w.d.hubbs@gmail.com>
1221
1222 librc: fix handling the nothing special case for rc_sys
1223
1224 commit 649f63d882d53533ae8b1c3b28967e772e738c45
1225 Author: Doug Freed <dwfreed@mtu.edu>
1226 Commit: William Hubbs <w.d.hubbs@gmail.com>
1227
1228 librc: move system detection code into rc_sys and use it
1229
1230 This fixes an issue where librc code was calling code that only existed
1231 in the rc binary.
1232
1233 This reverts commits 8addd79 and 9f6e056
1234
1235 This fixes #75.
1236
1237 commit 55a28f5d2524615560698453a5a6afd50460030c
1238 Author: William Hubbs <w.d.hubbs@gmail.com>
1239 Commit: William Hubbs <w.d.hubbs@gmail.com>
1240
1241 Revert "rc: make get_systype similar to the old rc_sys function"
1242
1243 This reverts commit f79a7a7be18d68bf264efc60d82838d03048da6b.
1244
1245 commit 6c0942137572608d02eb4b34bad55c9bf418a6ba
1246 Author: William Hubbs <w.d.hubbs@gmail.com>
1247 Commit: William Hubbs <w.d.hubbs@gmail.com>
1248
1249 Revert "librc: fix librc-depend functions to call rc_sys"
1250
1251 This reverts commit 73482cf13a338051606788957cbd0031ac850c70.
1252
1253 commit 79359f77cc786e18695368bccb6b6186ecfe38c0
1254 Author: William Hubbs <w.d.hubbs@gmail.com>
1255 Commit: William Hubbs <w.d.hubbs@gmail.com>
1256
1257 fix bsd build
1258
1259 X-Gentoo-Bug: 572068
1260 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572068
1261
1262 commit f79a7a7be18d68bf264efc60d82838d03048da6b
1263 Author: William Hubbs <w.d.hubbs@gmail.com>
1264 Commit: William Hubbs <w.d.hubbs@gmail.com>
1265
1266 rc: make get_systype similar to the old rc_sys function
1267
1268 commit 73482cf13a338051606788957cbd0031ac850c70
1269 Author: William Hubbs <w.d.hubbs@gmail.com>
1270 Commit: William Hubbs <w.d.hubbs@gmail.com>
1271
1272 librc: fix librc-depend functions to call rc_sys
1273
1274 commit 0910c455d3723ac4d4b793afb61cd82f660547f4
1275 Author: William Hubbs <w.d.hubbs@gmail.com>
1276 Commit: William Hubbs <w.d.hubbs@gmail.com>
1277
1278 src/rc/Makefile: fix make depend target
1279
1280 commit f5e06bc55ab1717ddff8c21f00f48cfcba8cb4a7
1281 Author: William Hubbs <w.d.hubbs@gmail.com>
1282 Commit: William Hubbs <w.d.hubbs@gmail.com>
1283
1284 include rc.h properly in source files
1285
1286 We were attempting to include rc.h in rc-misc.h instead of the source
1287 files where it should be included.
1288
1289 commit e7ae08c38d4753d8d54a4ed60ca98794d85aadd9
1290 Author: William Hubbs <w.d.hubbs@gmail.com>
1291 Commit: William Hubbs <w.d.hubbs@gmail.com>
1292
1293 version 0.21
1294
1295 commit 6da0abc0850dfc99df0ba50cbd0092929ec0107b
1296 Author: William Hubbs <w.d.hubbs@gmail.com>
1297 Commit: William Hubbs <w.d.hubbs@gmail.com>
1298
1299 fix selinux build
1300
1301 X-Gentoo-Bug: 571798
1302 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=571798
1303
1304 commit b34df9dd817069ade7e0526a59aaa9d3f2beb806
1305 Author: William Hubbs <w.d.hubbs@gmail.com>
1306 Commit: William Hubbs <w.d.hubbs@gmail.com>
1307
1308 fix selinux build
1309
1310 commit 6f02069746f4d8a2331ab7e000abdca9bbdd622d
1311 Author: William Hubbs <w.d.hubbs@gmail.com>
1312 Commit: William Hubbs <w.d.hubbs@gmail.com>
1313
1314 Add LANG, LC_MESSAGES and TERM to the environment whitelist
1315
1316 commit d4c7207ef3906daf6f8646e8deb6d968fe76cb36
1317 Author: William Hubbs <w.d.hubbs@gmail.com>
1318 Commit: William Hubbs <w.d.hubbs@gmail.com>
1319
1320 fix seg fault
1321
1322 commit 04f05c30d13ec83b85164a536eb570f29a66b275
1323 Author: William Hubbs <w.d.hubbs@gmail.com>
1324 Commit: William Hubbs <w.d.hubbs@gmail.com>
1325
1326 update ChangeLog
1327
1328 commit 9473ac514cb72663d5c3bac8b5473cced4a20bf7
1329 Author: joe9 <joe9mail@gmail.com>
1330 Commit: William Hubbs <w.d.hubbs@gmail.com>
1331
1332 allow the user to decide whether fsck aborts for errors
1333
1334 X-Gentoo-Bug: 564008
1335 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=564008
1336
1337 commit bf2f40828ee26d3ba9185f29db596ee5d7b9cf61
1338 Author: William Hubbs <w.d.hubbs@gmail.com>
1339 Commit: William Hubbs <w.d.hubbs@gmail.com>
1340
1341 Remove multicall binary structure from OpenRC
1342
1343 This eliminates the need for the selinux-specific wrapper scrript we
1344 were installing in /lib*/rc/{bin,sbin}.
1345
1346 commit fe485f44339963fdbee143687dcbef2069924bc6
1347 Author: William Hubbs <w.d.hubbs@gmail.com>
1348 Commit: William Hubbs <w.d.hubbs@gmail.com>
1349
1350 rc: fix compiler warnings cleanup
1351
1352 This reverts commit 981d2b3308edb0d0a68f7bdce4f2c99110de6940 and fixes
1353 the warnings that generated.
1354
1355 commit 53bc986ce5f9725d7117356e28224ac898f9c9bf
1356 Author: William Hubbs <w.d.hubbs@gmail.com>
1357 Commit: William Hubbs <w.d.hubbs@gmail.com>
1358
1359 Clean default env_whitelist
1360
1361 The whitelist of environment variables we pass to service scripts
1362 included several unnecessary variables.
1363
1364 The default whitelist now includes EERROR_QUIET, EINFO_QUIET,
1365 IN_BACKGROUND and IN_HOTPLUG.
1366
1367 X-Gentoo-Bug: 569542
1368 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=569542
1369
1370 commit 981d2b3308edb0d0a68f7bdce4f2c99110de6940
1371 Author: William Hubbs <w.d.hubbs@gmail.com>
1372 Commit: William Hubbs <w.d.hubbs@gmail.com>
1373
1374 rc: clean up compiler warnings
1375
1376 The get_systype(), detect_container(), detect_prefix() and detect_vm()
1377 functions need to return "char *" instead of "const char *".
1378
1379 commit 5d3e85bc310e12411135e98a397b35fb920a72a3
1380 Author: William Hubbs <w.d.hubbs@gmail.com>
1381 Commit: William Hubbs <w.d.hubbs@gmail.com>
1382
1383 add ignore patterns for init.d directory
1384
1385 commit 000503fad72e4eb2ef956a24df358be84b2a9493
1386 Author: William Hubbs <w.d.hubbs@gmail.com>
1387 Commit: William Hubbs <w.d.hubbs@gmail.com>
1388
1389 Convert OpenRC to a centralized copyright/license structure
1390
1391 In the past, OpenRC was a hybrid of a centralized and file-scope
1392 license/copyright structure.
1393
1394 I followed the instructions from the Software Freedom Law Center [1] to
1395 convert to a Centralized structure where possible, for easier future
1396 maintenance.
1397
1398 [1] https://softwarefreedom.org/resources/2012/ManagingCopyrightInformation.html
1212
1313 include ${TOP}/Makefile.inc
1414
15 SUBDIR= conf.d etc init.d local.d man scripts sh src sysctl.d
15 SUBDIR= conf.d etc init.d local.d man scripts sh src support sysctl.d
1616
1717 # Build pkgconfig or not
1818 MKPKGCONFIG?= yes
00 NAME= openrc
1 VERSION= 0.23
1 VERSION= 0.27
22 PKG= ${NAME}-${VERSION}
11
22 This file will contain a list of notable changes for each release. Note
33 the information in this file is in reverse order.
4
5 ## OpenRC-0.25
6
7 This version contains an OpenRC-specific implementation of init for
8 Linux which can be used in place of sysvinit or any other init process.
9 For information on its usage, see the man pages for openrc-init (8) and
10 openrc-shutdown (8).
11
12 ## OpenRC-0.24.1
13
14 This version starts cleaning up the dependencies so that rc_parallel
15 will work correctly.
16
17 The first step in this process is to remove the 'before *' from the
18 depend functions in the clock services. This means some services not
19 controlled by OpenRC may now start before instead of after the clock
20 service. If it is important for these services to start after the clock
21 service, they need to have 'after clock' added to their depend
22 functions.
23
24 ## OpenRC-0.24
25
26 Since the deptree2dot tool and the perl requirement are completely
27 optional, the deptree2dot tool has been moved to the support directory.
28 As a result, the MKTOOLS=yes/no switch has been removed from the makefiles.
29
30 This version adds the agetty service which can be used to spawn
31 agetty on a specific terminal. This is currently documented in the
32 agetty-guide.md file at the top level of this distribution.
433
534 ## OpenRC-0.23
635
2727 MKPKGCONFIG=no
2828 MKSELINUX=yes
2929 MKSTATICLIBS=no
30 MKSYSVINIT=yes
3031 MKTERMCAP=ncurses
3132 MKTERMCAP=termcap
32 MKTOOLS=yes
3333 PKG_PREFIX=/usr/pkg
3434 LOCAL_PREFIX=/usr/local
3535 PREFIX=/usr/local
7272 OpenRC by default then you may wish to backup the above listed files,
7373 remove them and then install so that the OS hooks into OpenRC.
7474
75 `init.d.misc` is not installed by default as the scripts will need
76 tweaking on a per distro basis. They are also non essential to the
77 operation of the system.
78
7975 ## Reporting Bugs
8076
8177 If you are using Gentoo Linux, bugs can be filed on their bugzilla under
0 # Setting up the agetty service in OpenRC
1
2 The agetty service is an OpenRC specific way to monitor and respawn a
3 getty, using agetty, on Linux. To use this method, make sure you aren't
4 spawning a getty manager for this port some other way (such as through
5 sysvinit/inittab), then run the following commands as root.
6
7 Note that [port] refers to the port you are spawning the getty on, for
8 example, tty1 or ttyS0. The full path to it, for example, /dev/tty1
9 should not be used.
10
11 ```
12 # cd /etc/init.d
13 # ln -s agetty agetty.[port]
14 # cd /etc/conf.d
15 # cp agetty agetty.[port]
16 #rc-update add agetty.[port] [runlevel]
17 ```
1111
1212 CONF-FreeBSD= ipfw modules moused powerd rarpd savecore syscons
1313
14 CONF-Linux= consolefont devfs dmesg hwclock keymaps killprocs modules mtab \
15 net-online
14 CONF-Linux= agetty consolefont devfs dmesg hwclock keymaps killprocs modules \
15 mtab net-online
1616
1717 CONF-NetBSD= moused rarpd savecore
1818
0 # Set the baud rate of the terminal line
1 #baud=""
2
3 # set the terminal type
4 #term_type="linux"
5
6 # extra options to pass to agetty for this port
7 #agetty_options=""
0 # If you wish to pass any options to killall5 during shutdown,
0 # If you wish to pass any options to kill_all during shutdown,
11 # you should do so here.
2 #
3 # The setting is called killall5_opts because the options here are meant
4 # to be identical to those you could pass to killall5.
25 killall5_opts=""
22 # default is all interfaces that support ethernet.
33 #interfaces=""
44
5 # This setting controls whether a ping to the default gateway is
6 # included in the test for network connectivity after all interfaces
7 # are active.
8 #ping_default_gateway=no
5 # This setting controls whether a ping test is included in the test for
6 # network connectivity after all interfaces are active.
7 #include_ping_test=no
8
9 # This setting is the host to attempt to ping if the above is yes.
10 # The default is google.com.
11 #ping_test_host=some.host.name
912
1013 # The timeout setting controls how long the net-online service waits
1114 # for the network to be configured.
177177 # "xenU" - XenU Domain (Linux and NetBSD)
178178 #rc_sys=""
179179
180 # if you use openrc-init, which is currently only available on Linux,
181 # this is the default runlevel to activate after "sysinit" and "boot"
182 # when booting.
183 #rc_default_runlevel="default"
184
180185 # on Linux and Hurd, this is the number of ttys allocated for logins
181186 # It is used in the consolefont, keymaps, numlock and termencoding
182187 # service scripts.
197197 command=
198198 command_args=
199199 pidfile=
200 ``
200 ```
201201
202202 Thus the 'smallest' service scripts can be half a dozen lines long
203203
0 agetty
01 binfmt
12 modules-load
23 bootmisc
1818 rc-enabled.in rpcbind.in savecore.in syslogd.in
1919 # These are FreeBSD specific
2020 SRCS-FreeBSD+= adjkerntz.in devd.in dumpon.in encswap.in ipfw.in \
21 modules.in modules-load.in mixer.in nscd.in powerd.in syscons.in
21 modules-load.in mixer.in nscd.in powerd.in syscons.in
2222
23 SRCS-Linux= binfmt.in devfs.in dmesg.in hwclock.in consolefont.in keymaps.in \
24 killprocs.in modules.in modules-load.in mount-ro.in mtab.in numlock.in \
25 procfs.in net-online.in sysfs.in termencoding.in
23 SRCS-Linux= agetty.in binfmt.in devfs.in dmesg.in hwclock.in consolefont.in \
24 keymaps.in killprocs.in modules.in modules-load.in mount-ro.in mtab.in \
25 numlock.in procfs.in net-online.in sysfs.in termencoding.in
2626
2727 # Generic BSD scripts
2828 SRCS-NetBSD= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \
2222
2323 depend()
2424 {
25 after swclock
2526 provide clock
2627 # BSD adjkerntz needs to be able to write to /etc
2728 if [ "$clock" = "UTC" -a -e /etc/wall_cmos_clock ] ||
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2017 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 description="start agetty on a terminal line"
12 supervisor=supervise-daemon
13 port="${RC_SVCNAME#*.}"
14 term_type="${term_type:-linux}"
15 command=/sbin/agetty
16 command_args_foreground="${agetty_options} ${port} ${baud} ${term_type}"
17 pidfile="/run/${RC_SVCNAME}.pid"
18
19 depend() {
20 after local
21 keyword -prefix
22 }
23
24 start_pre() {
25 if [ -z "$port" ]; then
26 eerror "${RC_SVCNAME} cannot be started directly. You must create"
27 eerror "symbolic links to it for the ports you want to start"
28 eerror "agetty on and add those to the appropriate runlevels."
29 return 1
30 fi
31 }
1212
1313 depend()
1414 {
15 after procfs
15 after clock procfs
1616 use modules devfs
1717 keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
1818 }
7070 ebegin "Cleaning /var/run"
7171 for x in $(find /var/run ! -type d ! -name utmp \
7272 ! -name random-seed ! -name dev.db \
73 ! -name ld-elf.so.hints ! -name ld.so.hints);
73 ! -name ld-elf.so.hints ! -name ld-elf32.so.hints \
74 ! -name ld.so.hints);
7475 do
7576 # Clean stale sockets
7677 if [ -S "$x" ]; then
239240 {
240241 # Write a halt record if we're shutting down
241242 if [ "$RC_RUNLEVEL" = shutdown ]; then
242 [ "$RC_UNAME" = Linux ] && halt -w
243 [ "$RC_UNAME" = Linux ] && openrc-shutdown -w
243244 if [ "$RC_SYS" = OPENVZ ]; then
244245 yesno $RC_REBOOT && printf "" >/reboot
245246 fi
1212
1313 depend()
1414 {
15 after clock
1516 need localmount
1617 }
1718
1111 description="Configures a specific kernel dump device."
1212
1313 depend() {
14 after clock
1415 need swap
1516 keyword -jail -prefix
1617 }
1414
1515 depend()
1616 {
17 after clock
1718 use dev clock modules
1819 keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -timeout -vserver -uml
1920 }
1414 depend()
1515 {
1616 use root
17 after clock
1718 before devd net
1819 keyword -jail -prefix
1920 }
1111 description="Sets the hostname of the machine."
1212
1313 depend() {
14 after clock
1415 keyword -docker -lxc -prefix -systemd-nspawn
1516 }
1617
3232 want modules
3333 if yesno $clock_adjfile; then
3434 use root
35 else
36 before *
3735 fi
3836 keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
3937 }
1313 depend()
1414 {
1515 need localmount termencoding
16 after bootmisc
16 after bootmisc clock
1717 keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
1818 }
1919
1818 start()
1919 {
2020 ebegin "Terminating remaining processes"
21 killall5 -15 ${killall5_opts}
21 kill_all 15 ${killall5_opts}
2222 eend 0
2323 ebegin "Killing remaining processes"
24 killall5 -9 ${killall5_opts}
24 kill_all 9 ${killall5_opts}
2525 eend 0
2626 }
1313 depend()
1414 {
1515 need fsck
16 use lvm modules mtab
17 after lvm modules
16 use lvm modules mtab root
17 after clock lvm modules root
1818 keyword -docker -jail -lxc -prefix -systemd-nspawn -vserver
1919 }
2020
1212
1313 depend()
1414 {
15 after clock
1516 keyword -jail -prefix -systemd-nspawn -vserver
1617 }
1718
2829 else
2930 ebegin "Bringing up network interface lo0"
3031 ifconfig lo0 127.0.0.1 netmask 255.0.0.0
31 route -q add -inet 127.0.0.0 -netmask 255.0.0.0 127.0.0.1
3232 fi
3333 eend $?
3434 }
1212
1313 depend()
1414 {
15 need killprocs savecache
15 after killprocs savecache
1616 keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
1717 }
1818
1212
1313 depend()
1414 {
15 after clock
1516 need root
1617 keyword -prefix -systemd-nspawn
1718 }
1414 {
1515 after modules
1616 need sysfs
17 provide network-online
1718 keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver
1819 }
1920
2425 read iftype < ${ifname}/type
2526 [ "$iftype" = "1" ] && printf "%s " ${ifname##*/}
2627 done
27 }
28
29 get_default_gateway()
30 {
31 local cmd gateway
32 if command -v ip > /dev/null 2>&1; then
33 cmd="ip route show"
34 else
35 cmd=route
36 fi
37 set -- $($cmd | grep default)
38 [ "$2" != via ] && gateway="$2" || gateway="$3"
39 printf "%s" $gateway
4028 }
4129
4230 start ()
6553 : $((timeout -= 1))
6654 done
6755 ! $infinite && [ $timeout -eq 0 ] && rc=1
68 if [ $rc -eq 0 ] && yesno ${ping_default_gateway:-no}; then
69 gateway="$(get_default_gateway)"
70 if [ -n "$gateway" ] && ! ping -c 1 $gateway > /dev/null 2>&1; then
71 rc=1
56 include_ping_test=${include_ping_test:-${ping_default_gateway}}
57 if [ -n "${ping_default_gateway}" ]; then
58 ewarn "ping_default_gateway is deprecated, please use include_ping_test"
59 fi
60 if [ $rc -eq 0 ] && yesno ${include_ping_test:-no}; then
61 ping_test_host="${ping_test_host:-google.com}"
62 if [ -n "$ping_test_host" ]; then
63 ping -c 1 $ping_test_host > /dev/null 2>&1
64 rc=$?
7265 fi
7366 fi
7467 eend $rc "The network is offline"
1919 *) mywant="$mywant nfsclient"; break ;;
2020 esac
2121 done
22 after root
2223 config /etc/fstab
2324 want $mywant
2425 use afc-client amd openvpn
2526 use dns
27 use root
2628 keyword -docker -jail -lxc -prefix -systemd-nspawn -vserver
2729 }
2830
1717 depend()
1818 {
1919 need localmount
20 after bootmisc
20 after bootmisc clock
2121 if [ -n "$(interfaces)" ]; then
2222 provide net
2323 fi
1212
1313 depend()
1414 {
15 after clock
1516 need localmount
1617 keyword -prefix
1718 }
1212
1313 depend()
1414 {
15 after clock
1516 use devfs
1617 want modules
1718 need localmount
1212
1313 depend()
1414 {
15 after clock
1516 need fsck
1617 keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -vserver
1718 }
1313 depend()
1414 {
1515 need dumpon localmount
16 after clock
1617 before encswap
1718 keyword -jail -prefix
1819 }
0 #!@SBINDIR@/openrc-run
0 S#!@BINDIR@/openrc-run
11 # Copyright (c) 2009-2015 The OpenRC Authors.
22 # See the Authors file at the top-level directory of this distribution and
33 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
1313 description="Configures static routes."
1414 __nl="
1515 "
16
1716 depend()
1817 {
18 after clock
1919 provide net
2020 use network
2121 keyword -jail -prefix -vserver
1010
1111 depend()
1212 {
13 after clock
1314 before fsck
1415 keyword -jail -prefix
1516 }
1010
1111 depend()
1212 {
13 after clock
1314 before localmount
1415 keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -vserver
1516 }
1212
1313 depend()
1414 {
15 before *
1615 provide clock
1716 keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
1817 }
99 # except according to the terms contained in the LICENSE file.
1010
1111 depend() {
12 after clock
1213 need localmount
1314 keyword -jail -prefix
1415 }
1010
1111 depend()
1212 {
13 after clock
1314 before bootmisc logger
1415 keyword -prefix -systemd-nspawn -vserver
1516 }
1414
1515 depend()
1616 {
17 want modules
1817 keyword -docker -lxc -prefix -systemd-nspawn -vserver
1918 }
2019
9897 fi
9998
10099 # set up kernel support for efivarfs
101 # The presence of /sys/firmware/efi indicates that the system was
102 # booted in efi mode.
103 if [ -d /sys/firmware/efi ]; then
104 if [ ! -d /sys/firmware/efi/efivars ] &&
105 modprobe -q efivarfs; then
106 ewarn "The efivarfs module needs to be configured in " \
107 "@SYSCONFDIR@/conf.d/modules or built in"
108 fi
109 if [ -d /sys/firmware/efi/efivars ] &&
110 ! mountinfo -q /sys/firmware/efi/efivars; then
111 if grep -qs efivarfs /proc/filesystems; then
112 ebegin "Mounting efivarfs filesystem"
113 mount -n -t efivarfs -o ${sysfs_opts} \
114 efivarfs /sys/firmware/efi/efivars
115 eend $?
116 fi
117 fi
100 if [ -d /sys/firmware/efi/efivars ] &&
101 ! mountinfo -q /sys/firmware/efi/efivars; then
102 ebegin "Mounting efivarfs filesystem"
103 mount -n -t efivarfs -o ${sysfs_opts} \
104 efivarfs /sys/firmware/efi/efivars 2> /dev/null
105 eend 0
118106 fi
119107 }
120108
2121 provide logger
2222 use net newsyslog
2323 need localmount
24 after bootmisc
24 after bootmisc clock
2525 keyword -prefix
2626 }
1717 {
1818 keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
1919 use root
20 after bootmisc
20 after bootmisc clock
2121 }
2222
2323 start()
1010
1111 depend()
1212 {
13 after fsck
13 after clock fsck
1414 keyword -prefix
1515 }
1616
1313
1414 depend()
1515 {
16 after clock
1617 need localmount
1718 keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn
1819 }
1010
1111 depend()
1212 {
13 after clock
1314 need localmount
1415 keyword -prefix
1516 }
+0
-11
init.d.misc/.gitignore less more
0 avahi-dnsconfd
1 avahid
2 dhcpcd
3 dbus
4 hald
5 named
6 ntpd
7 openvpn
8 polkitd
9 sshd
10 wpa_supplicant
+0
-11
init.d.misc/Makefile less more
0 DIR= ${INITDIR}
1 SRCS= avahi-dnsconfd.in avahid.in dhcpcd.in dbus.in \
2 hald.in named.in ntpd.in \
3 openvpn.in polkitd.in sshd.in wpa_supplicant.in
4
5 MK= ../mk
6
7 SED_EXTRA+= -e 's:@VARBASE@:/var:g'
8
9 include ${MK}/os.mk
10 include ${MK}/scripts.mk
+0
-22
init.d.misc/avahi-dnsconfd.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/avahi-dnsconfd
12 command_args="$avahi_dnsconfd_args -D"
13 pidfile=@VARBASE@/run/avahi-dnsconfd.pid
14 name="Avahi DNS Configuration Daemon"
15
16 depend()
17 {
18 use dns
19 need localmount dbus
20 after bootmisc
21 }
+0
-22
init.d.misc/avahid.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/avahi-daemon
12 command_args="$avahid_args -D"
13 pidfile=@VARBASE@/run/avahi-daemon/pid
14 name="Avahi Service Advertisement Daemon"
15
16 depend()
17 {
18 use dns
19 need localmount dbus
20 after bootmisc
21 }
+0
-26
init.d.misc/dbus.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/bin/dbus-daemon
12 pidfile=@VARBASE@/run/dbus/pid
13 command_args="${dbusd_args---system}"
14 name="Message Bus Daemon"
15
16 depend()
17 {
18 need localmount net
19 after bootmisc
20 }
21
22 start_pre()
23 {
24 mkdir -p $(dirname $pidfile)
25 }
+0
-34
init.d.misc/dhcpcd.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=/sbin/dhcpcd
12 pidfile=/var/run/dhcpcd.pid
13 command_args=-q
14 name="DHCP Client Daemon"
15
16 depend()
17 {
18 provide net
19 need localmount
20 use logger
21 after bootmisc modules
22 before dns
23 }
24
25 stop_pre()
26 {
27 # When shutting down, kill dhcpcd but preserve network
28 # We do this as /var/run/dhcpcd could be cleaned out when we
29 # return to multiuser.
30 if yesno $RC_GOINGDOWN; then
31 : ${stopsig:=SIGKILL}
32 fi
33 }
+0
-31
init.d.misc/dnsmasq.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/dnsmasq
12 command_args=$dnsmasq_args
13 pidfile=@VARBASE@/run/dnsmasq.pid
14 required_files=/etc/dnsmasq.conf
15
16 extra_started_commands="reload"
17
18 depend()
19 {
20 provide dns
21 need localmount net
22 after bootmisc
23 }
24
25 reload()
26 {
27 ebegin "Reloading $RC_SVCNAME"
28 start-stop-daemon --signal SIGHUP --pidfile "$pidfile"
29 eend $?
30 }
+0
-20
init.d.misc/hald.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/hald
12 pidfile=@VARBASE@/run/hald/hald.pid
13 command_args=$hald_args
14 name="Hardware Abstraction Layer Daemon"
15
16 depend()
17 {
18 need dbus
19 }
+0
-119
init.d.misc/named.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=/usr/sbin/named
12 command_args=$named_args
13 pidfile=@VARBASE@/run/named.pid
14 name="Domain Name server"
15 extra_started_commands="reload"
16
17 namedb=/etc/namedb
18 uid=named
19 case "$RC_UNAME" in
20 FreeBSD)
21 uid=bind
22 pidfile=@VARBASE@/run/named/pid
23 ;;
24 Linux)
25 uid=bind
26 ;;
27 esac
28 : ${named_uid:=${uid}}
29
30 depend()
31 {
32 provide dns
33 need localmount
34 after bootmisc
35 }
36
37 start_pre()
38 {
39 if [ -n "$named_chroot" ]; then
40 # Create (or update) the chroot directory structure
41 if [ -r /etc/mtree/BIND.chroot.dist ]; then
42 mtree -deU -f /etc/mtree/BIND.chroot.dist -p "$named_chroot"
43 else
44 ewarn "/etc/mtree/BIND.chroot.dist missing,"
45 ewarn "chroot directory structure not updated"
46 fi
47
48 if [ ! -d "$named_chroot"/. ]; then
49 eerror "chroot directory $named_chroot missing"
50 exit 1
51 fi
52
53 # Create /etc/namedb symlink
54 if [ ! -L "$namedb" ]; then
55 if [ -d "$namedb" ]; then
56 ewarn "named chroot: $namedb is a directory!"
57 elif [ -e "$namedb" ]; then
58 ewarn "named chroot: $namedb exists!"
59 else
60 ln -s "$named_chroot$namedb" "$namedb"
61 fi
62 else
63 # Make sure it points to the right place.
64 ln -shf "$named_chroot$namedb" "$namedb"
65 fi
66
67 case "$RC_UNAME" in
68 *BSD|DragonFly)
69 # Mount a devfs in the chroot directory if needed
70 umount "$named_chroot"/dev 2>/dev/null
71 mount -t devfs dev "$named_chroot"/dev
72 devfs -m "$named_chroot"/dev \
73 ruleset devfsrules_hide_all
74 devfs -m "$named_chroot"/dev \
75 rule apply path null unhide
76 devfs -m "$named_chroot"/dev \
77 rule apply path random unhide
78 ;;
79 esac
80
81 # Copy local timezone information if it is not up to date.
82 if [ -r /etc/localtime ]; then
83 cmp -s /etc/localtime "$named_chroot/etc/localtime" ||
84 cp -p /etc/localtime "$named_chroot/etc/localtime"
85 fi
86
87 command_args="$command_args -t $named_chroot"
88
89 ln -fs "$named_chroot$pidfile" "$pidfile"
90 fi
91
92 if [ ! -s "$named_chroot$namedb/rndc.conf" ]; then
93 local confgen="${command%/named}/rndc-confgen -a -b256 -u $named_uid \
94 -c $named_chrootdir/etc/namedb/rndc.key"
95 if [ -s "$named_chroot$namedb/rndc.key" ]; then
96 local getuser="stat -f%Su"
97 [ "$RC_UNAME" = Linux ] && getuser="stat -c%U"
98 case $(${getuser} "$named_chroot$namedb"/rndc.key) in
99 root|"$named_uid");;
100 *) $confgen;;
101 esac
102 else
103 $confgen
104 fi
105 fi
106 }
107
108 reload()
109 {
110 rndc reload
111 }
112
113 stop_post()
114 {
115 if [ -n "$named_chroot" -a -c "$named_chroot"/dev/null ]; then
116 umount "$named_chroot"/dev 2>/dev/null || true
117 fi
118 }
+0
-44
init.d.misc/ntpd.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 : ${ntpd_config:=/etc/ntp.conf}
12 : ${ntpd_drift:=/var/db/ntpd.drift}
13
14 command=/usr/sbin/ntpd
15 required_files=$ntpd_config
16 pidfile=/var/run/ntpd.pid
17 command_args="$ntpd_args -c $ntpd_config -f $ntpd_drift -p $pidfile"
18 name="Network Time Protocol Daemon"
19
20 depend()
21 {
22 use dns
23 need localmount
24 after bootmisc ntp-client
25 }
26
27 start_pre()
28 {
29 if [ -n "$ntpd_chroot" ]; then
30 case "$RC_UNAME" in
31 *BSD|DragonFly)
32 if [ ! -c "$ntpd_chroot/dev/clockctl" ]; then
33 rm -f "$ntpd_chroot/dev/clockctl"
34 (cd /dev; /bin/pax -rw -pe clockctl \
35 "$ntpd_chroot/dev")
36 fi
37 ;;
38 esac
39 ln -fs "$ntpd_chroot$ntpd_drift" "$ntpd_drift"
40
41 command_args="$command_args -u ntpd:ntpd -i $ntpd_chroot"
42 fi
43 }
+0
-74
init.d.misc/openvpn.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 vpn=${RC_SVCNAME#*.}
12 name="OpenVPN"
13 [ "$vpn" != openvpn ] && name="$name ($vpn)"
14 command=@PKG_PREFIX@/sbin/openvpn
15
16 pidfile=@VARBASE@/run/"$RC_SVCNAME".pid
17 : ${openvpn_dir:=@PKG_PREFIX@/etc/openvpn}
18 : ${openvpn_config:=$openvpn_dir/$vpn.conf}
19 command_args="$openvpn_args --daemon --config $openvpn_config"
20 command_args="$command_args --writepid $pidfile"
21 required_dirs=$openvpn_dir
22 required_files=$openvpn_config
23
24 # If we're an openvpn client, then supply a nice default config
25 # You can find sample up/down scripts in the OpenRC support/openvpn dir
26 if yesno $openvpn_client; then
27 : ${openvpn_up:=${openvpn_dir}/up.sh}
28 : ${openvpn_down:=${openvpn_dir}/down.sh}
29 command_args="$command_args --nobind --up-delay --up-restart --down-pre"
30 command_args="$command_args --up $openvpn_up"
31 command_args="$command_args --down $openvpn_down"
32 required_files="$required_files $openvpn_up $openvpn_down"
33
34 in_background_fake="start stop"
35 start_inactive=YES
36 fi
37
38 depend()
39 {
40 need localmount net
41 use dns
42 after bootmisc
43 }
44
45 start_pre()
46 {
47 # Linux has good dynamic tun/tap creation
48 if [ "$RC_UNAME" = Linux ]; then
49 if [ ! -e /dev/net/tun ]; then
50 if ! modprobe tun; then
51 eerror "TUN/TAP support is not available in this kernel"
52 return 1
53 fi
54 fi
55 if [ -h /dev/net/tun -a -c /dev/misc/net/tun ]; then
56 ebegin "Detected broken /dev/net/tun symlink, fixing..."
57 rm -f /dev/net/tun
58 ln -s /dev/misc/net/tun /dev/net/tun
59 eend $?
60 fi
61 else
62 if command -v kldload >/dev/null 2>&1; then
63 # Hammer the modules home by default
64 sysctl -a | grep -q '\.tun\.' || kldload if_tun
65 sysctl -a | grep -q '\.tap\.' || kldload if_tap
66 fi
67 fi
68
69 # If the config file does not specify the cd option, we do
70 if ! grep -q "^[ \t]*cd[ \t].*" "$openvpn_config"; then
71 command_args="$command_args --cd $openvpn_dir"
72 fi
73 }
+0
-20
init.d.misc/polkitd.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/polkitd
12 pidfile=@VARBASE@/run/polkitd/polkitd.pid
13 command_args="$polkitd_args"
14 name="PolicyKit Daemon"
15
16 depend()
17 {
18 need dbus
19 }
+0
-42
init.d.misc/sshd.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=/usr/sbin/sshd
12 command_args=$sshd_args
13 pidfile=@VARBASE@/run/sshd.pid
14 required_files=/etc/ssh/sshd_config
15
16 depend()
17 {
18 use logger dns
19 need net
20 }
21
22 start_pre()
23 {
24 if [ ! -e /etc/ssh/ssh_host_key ]; then
25 ebegin "Generating Hostkey"
26 ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N ''
27 eend $? || return 1
28 fi
29 if [ ! -e /etc/ssh/ssh_host_dsa_key ]; then
30 ebegin "Generating DSA Hostkey"
31 ssh-keygen -d -f /etc/ssh/ssh_host_dsa_key -N ''
32 eend $? || return 1
33 fi
34 if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then
35 ebegin "Generating RSA Hostkey"
36 ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
37 eend $? || return 1
38 fi
39
40 $command -t
41 }
+0
-82
init.d.misc/wpa_supplicant.in less more
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=/usr/sbin/wpa_supplicant
12 : ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf}
13 wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if
14 command_args="$wpa_supplicant_args -B -c$wpa_supplicant_conf $wpa_supplicant_if"
15 name="WPA Supplicant Daemon"
16
17 depend()
18 {
19 need localmount
20 use logger
21 after bootmisc modules
22 before dns dhcpcd net
23 keyword -shutdown
24 }
25
26 find_wireless()
27 {
28 local iface=
29
30 case "$RC_UNAME" in
31 Linux)
32 for iface in /sys/class/net/*; do
33 if [ -e "$iface"/wireless -o \
34 -e "$iface"/phy80211 ]
35 then
36 echo "${iface##*/}"
37 return 0
38 fi
39 done
40 ;;
41 FreeBSD)
42 for iface in $(sysctl -b net.wlan.devices 2>/dev/null); do
43 echo "${iface##*/}"
44 done
45 ;;
46 *)
47 for iface in /dev/net/* $(ifconfig -l 2>/dev/null); do
48 if ifconfig "${iface##*/}" 2>/dev/null | \
49 grep -q "[ ]*ssid "
50 then
51 echo "${iface##*/}"
52 return 0
53 fi
54 done
55 ;;
56 esac
57
58 return 1
59 }
60
61 append_wireless()
62 {
63 local iface= i=
64
65 iface=$(find_wireless)
66 if [ -n "$iface" ]; then
67 for i in $iface; do
68 command_args="$command_args -i$i"
69 done
70 else
71 eerror "Could not find a wireless interface"
72 fi
73 }
74
75 start_pre()
76 {
77 case " $command_args" in
78 *" -i"*) ;;
79 *) append_wireless;;
80 esac
81 }
88 service.8 start-stop-daemon.8 supervise-daemon.8
99
1010 ifeq (${OS},Linux)
11 MAN8 += rc-sstat.8
11 MAN8 += rc-sstat.8 openrc-init.8 openrc-shutdown.8
1212 endif
1313
1414 # Handy macro to create symlinks
0 .\" Copyright (c) 2017 The OpenRC Authors.
1 .\" See the Authors file at the top-level directory of this distribution and
2 .\" https://github.com/OpenRC/openrc/blob/master/AUTHORS
3 .\"
4 .\" This file is part of OpenRC. It is subject to the license terms in
5 .\" the LICENSE file found in the top-level directory of this
6 .\" distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
7 .\" This file may not be copied, modified, propagated, or distributed
8 .\" except according to the terms contained in the LICENSE file.
9 .\"
10 .Dd April 6, 2017
11 .Dt openrc-init 8 SMM
12 .Os OpenRC
13 .Sh NAME
14 .Nm openrc-init
15 .Nd the parent of all processes
16 .Sh SYNOPSIS
17 .Nm
18 .Sh DESCRIPTION
19 .Nm
20 is an init process which can be an alternative to sysvinit or any other
21 init process.
22 .Pp
23 To use
24 .Nm
25 configure your boot loader to invoke it or symlink it to /sbin/init.
26 Also, you will need to use
27 .Xr openrc-shutdown 8 ,
28 to halt, reboot or poweroff the system.
29 .Pp
30 The default runlevel is read from the init command line, the
31 rc_default_runlevel setting in rc.conf, the kernel command line, or it is
32 assumed to be "default" if it is not set in any of these places.
33 .Pp
34 .Nm
35 doesn't manage getty's directly, so you will need to manage them another
36 way. For example, you can use the agetty service script as described in
37 agetty-guide.md in this distribution.
38 .Sh BUGS
39 This was first released as part of OpenRC 0.25.
40 I do not know of any specific issues. However, since this is the first
41 release of openrc-init, please test and report any issues you find.
42 .Sh SEE ALSO
43 .Xr openrc-shutdown 8 ,
44 .Sh AUTHORS
45 .An William Hubbs <w.d.hubbs@gmail.com>
166166 Process name to match when signaling the daemon.
167167 .It Ar stopsig
168168 Signal to send when stopping the daemon.
169 .It Ar respawn_delay
170 Respawn delay
171 .Xr supervise-daemon 8
172 will use for this daemon. See
173 .Xr supervise-daemon 8
174 for more information about this setting.
175 .It Ar respawn_max
176 Respawn max
177 .Xr supervise-daemon 8
178 will use for this daemon. See
179 .Xr supervise-daemon 8
180 for more information about this setting.
181 .It Ar respawn_period
182 Respawn period
183 .Xr supervise-daemon 8
184 will use for this daemon. See
185 .Xr supervise-daemon 8
186 for more information about this setting.
169187 .It Ar retry
170188 Retry schedule to use when stopping the daemon. It can either be a
171189 timeout in seconds or multiple signal/timeout pairs (like SIGTERM/5).
0 .\" Copyright (c) 2017 The OpenRC Authors.
1 .\" See the Authors file at the top-level directory of this distribution and
2 .\" https://github.com/OpenRC/openrc/blob/master/AUTHORS
3 .\"
4 .\" This file is part of OpenRC. It is subject to the license terms in
5 .\" the LICENSE file found in the top-level directory of this
6 .\" distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
7 .\" This file may not be copied, modified, propagated, or distributed
8 .\" except according to the terms contained in the LICENSE file.
9 .\"
10 .Dd May 22, 2017
11 .Dt openrc-shutdown 8 SMM
12 .Os OpenRC
13 .Sh NAME
14 .Nm openrc-shutdown
15 .Nd bring the system down
16 .Sh SYNOPSIS
17 .Nm
18 .Op Fl d , -no-write
19 .Op Fl D , -dry-run
20 .Op Fl H , -halt
21 .Op Fl k , -kexec
22 .Op Fl p , -poweroff
23 .Op Fl R , -reexec
24 .Op Fl r , -reboot
25 .Op Fl s , -single
26 .Op Fl w , -write-only
27 .Sh DESCRIPTION
28 .Nm
29 is the utility that communicates with
30 .Xr openrc-init 8
31 to bring down the system or instruct openrc-init to re-execute itself.
32 It supports the following options:
33 .Bl -tag -width "poweroff"
34 .It Fl d , -no-write
35 Do not write the wtmp boot record.
36 .It Fl D , -dry-run
37 Print the action that would be taken without executing it. This is to
38 allow testing.
39 .It Fl H , -halt
40 Stop all services, kill all remaining processes and halt the system.
41 .It Fl k , -kexec
42 Stop all services, kill all processes and boot directly into a new
43 kernel loaded via
44 .Xr kexec 8 .
45 .It Fl p , -poweroff
46 Stop all services, kill all processes and power off the system.
47 .It Fl R , -reexec
48 instruct openrc-init to re-exec itself. This should be used after an
49 upgrade of OpenRC if you are using openrc-init as your init process.
50 .It Fl r , -reboot
51 Stop all services, kill all processes and reboot the system.
52 .It Fl s , -single
53 Stop all services, kill all processes and move to single user mode.
54 .It Fl w , -write-only
55 Stop all services, kill all processes and move to single user mode.
56 .El
57 .Sh SEE ALSO
58 .Xr openrc-init 8 ,
59 .Xr kexec 8 ,
60 .Sh AUTHORS
61 .An William Hubbs <w.d.hubbs@gmail.com>
2323 in different runlevels. The default behavior is to show information
2424 about the current runlevel and any unassigned services that are not stopped,
2525 but any runlevel can be quickly examined.
26 .Pp
27 If an active service is being supervised by
28 .Xr supervise-daemon 8,
29 the amount of time the daemon has been active along with the number of
30 times it has been respawned in the current respawn period will be
31 displayed.
2632 .Pp
2733 The options are as follows:
2834 .Bl -tag -width ".Fl test , test string"
5662 .Sh SEE ALSO
5763 .Xr openrc 8 ,
5864 .Xr rc-update 8
65 .Xr supervise-daemon 8
5966 .Sh AUTHORS
6067 .An Roy Marples <roy@marples.name>
1515 .Nd starts a daemon and restarts it if it crashes
1616 .Sh SYNOPSIS
1717 .Nm
18 .Fl D , -respawn-delay
19 .Ar seconds
1820 .Fl d , -chdir
1921 .Ar path
2022 .Fl e , -env
2527 .Ar arg
2628 .Fl k , -umask
2729 .Ar value
30 .Fl m , -respawn-max
31 .Ar count
2832 .Fl N , -nicelevel
2933 .Ar level
3034 .Fl p , -pidfile
3135 .Ar pidfile
36 .Fl P , -respawn-period
37 .Ar seconds
38 .Fl r , -chroot
39 .Ar chrootpath
3240 .Fl u , -user
3341 .Ar user
34 .Fl r , -chroot
35 .Ar chrootpath
3642 .Fl 1 , -stdout
3743 .Ar logfile
3844 .Fl 2 , -stderr
8187 .Pp
8288 The options are as follows:
8389 .Bl -tag -width indent
90 .It Fl D , -respawn-delay Ar seconds
91 wait this number of seconds before restarting a daemon after it crashes.
92 The default is 0.
8493 .It Fl d , -chdir Ar path
8594 chdir to this directory before starting the daemon.
8695 .It Fl e , -env Ar VAR=VALUE
93102 Data can be from 0 to 7 inclusive.
94103 .It Fl k , -umask Ar mode
95104 Set the umask of the daemon.
105 .It Fl m , -respawn-max Ar count
106 Sets the maximum number of times a daemon will be respawned during a
107 respawn period. If a daemon dies more than this number of times during a
108 respawn period,
109 .Nm
110 will give up trying to respawn it and exit. The default is 10, and 0
111 means unlimited.
96112 .It Fl N , -nicelevel Ar level
97113 Modifies the scheduling priority of the daemon.
114 .It Fl P , -respawn-period Ar seconds
115 Sets the length of a respawn period. The default is 10 seconds. See the
116 description of --respawn-max for more information.
98117 .It Fl r , -chroot Ar path
99118 chroot to this directory before starting the daemon. All other paths, such
100119 as the path to the daemon, chdir and pidfile, should be relative to the chroot.
122141 cause it to stop processing options at that point. Any subsequent arguments
123142 are passed as arguments to the daemon to start and used when finding a daemon
124143 to stop or signal.
144 .Sh NOTE
145 If respawn-delay, respawn-max and respawn-period are not set correctly,
146 it is possible to trigger a situation in which the supervisor will
147 infinitely try to respawn a daemon. To avoid this, if you change the
148 values of --respawn-delay, --respawn-max or --respawn-period, always
149 make sure the settings mmake sense. For example, a respawn period of 5
150 seconds with a respawn max of 10 and a respawn delay of 1 second leads
151 to infinite respawning since there can never be 10 respawns within 5
152 seconds.
125153 .Sh SEE ALSO
126154 .Xr chdir 2 ,
127155 .Xr chroot 2 ,
2525 -Wnested-externs \
2626 -Winline -Wwrite-strings -Wcast-align -Wcast-qual \
2727 -Wpointer-arith \
28 -Wdeclaration-after-statement -Wsequence-point
28 -Wdeclaration-after-statement -Wsequence-point \
29 -Werror=implicit-function-declaration
2930
3031 # We should be using -Wredundant-decls, but our library hidden proto stuff
3132 # gives loads of warnings. I don't fully understand it (the hidden proto,
1010 SFX= .GNU.in
1111 PKG_PREFIX?= /usr
1212
13 CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -DMAXPATHLEN=4096 -DPATH_MAX=4096
13 CPPFLAGS+= -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -DMAXPATHLEN=4096 -DPATH_MAX=4096
1414 LIBDL= -Wl,-Bdynamic -ldl
1010 SFX= .Linux.in
1111 PKG_PREFIX?= /usr
1212
13 CPPFLAGS+= -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700
13 CPPFLAGS+= -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700
1414 LIBDL= -Wl,-Bdynamic -ldl
1515
1616 ifeq (${MKSELINUX},yes)
5858 MANDIR?= ${MANPREFIX}/man
5959 MANMODE?= 0444
6060
61 DATADIR?= ${UPREFIX}/share/openrc
62 DATAMODE?= 0644
63
6164 DOCDIR?= ${UPREFIX}/share/doc
6265 DOCMODE?= 0644
6366
0 halt
1 poweroff
02 rc-sstat
3 reboot
4 shutdown
77 ifeq (${OS},Linux)
88 SRCS+= rc-sstat.in
99 BIN+= rc-sstat
10 ifeq (${MKSYSVINIT},yes)
11 SRCS+= halt.in poweroff.in reboot.in shutdown.in
12 BIN+= halt poweroff reboot shutdown
13 endif
1014 endif
1115
1216 _installafter:
1317 ifeq (${OS},Linux)
1418 ${INSTALL} -d ${DESTDIR}${SBINDIR}
15 ln -s ${DIR}/rc-sstat ${DESTDIR}/${SBINDIR}/rc-sstat
19 ln -sf ../${DIR}/rc-sstat ${DESTDIR}/${SBINDIR}/rc-sstat
20 ifeq (${MKSYSVINIT},yes)
21 ln -sf ../${DIR}/halt ${DESTDIR}/sbin/halt
22 ln -sf ../${DIR}/poweroff ${DESTDIR}/sbin/poweroff
23 ln -sf ../${DIR}/reboot ${DESTDIR}/sbin/reboot
24 ln -sf ../${DIR}/shutdown ${DESTDIR}/sbin/shutdown
25 ln -sf openrc-init ${DESTDIR}/sbin/init
26 endif
1627 endif
1728
1829 include ${MK}/scripts.mk
0 #!@SHELL@
1
2 exec @SBINDIR@/openrc-shutdown --halt "$@"
0 #!@SHELL@
1
2 exec @SBINDIR@/openrc-shutdown --poweroff "$@"
0 #!@SHELL@
1
2 exec @SBINDIR@/openrc-shutdown --reboot "$@"
0 #!@SHELL@
1
2 args="$@"
3 case "$@" in
4 *--single*|*-s*) args="$@" ;;
5 *) args="--single $@";;
6 esac
7 exec @SBINDIR@/openrc-shutdown "$args"
7373
7474 # Only generate dependencies for OpenRC scripts
7575 read one two three <"$RC_SERVICE"
76 [ "$one" = "#!@SBINDIR@/runscript" ] || \
77 [ "$one" = "#!@SBINDIR@/openrc-run" ] || \
78 [ "$one" = "#!" -a "$two" = "@SBINDIR@/runscript" ] || \
79 [ "$one" = "#!" -a "$two" = "@SBINDIR@/openrc-run" ] || \
80 continue
76 case "$one" in
77 \#*/openrc-run) ;;
78 \#*/runscript) ;;
79 \#!)
80 case "$two" in
81 */openrc-run) ;;
82 */runscript) ;;
83 *)
84 continue
85 ;;
86 esac
87 ;;
88 *)
89 continue
90 ;;
91 esac
8192 unset one two three
8293
8394 RC_SVCNAME=${RC_SERVICE##*/} ; export RC_SVCNAME
8484 return 1
8585 }
8686
87 get_bootparam_value()
88 {
89 local match="$1" which_value="$2" sep="$3" result value
90 if [ -n "$match" -a -r /proc/cmdline ]; then
91 set -- $(cat /proc/cmdline)
92 while [ -n "$1" ]; do
93 case "$1" in
94 $match=*)
95 value="${1##*=}"
96 case "$which_value" in
97 all)
98 [ -z "$sep" ] && sep=' '
99 if [ -z "$result" ]; then
100 result="$value"
101 else
102 result="${result}${sep}${value}"
103 fi
104 ;;
105 last)
106 result="$value"
107 ;;
108 *)
109 result="$value"
110 break
111 ;;
112 esac
113 ;;
114 esac
115 shift
116 done
117 fi
118 echo $result
119 }
120
87121 # Called from openrc-run.sh or gendepends.sh
88122 _get_containers() {
89123 local c
2424 eval supervise-daemon --start \
2525 ${chroot:+--chroot} $chroot \
2626 ${pidfile:+--pidfile} $pidfile \
27 ${respawn_delay:+--respawn-delay} $respawn_delay \
28 ${respawn_max:+--respawn-max} $respawn_max \
29 ${respawn_period:+--respawn-period} $respawn_period \
2730 ${command_user+--user} $command_user \
2831 $supervise_daemon_args \
2932 $command \
22
33 SUBDIR= test libeinfo librc rc
44
5 ifeq (${MKTOOLS},yes)
6 SUBDIR+= tools
7 endif
8
95 MK= ../mk
106 include ${MK}/subdir.mk
2222 #include <stdbool.h>
2323 #include <stdlib.h>
2424 #include <string.h>
25 #include <time.h>
2526 #include <unistd.h>
2627
2728 #include "helpers.h"
6768 bool _rc_can_find_pids(void);
6869
6970 RC_SERVICE lookup_service_state(const char *service);
71 void from_time_t(char *time_string, time_t tv);
72 time_t to_time_t(char *timestring);
7073
7174 #endif
0 /*
1 * rc-wtmp.h
2 * This is private to us and not for user consumption
3 */
4
5 /*
6 * Copyright (c) 2017 The OpenRC Authors.
7 * See the Authors file at the top-level directory of this distribution and
8 * https://github.com/OpenRC/openrc/blob/master/AUTHORS
9 *
10 * This file is part of OpenRC. It is subject to the license terms in
11 * the LICENSE file found in the top-level directory of this
12 * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
13 * This file may not be copied, modified, propagated, or distributed
14 * except according to the terms contained in the LICENSE file.
15 */
16
17 #ifndef __RC_WTMP_H__
18 #define __RC_WTMP_H__
19
20 #include <utmp.h>
21
22 void log_wtmp(const char *user, const char *id, pid_t pid, int type,
23 const char *line);
24
25 #endif
1818
1919 #include "queue.h"
2020 #include "librc.h"
21 #include "helpers.h"
2122
2223 bool
2324 rc_yesno(const char *value)
117118 librc_hidden_def(rc_getline)
118119
119120 char *
120 rc_proc_getent(const char *ent)
121 rc_proc_getent(const char *ent _unused)
121122 {
122123 #ifdef __linux__
123124 FILE *fp;
1818
1919 #include "queue.h"
2020 #include "librc.h"
21 #include <helpers.h>
2122 #ifdef __FreeBSD__
2223 # include <sys/sysctl.h>
2324 #endif
231232 }
232233
233234 static const char *
234 detect_container(const char *systype)
235 detect_container(const char *systype _unused)
235236 {
236237 #ifdef __FreeBSD__
237238 if (systype) {
295296 }
296297
297298 static const char *
298 detect_vm(const char *systype)
299 detect_vm(const char *systype _unused)
299300 {
300301 #ifdef __NetBSD__
301302 if (systype) {
3838 #define RC_CONFDIR RC_SYSCONFDIR "/conf.d"
3939 #define RC_PLUGINDIR RC_LIBDIR "/plugins"
4040
41 #define RC_INIT_FIFO RC_SVCDIR"/init.ctl"
4142 #define RC_PROFILE_ENV RC_SYSCONFDIR "/profile.env"
4243 #define RC_SYS_WHITELIST RC_LIBEXECDIR "/conf.d/env_whitelist"
4344 #define RC_USR_WHITELIST RC_SYSCONFDIR "/conf.d/env_whitelist"
5858 rc-abort
5959 rc
6060 openrc
61 openrc-init
6162 openrc-run
63 openrc-shutdown
64 kill_all
0 include ../../Makefile.inc
1 MK= ../../mk
2 include ${MK}/os.mk
3
04 SRCS= checkpath.c do_e.c do_mark_service.c do_service.c \
15 do_value.c fstabinfo.c is_newer_than.c is_older_than.c \
26 mountinfo.c openrc-run.c rc-abort.c rc.c \
610
711 ifeq (${MKSELINUX},yes)
812 SRCS+= rc-selinux.c
13 endif
14
15 ifeq (${OS},Linux)
16 SRCS+= kill_all.c openrc-init.c openrc-shutdown.c rc-wtmp.c
917 endif
1018
1119 CLEANFILES= version.h rc-selinux.o
3341 mark_service_inactive mark_service_wasinactive \
3442 mark_service_hotplugged mark_service_failed \
3543 rc-abort swclock
44
45 ifeq (${OS},Linux)
46 RC_BINPROGS+= kill_all
47 SBINPROGS+= openrc-init openrc-shutdown
48 endif
49
3650 ALL_PROGS= ${BINPROGS} ${SBINPROGS} ${RC_BINPROGS} ${RC_SBINPROGS}
3751 CLEANFILES+= ${ALL_PROGS}
3852
4054 LOCAL_LDFLAGS=-L../librc -L../libeinfo
4155 LDADD+= -lutil -lrc -leinfo
4256
43 include ../../Makefile.inc
44 MK= ../../mk
4557 include ${MK}/prog.mk
4658 include ${MK}/gitver.mk
4759 include ${MK}/cc.mk
8799 endif
88100 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
89101
102 kill_all: kill_all.o _usage.o
103 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
104
90105 einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
91106 eindent eoutdent esyslog eval_ecolors ewaitfile \
92107 veinfo vewarn vebegin veend vewend veindent veoutdent: do_e.o rc-misc.o
93108 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
94109
95110 fstabinfo: fstabinfo.o _usage.o rc-misc.o
111 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
112
113 openrc-init: openrc-init.o rc-wtmp.o
96114 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
97115
98116 is_newer_than: is_newer_than.o rc-misc.o
111129 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
112130
113131 openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o _usage.o
132 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
133
134 openrc-shutdown: openrc-shutdown.o _usage.o rc-wtmp.o
114135 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
115136
116137 openrc-run runscript: openrc-run.o _usage.o rc-misc.o rc-plugin.o
0 /*
1 * kill_all.c
2 * Sends a signal to all processes on the system.
3 */
4
5 /*
6 * Copyright (c) 2017 The OpenRC Authors.
7 * See the Authors file at the top-level directory of this distribution and
8 * https://github.com/OpenRC/openrc/blob/master/AUTHORS
9 *
10 * This file is part of OpenRC. It is subject to the license terms in
11 * the LICENSE file found in the top-level directory of this
12 * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
13 * This file may not be copied, modified, propagated, or distributed
14 * except according to the terms contained in the LICENSE file.
15 */
16
17
18 #include <dirent.h>
19 #include <errno.h>
20 #include <getopt.h>
21 #include <signal.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <syslog.h>
26 #include <unistd.h>
27 #include <sys/types.h>
28 #include <sys/wait.h>
29
30 #include "einfo.h"
31 #include "rc.h"
32 #include "rc-misc.h"
33 #include "_usage.h"
34
35 const char *applet = NULL;
36 const char *extraopts = "[signal number]";
37 const char *getoptstring = "do:" getoptstring_COMMON;
38 const struct option longopts[] = {
39 { "dry-run", 0, NULL, 'd' },
40 { "omit", 1, NULL, 'o' },
41 longopts_COMMON
42 };
43 const char * const longopts_help[] = {
44 "print what would be done",
45 "omit this pid (can be repeated)",
46 longopts_help_COMMON
47 };
48 const char *usagestring = NULL;
49
50 static int mount_proc(void)
51 {
52 pid_t pid;
53 pid_t rc;
54 int status;
55
56 if (exists("/proc/version"))
57 return 0;
58 pid = fork();
59 switch(pid) {
60 case -1:
61 syslog(LOG_ERR, "Unable to fork");
62 return -1;
63 break;
64 case 0:
65 /* attempt to mount /proc */
66 execl("mount", "mount", "-t", "proc", "proc", "/proc", NULL);
67 syslog(LOG_ERR, "Unable to execute mount");
68 exit(1);
69 break;
70 default:
71 /* wait for child process */
72 while ((rc = wait(&status)) != pid)
73 if (rc < 0 && errno == ECHILD)
74 break;
75 if (rc != pid || WEXITSTATUS(status) != 0)
76 syslog(LOG_ERR, "mount returned non-zero exit status");
77 break;
78 }
79 if (! exists("/proc/version")) {
80 syslog(LOG_ERR, "Could not mount /proc");
81 return -1;
82 }
83 return 0;
84 }
85
86 static bool is_user_process(pid_t pid)
87 {
88 char buf[PATH_MAX+1];
89 FILE *fp;
90 char path[PATH_MAX+1];
91 pid_t temp_pid;
92 bool user_process = true;
93
94 while (pid >0 && user_process) {
95 if (pid == 2) {
96 user_process = false;
97 continue;
98 }
99 snprintf(path, sizeof(path), "/proc/%d/status", pid);
100 fp = fopen(path, "r");
101 /*
102 * if we could not open the file, the process disappeared, which
103 * leaves us no way to determine for sure whether it was a user
104 * process or kernel thread, so we say it is a kernel thread to
105 * avoid accidentally killing it.
106 */
107 if (!fp) {
108 user_process = false;
109 continue;
110 }
111 temp_pid = -1;
112 while (! feof(fp)) {
113 buf[0] = 0;
114 if (fgets(buf, sizeof(buf), fp))
115 sscanf(buf, "PPid: %d", &temp_pid);
116 else
117 break;
118 }
119 fclose(fp);
120 if (temp_pid == -1) {
121 syslog(LOG_ERR, "Unable to read pid from /proc/%d/status", pid);
122 user_process = false;
123 continue;
124 }
125 pid = temp_pid;
126 }
127 return user_process;
128 }
129
130 static int signal_processes(int sig, RC_STRINGLIST *omits, bool dryrun)
131 {
132 sigset_t signals;
133 sigset_t oldsigs;
134 DIR *dir;
135 struct dirent *d;
136 char buf[PATH_MAX+1];
137 pid_t pid;
138 int sendcount = 0;
139
140 kill(-1, SIGSTOP);
141 sigfillset(&signals);
142 sigemptyset(&oldsigs);
143 sigprocmask(SIG_SETMASK, &signals, &oldsigs);
144 /*
145 * Open the /proc directory.
146 * CWD must be /proc to avoid problems if / is affected by the killing
147 * (i.e. depends on fuse).
148 */
149 if (chdir("/proc") == -1) {
150 syslog(LOG_ERR, "chdir /proc failed");
151 sigprocmask(SIG_SETMASK, &oldsigs, NULL);
152 kill(-1, SIGCONT);
153 return -1;
154 }
155 dir = opendir(".");
156 if (!dir) {
157 syslog(LOG_ERR, "cannot opendir(/proc)");
158 sigprocmask(SIG_SETMASK, &oldsigs, NULL);
159 kill(-1, SIGCONT);
160 return -1;
161 }
162
163 /* Walk through the directory. */
164 while ((d = readdir(dir)) != NULL) {
165 /* Is this a process? */
166 pid = (pid_t) atoi(d->d_name);
167 if (pid == 0)
168 continue;
169
170 /* Is this a process we have been requested to omit? */
171 sprintf(buf, "%d", pid);
172 if (rc_stringlist_find(omits, buf))
173 continue;
174
175 /* Is this process in our session? */
176 if (getsid(getpid()) == getsid(pid))
177 continue;
178
179 /* Is this a kernel thread? */
180 if (!is_user_process(pid))
181 continue;
182
183 if (dryrun)
184 einfo("Would send signal %d to process %d", sig, pid);
185 else if (kill(pid, sig) == 0)
186 sendcount++;
187 }
188 closedir(dir);
189 sigprocmask(SIG_SETMASK, &oldsigs, NULL);
190 kill(-1, SIGCONT);
191 return sendcount;
192 }
193
194 int main(int argc, char **argv)
195 {
196 char *arg = NULL;
197 int opt;
198 bool dryrun = false;
199 RC_STRINGLIST *omits = rc_stringlist_new();
200 int sig = SIGKILL;
201 char *here;
202 char *token;
203
204 /* Ensure that we are only quiet when explicitly told to be */
205 unsetenv("EINFO_QUIET");
206
207 applet = basename_c(argv[0]);
208 rc_stringlist_addu(omits, "1");
209 while ((opt = getopt_long(argc, argv, getoptstring,
210 longopts, (int *) 0)) != -1)
211 {
212 switch (opt) {
213 case 'd':
214 dryrun = true;
215 break;
216 case 'o':
217 here = optarg;
218 while ((token = strsep(&here, ",;:"))) {
219 if ((pid_t) atoi(token) > 0)
220 rc_stringlist_addu(omits, token);
221 else {
222 eerror("Invalid omit pid value %s", token);
223 usage(EXIT_FAILURE);
224 }
225 }
226 break;
227 case_RC_COMMON_GETOPT
228 }
229 }
230
231 if (argc > optind) {
232 arg = argv[optind];
233 sig = atoi(arg);
234 if (sig <= 0 || sig > 31) {
235 rc_stringlist_free(omits);
236 eerror("Invalid signal %s", arg);
237 usage(EXIT_FAILURE);
238 }
239 }
240
241 openlog(applet, LOG_CONS|LOG_PID, LOG_DAEMON);
242 if (mount_proc() != 0) {
243 rc_stringlist_free(omits);
244 eerrorx("Unable to mount /proc file system");
245 }
246 signal_processes(sig, omits, dryrun);
247 rc_stringlist_free(omits);
248 return 0;
249 }
4545 #include "_usage.h"
4646
4747 const char *applet = NULL;
48 const char *procmounts = "/proc/mounts";
4849 const char *extraopts = "[mount1] [mount2] ...";
4950 const char *getoptstring = "f:F:n:N:o:O:p:P:iste:E:" getoptstring_COMMON;
5051 const struct option longopts[] = {
322323 int netdev;
323324 RC_STRINGLIST *list;
324325
325 if ((fp = fopen("/proc/self/mounts", "r")) == NULL)
326 if ((fp = fopen(procmounts, "r")) == NULL)
326327 eerrorx("getmntinfo: %s", strerror(errno));
327328
328329 list = rc_stringlist_new();
0 /*
1 * openrc-init.c
2 * This is the init process (pid 1) for OpenRC.
3 *
4 * This is based on code written by James Hammons <jlhamm@acm.org>, so
5 * I would like to publically thank him for his work.
6 */
7
8 /*
9 * Copyright (c) 2017 The OpenRC Authors.
10 * See the Authors file at the top-level directory of this distribution and
11 * https://github.com/OpenRC/openrc/blob/master/AUTHORS
12 *
13 * This file is part of OpenRC. It is subject to the license terms in
14 * the LICENSE file found in the top-level directory of this
15 * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
16 * This file may not be copied, modified, propagated, or distributed
17 * except according to the terms contained in the LICENSE file.
18 */
19
20 #include <errno.h>
21 #include <signal.h>
22 #include <stdbool.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <unistd.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <sys/reboot.h>
30 #include <sys/wait.h>
31
32 #include "helpers.h"
33 #include "rc.h"
34 #include "rc-wtmp.h"
35 #include "version.h"
36
37 static const char *rc_default_runlevel = "default";
38
39 static pid_t do_openrc(const char *runlevel)
40 {
41 pid_t pid;
42 sigset_t signals;
43
44 pid = fork();
45 switch(pid) {
46 case -1:
47 perror("fork");
48 break;
49 case 0:
50 setsid();
51 /* unblock all signals */
52 sigemptyset(&signals);
53 sigprocmask(SIG_SETMASK, &signals, NULL);
54 printf("Starting %s runlevel\n", runlevel);
55 execl("/sbin/openrc", "/sbin/openrc", runlevel, NULL);
56 perror("exec");
57 break;
58 default:
59 break;
60 }
61 return pid;
62 }
63
64 static void init(const char *default_runlevel)
65 {
66 const char *runlevel = NULL;
67 pid_t pid;
68
69 pid = do_openrc("sysinit");
70 waitpid(pid, NULL, 0);
71 pid = do_openrc("boot");
72 waitpid(pid, NULL, 0);
73 if (default_runlevel)
74 runlevel = default_runlevel;
75 else
76 runlevel = rc_conf_value("rc_default_runlevel");
77 if (!runlevel)
78 runlevel = rc_default_runlevel;
79 if (!rc_runlevel_exists(runlevel)) {
80 printf("%s is an invalid runlevel\n", runlevel);
81 runlevel = rc_default_runlevel;
82 }
83 pid = do_openrc(runlevel);
84 waitpid(pid, NULL, 0);
85 log_wtmp("reboot", "~~", 0, RUN_LVL, "~~");
86 }
87
88 static void handle_reexec(char *my_name)
89 {
90 execl(my_name, my_name, "reexec", NULL);
91 return;
92 }
93
94 static void handle_shutdown(const char *runlevel, int cmd)
95 {
96 pid_t pid;
97
98 pid = do_openrc(runlevel);
99 while (waitpid(pid, NULL, 0) != pid);
100 printf("Sending the final term signal\n");
101 kill(-1, SIGTERM);
102 sleep(3);
103 printf("Sending the final kill signal\n");
104 kill(-1, SIGKILL);
105 sync();
106 reboot(cmd);
107 }
108
109 static void handle_single(void)
110 {
111 pid_t pid;
112
113 pid = do_openrc("single");
114 while (waitpid(pid, NULL, 0) != pid);
115 }
116
117 static void reap_zombies(void)
118 {
119 pid_t pid;
120
121 for (;;) {
122 pid = waitpid(-1, NULL, WNOHANG);
123 if (pid == 0)
124 break;
125 else if (pid == -1) {
126 if (errno == ECHILD)
127 break;
128 perror("waitpid");
129 continue;
130 }
131 }
132 }
133
134 static void signal_handler(int sig)
135 {
136 switch(sig) {
137 case SIGINT:
138 handle_shutdown("reboot", RB_AUTOBOOT);
139 break;
140 case SIGCHLD:
141 reap_zombies();
142 break;
143 default:
144 printf("Unknown signal received, %d\n", sig);
145 break;
146 }
147 }
148
149 int main(int argc, char **argv)
150 {
151 char *default_runlevel;
152 char buf[2048];
153 int count;
154 FILE *fifo;
155 bool reexec = false;
156 sigset_t signals;
157 struct sigaction sa;
158
159 if (getpid() != 1)
160 return 1;
161
162 printf("OpenRC init version %s starting\n", VERSION);
163
164 if (argc > 1)
165 default_runlevel = argv[1];
166 else
167 default_runlevel = NULL;
168
169 if (default_runlevel && strcmp(default_runlevel, "reexec") == 0)
170 reexec = true;
171
172 /* block all signals we do not handle */
173 sigfillset(&signals);
174 sigdelset(&signals, SIGCHLD);
175 sigdelset(&signals, SIGINT);
176 sigprocmask(SIG_SETMASK, &signals, NULL);
177
178 /* install signal handler */
179 memset(&sa, 0, sizeof(sa));
180 sa.sa_handler = signal_handler;
181 sigaction(SIGCHLD, &sa, NULL);
182 sigaction(SIGINT, &sa, NULL);
183 reboot(RB_DISABLE_CAD);
184
185 if (! reexec)
186 init(default_runlevel);
187
188 if (mkfifo(RC_INIT_FIFO, 0600) == -1 && errno != EEXIST)
189 perror("mkfifo");
190
191 for (;;) {
192 /* This will block until a command is sent down the pipe... */
193 fifo = fopen(RC_INIT_FIFO, "r");
194 if (!fifo) {
195 if (errno != EINTR)
196 perror("fopen");
197 continue;
198 }
199 count = fread(buf, 1, sizeof(buf) - 1, fifo);
200 buf[count] = 0;
201 fclose(fifo);
202 printf("PID1: Received \"%s\" from FIFO...\n", buf);
203 if (strcmp(buf, "halt") == 0)
204 handle_shutdown("shutdown", RB_HALT_SYSTEM);
205 else if (strcmp(buf, "kexec") == 0)
206 handle_shutdown("reboot", RB_KEXEC);
207 else if (strcmp(buf, "poweroff") == 0)
208 handle_shutdown("shutdown", RB_POWER_OFF);
209 else if (strcmp(buf, "reboot") == 0)
210 handle_shutdown("reboot", RB_AUTOBOOT);
211 else if (strcmp(buf, "reexec") == 0)
212 handle_reexec(argv[0]);
213 else if (strcmp(buf, "single") == 0)
214 handle_single();
215 }
216 return 0;
217 }
0 /*
1 * openrc-shutdown.c
2 * If you are using OpenRC's provided init, this will shut down or
3 * reboot your system.
4 *
5 * This is based on code written by James Hammons <jlhamm@acm.org>, so
6 * I would like to publically thank him for his work.
7 */
8
9 /*
10 * Copyright 2017 The OpenRC Authors.
11 * See the Authors file at the top-level directory of this distribution and
12 * https://github.com/OpenRC/openrc/blob/master/AUTHORS
13 *
14 * This file is part of OpenRC. It is subject to the license terms in
15 * the LICENSE file found in the top-level directory of this
16 * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
17 * This file may not be copied, modified, propagated, or distributed
18 * except according to the terms contained in the LICENSE file.
19 */
20
21 #include <getopt.h>
22 #include <signal.h>
23 #include <stdbool.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <unistd.h>
28 #include <sys/types.h>
29 #include <sys/utsname.h>
30
31 #include "einfo.h"
32 #include "rc.h"
33 #include "helpers.h"
34 #include "_usage.h"
35 #include "rc-wtmp.h"
36
37 const char *applet = NULL;
38 const char *extraopts = NULL;
39 const char *getoptstring = "dDHKpRrsw" getoptstring_COMMON;
40 const struct option longopts[] = {
41 { "no-write", no_argument, NULL, 'd'},
42 { "dry-run", no_argument, NULL, 'D'},
43 { "halt", no_argument, NULL, 'H'},
44 { "kexec", no_argument, NULL, 'K'},
45 { "poweroff", no_argument, NULL, 'p'},
46 { "reexec", no_argument, NULL, 'R'},
47 { "reboot", no_argument, NULL, 'r'},
48 { "single", no_argument, NULL, 's'},
49 { "write-only", no_argument, NULL, 'w'},
50 longopts_COMMON
51 };
52 const char * const longopts_help[] = {
53 "do not write wtmp record",
54 "print actions instead of executing them",
55 "halt the system",
56 "reboot the system using kexec",
57 "power off the system",
58 "re-execute init (use after upgrading)",
59 "reboot the system",
60 "single user mode",
61 "write wtmp boot record and exit",
62 longopts_help_COMMON
63 };
64 const char *usagestring = NULL;
65 const char *exclusive = "Select one of "
66 "--halt, --kexec, --poweroff, --reexec, --reboot, --single or --write-only";
67
68 static bool do_dryrun = false;
69 static bool do_halt = false;
70 static bool do_kexec = false;
71 static bool do_poweroff = false;
72 static bool do_reboot = false;
73 static bool do_reexec = false;
74 static bool do_single = false;
75 static bool do_wtmp = true;
76 static bool do_wtmp_only = false;
77
78 static void send_cmd(const char *cmd)
79 {
80 FILE *fifo;
81 size_t ignored;
82
83 if (do_dryrun) {
84 einfo("Would send %s to init", cmd);
85 return;
86 }
87 if (do_wtmp && (do_halt || do_kexec || do_reboot || do_poweroff))
88 log_wtmp("shutdown", "~~", 0, RUN_LVL, "~~");
89 fifo = fopen(RC_INIT_FIFO, "w");
90 if (!fifo) {
91 perror("fopen");
92 return;
93 }
94
95 ignored = fwrite(cmd, 1, strlen(cmd), fifo);
96 if (ignored != strlen(cmd))
97 printf("Error writing to init fifo\n");
98 fclose(fifo);
99 }
100
101 int main(int argc, char **argv)
102 {
103 int opt;
104 int cmd_count = 0;
105
106 applet = basename_c(argv[0]);
107 while ((opt = getopt_long(argc, argv, getoptstring,
108 longopts, (int *) 0)) != -1)
109 {
110 switch (opt) {
111 case 'd':
112 do_wtmp = false;
113 break;
114 case 'D':
115 do_dryrun = true;
116 break;
117 case 'H':
118 do_halt = true;
119 cmd_count++;
120 break;
121 case 'K':
122 do_kexec = true;
123 cmd_count++;
124 break;
125 case 'p':
126 do_poweroff = true;
127 cmd_count++;
128 break;
129 case 'R':
130 do_reexec = true;
131 cmd_count++;
132 break;
133 case 'r':
134 do_reboot = true;
135 cmd_count++;
136 break;
137 case 's':
138 do_single = true;
139 cmd_count++;
140 break;
141 case 'w':
142 do_wtmp_only = true;
143 cmd_count++;
144 break;
145 case_RC_COMMON_GETOPT
146 }
147 }
148 if (geteuid() != 0 && ! do_dryrun)
149 eerrorx("%s: you must be root\n", applet);
150 if (cmd_count != 1) {
151 eerror("%s: %s\n", applet, exclusive);
152 usage(EXIT_FAILURE);
153 }
154 if (do_halt)
155 send_cmd("halt");
156 else if (do_kexec)
157 send_cmd("kexec");
158 else if (do_poweroff)
159 send_cmd("poweroff");
160 else if (do_reboot)
161 send_cmd("reboot");
162 else if (do_reexec)
163 send_cmd("reexec");
164 else if (do_wtmp_only)
165 log_wtmp("shutdown", "~~", 0, RUN_LVL, "~~");
166 else if (do_single)
167 send_cmd("single");
168 return 0;
169 }
260260 break;
261261 }
262262 }
263 fclose(log);
263264 } else {
264265 log_error = 1;
265266 eerror("Error: fopen(%s) failed: %s", TMPLOG, strerror(errno));
266267 }
267268
268 fclose(log);
269269 fclose(plog);
270270 } else {
271271 /*
441441 return service_bits[i].bit;
442442 return 0;
443443 }
444
445 void from_time_t(char *time_string, time_t tv)
446 {
447 strftime(time_string, 20, "%Y-%m-%d %H:%M:%S", localtime(&tv));
448 }
449
450 time_t to_time_t(char *timestring)
451 {
452 int check = 0;
453 int year = 0;
454 int month = 0;
455 int day = 0;
456 int hour = 0;
457 int min = 0;
458 int sec = 0;
459 struct tm breakdown = {0};
460 time_t result = -1;
461
462 check = sscanf(timestring, "%4d-%2d-%2d %2d:%2d:%2d",
463 &year, &month, &day, &hour, &min, &sec);
464 if (check == 6) {
465 breakdown.tm_year = year - 1900; /* years since 1900 */
466 breakdown.tm_mon = month - 1;
467 breakdown.tm_mday = day;
468 breakdown.tm_hour = hour;
469 breakdown.tm_min = min;
470 breakdown.tm_sec = sec;
471 breakdown.tm_isdst = -1;
472 result = mktime(&breakdown);
473 }
474 return result;
475 }
7575 printf("%s\n", level);
7676 }
7777
78 static void get_uptime(const char *service, char *uptime, int uptime_size)
79 {
80 RC_SERVICE state = rc_service_state(service);
81 char *start_count;
82 time_t now;
83 char *start_time_string;
84 time_t start_time;
85 time_t time_diff;
86 time_t diff_days = (time_t) 0;
87 time_t diff_hours = (time_t) 0;
88 time_t diff_mins = (time_t) 0;
89 time_t diff_secs = (time_t) 0;
90
91 uptime[0] = '\0';
92 if (state & RC_SERVICE_STARTED) {
93 start_count = rc_service_value_get(service, "start_count");
94 start_time_string = rc_service_value_get(service, "start_time");
95 if (start_count && start_time_string) {
96 start_time = to_time_t(start_time_string);
97 now = time(NULL);
98 time_diff = (time_t) difftime(now, start_time);
99 diff_secs = time_diff;
100 if (diff_secs > (time_t) 86400) {
101 diff_days = diff_secs / (time_t) 86400;
102 diff_secs %= diff_days * (time_t) 86400;
103 }
104 if (diff_secs > (time_t) 3600) {
105 diff_hours = diff_secs / (time_t) 3600;
106 diff_secs %= diff_hours * (time_t) 3600;
107 }
108 if (diff_secs > (time_t) 60) {
109 diff_mins = diff_secs / (time_t) 60;
110 diff_secs %= diff_mins * (time_t) 60;
111 }
112 if (diff_days > 0)
113 snprintf(uptime, uptime_size,
114 "%ld day(s) %02ld:%02ld:%02ld (%s)",
115 diff_days, diff_hours, diff_mins, diff_secs,
116 start_count);
117 else
118 snprintf(uptime, uptime_size,
119 "%02ld:%02ld:%02ld (%s)",
120 diff_hours, diff_mins, diff_secs, start_count);
121 }
122 }
123 }
124
78125 static void
79126 print_service(const char *service)
80127 {
81 char status[10];
128 char status[60];
129 char uptime [40];
82130 int cols = printf(" %s", service);
83131 const char *c = ecolor(ECOLOR_GOOD);
84132 RC_SERVICE state = rc_service_state(service);
100148 {
101149 snprintf(status, sizeof(status), " crashed ");
102150 } else {
103 snprintf(status, sizeof(status), " started ");
151 get_uptime(service, uptime, 40);
152 snprintf(status, sizeof(status), " started %s", uptime);
104153 color = ECOLOR_GOOD;
105154 }
106155 } else if (state & RC_SERVICE_SCHEDULED) {
0 /*
1 * rc-wtmp.c
2 * This file contains routines to deal with the wtmp file.
3 */
4
5 /*
6 * Copyright 2017 The OpenRC Authors.
7 * See the Authors file at the top-level directory of this distribution and
8 * https://github.com/OpenRC/openrc/blob/master/AUTHORS
9 *
10 * This file is part of OpenRC. It is subject to the license terms in
11 * the LICENSE file found in the top-level directory of this
12 * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
13 * This file may not be copied, modified, propagated, or distributed
14 * except according to the terms contained in the LICENSE file.
15 */
16
17 #include <stdbool.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <unistd.h>
22 #include <sys/types.h>
23 #include <sys/utsname.h>
24
25 #include "rc-wtmp.h"
26
27 void log_wtmp(const char *user, const char *id, pid_t pid, int type,
28 const char *line)
29 {
30 struct timeval tv;
31 struct utmp utmp;
32 struct utsname uname_buf;
33
34 memset(&utmp, 0, sizeof(utmp));
35 gettimeofday(&tv, NULL);
36 utmp.ut_tv.tv_sec = tv.tv_sec;
37 utmp.ut_tv.tv_usec = tv.tv_usec;
38 utmp.ut_pid = pid;
39 utmp.ut_type = type;
40 strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
41 strncpy(utmp.ut_id , id , sizeof(utmp.ut_id ));
42 strncpy(utmp.ut_line, line, sizeof(utmp.ut_line));
43
44 /* Put the OS version in place of the hostname */
45 if (uname(&uname_buf) == 0)
46 strncpy(utmp.ut_host, uname_buf.release, sizeof(utmp.ut_host));
47
48 updwtmp(WTMP_FILE, &utmp);
49 }
6363 #include "rc.h"
6464 #include "rc-misc.h"
6565 #include "_usage.h"
66 #include "helpers.h"
6667
6768 const char *applet = NULL;
6869 const char *extraopts = NULL;
152153 # define SYS_ioprio_set __NR_ioprio_set
153154 #endif
154155 #if !defined(__DragonFly__)
155 static inline int ioprio_set(int which, int who, int ioprio)
156 static inline int ioprio_set(int which _unused,
157 int who _unused,
158 int ioprio _unused)
156159 {
157160 #ifdef SYS_ioprio_set
158161 return syscall(SYS_ioprio_set, which, who, ioprio);
193196 int signal;
194197 } SIGNALPAIR;
195198
199 #define signalpair_item(name) { #name, SIG##name },
200
196201 static const SIGNALPAIR signallist[] = {
197 { "ABRT", SIGABRT },
198 { "ALRM", SIGALRM },
199 { "FPE", SIGFPE },
200 { "HUP", SIGHUP },
201 { "ILL", SIGILL },
202 { "INT", SIGINT },
203 { "KILL", SIGKILL },
204 { "PIPE", SIGPIPE },
205 { "QUIT", SIGQUIT },
206 { "SEGV", SIGSEGV },
207 { "TERM", SIGTERM },
208 { "USR1", SIGUSR1 },
209 { "USR2", SIGUSR2 },
210 { "CHLD", SIGCHLD },
211 { "CONT", SIGCONT },
212 { "STOP", SIGSTOP },
213 { "TSTP", SIGTSTP },
214 { "TTIN", SIGTTIN },
215 { "TTOU", SIGTTOU },
202 signalpair_item(HUP)
203 signalpair_item(INT)
204 signalpair_item(QUIT)
205 signalpair_item(ILL)
206 signalpair_item(TRAP)
207 signalpair_item(ABRT)
208 signalpair_item(BUS)
209 signalpair_item(FPE)
210 signalpair_item(KILL)
211 signalpair_item(USR1)
212 signalpair_item(SEGV)
213 signalpair_item(USR2)
214 signalpair_item(PIPE)
215 signalpair_item(ALRM)
216 signalpair_item(TERM)
217 signalpair_item(CHLD)
218 signalpair_item(CONT)
219 signalpair_item(STOP)
220 signalpair_item(TSTP)
221 signalpair_item(TTIN)
222 signalpair_item(TTOU)
223 signalpair_item(URG)
224 signalpair_item(XCPU)
225 signalpair_item(XFSZ)
226 signalpair_item(VTALRM)
227 signalpair_item(PROF)
228 #ifdef SIGWINCH
229 signalpair_item(WINCH)
230 #endif
231 #ifdef SIGIO
232 signalpair_item(IO)
233 #endif
234 #ifdef SIGPWR
235 signalpair_item(PWR)
236 #endif
237 signalpair_item(SYS)
216238 { "NULL", 0 },
217239 };
218240
467489 if (tkilled == 0) {
468490 if (progressed)
469491 printf("\n");
470 eerror("%s: no matching processes found", applet);
492 eerror("%s: no matching processes found", applet);
471493 }
472494 return tkilled;
473495 }
695717 if (sscanf(tmp, "%d", &nicelevel) != 1)
696718 eerror("%s: invalid nice level `%s' (SSD_NICELEVEL)",
697719 applet, tmp);
698 if ((tmp = getenv("SSD_IONICELEVEL"))) {
699 int n = sscanf(tmp, "%d:%d", &ionicec, &ioniced);
700 if (n != 1 && n != 2)
701 eerror("%s: invalid ionice level `%s' (SSD_IONICELEVEL)",
702 applet, tmp);
703 if (ionicec == 0)
704 ioniced = 0;
705 else if (ionicec == 3)
706 ioniced = 7;
707 ionicec <<= 13; /* class shift */
708 }
720 if ((tmp = getenv("SSD_IONICELEVEL"))) {
721 int n = sscanf(tmp, "%d:%d", &ionicec, &ioniced);
722 if (n != 1 && n != 2)
723 eerror("%s: invalid ionice level `%s' (SSD_IONICELEVEL)",
724 applet, tmp);
725 if (ionicec == 0)
726 ioniced = 0;
727 else if (ionicec == 3)
728 ioniced = 7;
729 ionicec <<= 13; /* class shift */
730 }
709731
710732 /* Get our user name and initial dir */
711733 p = getenv("USER");
937959 if (redirect_stdout || redirect_stderr)
938960 eerrorx("%s: --stdout and --stderr are only relevant"
939961 " with --start", applet);
962 if (start_wait)
963 ewarn("using --wait with --stop has no effect,"
964 " use --retry instead");
940965 } else {
941966 if (!exec)
942967 eerrorx("%s: nothing to start", applet);
9891014 eerror("%s: %s does not exist", applet,
9901015 *exec_file ? exec_file : exec);
9911016 exit(EXIT_FAILURE);
992 }
1017
1018 }
1019 if (start && retry)
1020 ewarn("using --retry with --start has no effect,"
1021 " use --wait instead");
9931022
9941023 /* If we don't have a pidfile we should check if it's interpreted
9951024 * or not. If it we, we need to pass the interpreter through
6161 #include "rc.h"
6262 #include "rc-misc.h"
6363 #include "_usage.h"
64 #include "helpers.h"
6465
6566 const char *applet = NULL;
6667 const char *extraopts = NULL;
67 const char *getoptstring = "d:e:g:I:Kk:N:p:r:Su:1:2:" \
68 const char *getoptstring = "D:d:e:g:I:Kk:m:N:p:r:Su:1:2:" \
6869 getoptstring_COMMON;
6970 const struct option longopts[] = {
71 { "respawn-delay", 1, NULL, 'D'},
7072 { "chdir", 1, NULL, 'd'},
7173 { "env", 1, NULL, 'e'},
7274 { "group", 1, NULL, 'g'},
7375 { "ionice", 1, NULL, 'I'},
7476 { "stop", 0, NULL, 'K'},
7577 { "umask", 1, NULL, 'k'},
78 { "respawn-max", 1, NULL, 'm'},
7679 { "nicelevel", 1, NULL, 'N'},
7780 { "pidfile", 1, NULL, 'p'},
78 { "user", 1, NULL, 'u'},
81 { "respawn-period", 1, NULL, 'P'},
7982 { "chroot", 1, NULL, 'r'},
8083 { "start", 0, NULL, 'S'},
84 { "user", 1, NULL, 'u'},
8185 { "stdout", 1, NULL, '1'},
8286 { "stderr", 1, NULL, '2'},
8387 longopts_COMMON
8488 };
8589 const char * const longopts_help[] = {
90 "Set a respawn delay",
8691 "Change the PWD",
8792 "Set an environment string",
8893 "Change the process group",
8994 "Set an ionice class:data when starting",
9095 "Stop daemon",
9196 "Set the umask for the daemon",
97 "set maximum number of respawn attempts",
9298 "Set a nicelevel when starting",
9399 "Match pid found in this file",
94 "Change the process user",
100 "Set respawn time period",
95101 "Chroot to this directory",
96102 "Start daemon",
103 "Change the process user",
97104 "Redirect stdout to file",
98105 "Redirect stderr to file",
99106 longopts_help_COMMON
123130 # define SYS_ioprio_set __NR_ioprio_set
124131 #endif
125132 #if !defined(__DragonFly__)
126 static inline int ioprio_set(int which, int who, int ioprio)
133 static inline int ioprio_set(int which _unused, int who _unused,
134 int ioprio _unused)
127135 {
128136 #ifdef SYS_ioprio_set
129137 return syscall(SYS_ioprio_set, which, who, ioprio);
162170 return pid;
163171 }
164172
165 static void child_process(char *exec, char **argv)
173 static void child_process(char *exec, char **argv, char *svcname,
174 int start_count)
166175 {
167176 RC_STRINGLIST *env_list;
168177 RC_STRING *env;
174183 char *np;
175184 char **c;
176185 char cmdline[PATH_MAX];
186 time_t start_time;
187 char start_count_string[20];
188 char start_time_string[20];
177189
178190 #ifdef HAVE_PAM
179191 pam_handle_t *pamh = NULL;
182194 #endif
183195
184196 setsid();
197
198 if (svcname) {
199 start_time = time(NULL);
200 from_time_t(start_time_string, start_time);
201 rc_service_value_set(svcname, "start_time", start_time_string);
202 sprintf(start_count_string, "%i", start_count);
203 rc_service_value_set(svcname, "start_count", start_count_string);
204 }
185205
186206 if (nicelevel) {
187207 if (setpriority(PRIO_PROCESS, getpid(), nicelevel) == -1)
223243 /* Close any fd's to the passwd database */
224244 endpwent();
225245
246 /* remove the controlling tty */
226247 #ifdef TIOCNOTTY
227248 ioctl(tty_fd, TIOCNOTTY, 0);
228249 close(tty_fd);
318339 dup2(stderr_fd, STDERR_FILENO);
319340
320341 for (i = getdtablesize() - 1; i >= 3; --i)
321 close(i);
342 fcntl(i, F_SETFD, FD_CLOEXEC);
322343
323344 *cmdline = '\0';
324345 c = argv;
420441 char *p;
421442 char *token;
422443 int i;
444 int n;
423445 char exec_file[PATH_MAX];
446 int respawn_count = 0;
447 int respawn_delay = 0;
448 int respawn_max = 10;
449 int respawn_period = 5;
450 time_t respawn_now= 0;
451 time_t first_spawn= 0;
424452 struct passwd *pw;
425453 struct group *gr;
426454 FILE *fp;
457485 while ((opt = getopt_long(argc, argv, getoptstring, longopts,
458486 (int *) 0)) != -1)
459487 switch (opt) {
488 case 'D': /* --respawn-delay time */
489 n = sscanf(optarg, "%d", &respawn_delay);
490 if (n != 1 || respawn_delay < 1)
491 eerrorx("Invalid respawn-delay value '%s'", optarg);
492 break;
493
460494 case 'I': /* --ionice */
461495 if (sscanf(optarg, "%d:%d", &ionicec, &ioniced) == 0)
462496 eerrorx("%s: invalid ionice `%s'",
478512 applet, optarg);
479513 break;
480514
515 case 'P': /* --respawn-period time */
516 n = sscanf(optarg, "%d", &respawn_period);
517 if (n != 1 || respawn_delay < 1)
518 eerrorx("Invalid respawn-delay value '%s'", optarg);
519 break;
520
481521 case 'S': /* --start */
482522 start = true;
483523 break;
505545 if (parse_mode(&numask, optarg))
506546 eerrorx("%s: invalid mode `%s'",
507547 applet, optarg);
548 break;
549
550 case 'm': /* --respawn-max count */
551 n = sscanf(optarg, "%d", &respawn_max);
552 if (n != 1 || respawn_max < 1)
553 eerrorx("Invalid respawn-max value '%s'", optarg);
508554 break;
509555
510556 case 'p': /* --pidfile <pid-file> */
577623 if (start) {
578624 if (!exec)
579625 eerrorx("%s: nothing to start", applet);
626 if (respawn_delay * respawn_max > respawn_period) {
627 ewarn("%s: Please increase the value of --respawn-period to more "
628 "than %d to avoid infinite respawning", applet,
629 respawn_delay * respawn_max);
630 }
580631 }
581632
582633 /* Expand ~ */
636687 * result would be the same. */
637688 if (pidfile && exists(pidfile))
638689 unlink(pidfile);
639 if (svcname)
690 if (svcname) {
640691 rc_service_daemon_set(svcname, exec,
641692 (const char *const *)argv,
642693 pidfile, false);
694 rc_service_mark(svcname, RC_SERVICE_STOPPED);
695 }
643696 exit(EXIT_SUCCESS);
644697 }
645698
661714 fp = fopen(pidfile, "w");
662715 if (! fp)
663716 eerrorx("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
664 fclose(fp);
717 fclose(fp);
665718
666719 child_pid = fork();
667720 if (child_pid == -1)
671724 if (child_pid != 0)
672725 exit(EXIT_SUCCESS);
673726
727 #ifdef TIOCNOTTY
728 tty_fd = open("/dev/tty", O_RDWR);
729 #endif
730 devnull_fd = open("/dev/null", O_RDWR);
674731 child_pid = fork();
675732 if (child_pid == -1)
676733 eerrorx("%s: fork: %s", applet, strerror(errno));
678735 if (child_pid != 0) {
679736 /* this is the supervisor */
680737 umask(numask);
681
682 #ifdef TIOCNOTTY
683 tty_fd = open("/dev/tty", O_RDWR);
684 #endif
685
686 devnull_fd = open("/dev/null", O_RDWR);
687738
688739 fp = fopen(pidfile, "w");
689740 if (! fp)
690741 eerrorx("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
691742 fprintf(fp, "%d\n", getpid());
692743 fclose(fp);
744
745 if (svcname)
746 rc_service_daemon_set(svcname, exec,
747 (const char * const *) argv, pidfile, true);
748
749 /* remove the controlling tty */
750 #ifdef TIOCNOTTY
751 ioctl(tty_fd, TIOCNOTTY, 0);
752 close(tty_fd);
753 #endif
693754
694755 /*
695756 * Supervisor main loop
701762 syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
702763 kill(child_pid, SIGTERM);
703764 } else {
765 sleep(respawn_delay);
766 if (respawn_max > 0 && respawn_period > 0) {
767 respawn_now = time(NULL);
768 if (first_spawn == 0)
769 first_spawn = respawn_now;
770 if (respawn_now - first_spawn > respawn_period) {
771 respawn_count = 0;
772 first_spawn = 0;
773 } else
774 respawn_count++;
775 if (respawn_count >= respawn_max) {
776 syslog(LOG_INFO, "respawned \"%s\" too many times, "
777 "exiting", exec);
778 exiting = true;
779 continue;
780 }
781 }
704782 if (WIFEXITED(i))
705783 syslog(LOG_INFO, "%s, pid %d, exited with return code %d",
706784 exec, child_pid, WEXITSTATUS(i));
711789 if (child_pid == -1)
712790 eerrorx("%s: fork: %s", applet, strerror(errno));
713791 if (child_pid == 0)
714 child_process(exec, argv);
792 child_process(exec, argv, svcname, respawn_count);
715793 }
716794 }
717795
718 if (svcname)
796 if (pidfile && exists(pidfile))
797 unlink(pidfile);
798 if (svcname) {
719799 rc_service_daemon_set(svcname, exec,
720 (const char * const *) argv, pidfile, true);
721
800 (const char *const *)argv,
801 pidfile, false);
802 rc_service_mark(svcname, RC_SERVICE_STOPPED);
803 }
722804 exit(EXIT_SUCCESS);
723805 } else if (child_pid == 0)
724 child_process(exec, argv);
806 child_process(exec, argv, svcname, respawn_count);
725807 }
+0
-5
src/tools/Makefile less more
0 DIR= ${UPREFIX}/bin
1 BIN= deptree2dot
2
3 MK= ../../mk
4 include ${MK}/scripts.mk
+0
-44
src/tools/deptree2dot less more
0 #!/usr/bin/perl -w
1 # -*- cperl -*-
2 # Copyright © 2012 Diego Elio Pettenò <flameeyes@flameeyes.eu>
3 # Released under the 2-clause BSD license.
4 #
5 #Example usage:
6 #deptree2dot > deptree.dot
7 #deptree2dot | dot -Tpng -o deptree.png
8
9 my $deptree = defined($ARGV[0]) ? $ARGV[0] : "/run/openrc/deptree";
10
11 open DEPTREE, $deptree or exit 1;
12
13 print "digraph deptree {\n";
14
15 my @deptree;
16
17 while(my $line = readline(DEPTREE)) {
18 $line =~ /^depinfo_([0-9]+)_([a-z]+)(?:_[0-9]+)?='(.*)'\n$/;
19 my $index = $1;
20 my $prop = $2;
21 my $value = $3; $value =~ s/[-\.:~]/_/g;
22
23 if ( $prop eq "service" ) {
24 $deptree[$index] = $value;
25 printf "%s [shape=box];\n", $value;
26 } else {
27 my $service = $deptree[$index];
28
29 if ( $prop eq "ineed" ) {
30 printf "%s -> %s;\n", $service, $value;
31 } elsif ( $prop eq "iuse" ) {
32 printf "%s -> %s [color=blue];\n", $service, $value;
33 } elsif ( $prop eq "ibefore" ) {
34 printf "%s -> %s [style=dotted];\n", $service, $value;
35 } elsif ( $prop eq "iafter" ) {
36 printf "%s -> %s [style=dotted color=purple];\n", $value, $service;
37 } elsif ( $prop eq "iprovide" ) {
38 printf "%s -> %s [color=red];\n", $value, $service;
39 }
40 }
41 }
42
43 print "}\n";
0 # Copyright (c) 2017 the OpenRC Authors.
1 # See the Authors file at the top-level directory of this distribution and
2 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
3 #
4 # This file is part of OpenRC. It is subject to the license terms in
5 # the LICENSE file found in the top-level directory of this
6 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
7 # This file may not be copied, modified, propagated, or distributed
8 # except according to the terms contained in the LICENSE file.
9
10 MK= ../mk
11 include ${MK}/os.mk
12
13 SUBDIR= deptree2dot init.d.examples openvpn
14
15 ifeq (${OS},Linux)
16 SUBDIR+= sysvinit
17 endif
18
19 include ${MK}/subdir.mk
0 MK= ../../mk
1 include ${MK}/os.mk
2
3 DIR= ${DATADIR}/support/deptree2dot
4 BIN= deptree2dot
5 INC= README.md
6
7
8 include ${MK}/scripts.mk
0 # deptree2dot - Graph the OpenRC Dependency Tree
1
2 This utility can be used to graph the OpenRC dependency tree. It
3 requires perl5.x and converts the tree to a .dot file which can be
4 processed by graphviz.
5
6 Example usage:
7
8 $ chmod +x deptree2dot
9 $deptree2dot > deptree.dot
10 $deptree2dot | dot -Tpng -o deptree.png
0 #!/usr/bin/perl -w
1 # -*- cperl -*-
2 # Copyright © 2012 Diego Elio Pettenò <flameeyes@flameeyes.eu>
3 # Released under the 2-clause BSD license.
4 #
5 #Example usage:
6 #deptree2dot > deptree.dot
7 #deptree2dot | dot -Tpng -o deptree.png
8
9 my $deptree = defined($ARGV[0]) ? $ARGV[0] : "/run/openrc/deptree";
10
11 open DEPTREE, $deptree or exit 1;
12
13 print "digraph deptree {\n";
14
15 my @deptree;
16
17 while(my $line = readline(DEPTREE)) {
18 $line =~ /^depinfo_([0-9]+)_([a-z]+)(?:_[0-9]+)?='(.*)'\n$/;
19 my $index = $1;
20 my $prop = $2;
21 my $value = $3; $value =~ s/[-\.:~]/_/g;
22
23 if ( $prop eq "service" ) {
24 $deptree[$index] = $value;
25 printf "%s [shape=box];\n", $value;
26 } else {
27 my $service = $deptree[$index];
28
29 if ( $prop eq "ineed" ) {
30 printf "%s -> %s;\n", $service, $value;
31 } elsif ( $prop eq "iuse" ) {
32 printf "%s -> %s [color=blue];\n", $service, $value;
33 } elsif ( $prop eq "ibefore" ) {
34 printf "%s -> %s [style=dotted];\n", $service, $value;
35 } elsif ( $prop eq "iafter" ) {
36 printf "%s -> %s [style=dotted color=purple];\n", $value, $service;
37 } elsif ( $prop eq "iprovide" ) {
38 printf "%s -> %s [color=red];\n", $value, $service;
39 }
40 }
41 }
42
43 print "}\n";
0 avahi-dnsconfd
1 avahid
2 dhcpcd
3 dbus
4 hald
5 named
6 ntpd
7 openvpn
8 polkitd
9 sshd
10 wpa_supplicant
0 DIR= ${DATADIR}/support/init.d.examples
1 INC= README.md
2 SRCS= avahi-dnsconfd.in avahid.in dhcpcd.in dbus.in \
3 hald.in named.in ntpd.in \
4 openvpn.in polkitd.in sshd.in wpa_supplicant.in
5 BIN= ${OBJS}
6
7 MK= ../../mk
8
9 SED_EXTRA+= -e 's:@VARBASE@:/var:g'
10
11 include ${MK}/os.mk
12 include ${MK}/scripts.mk
0 The service scripts in this directory are meant as examples only.
1 They are not installed by default as the scripts will need tweaking on a
2 per distro basis. They are also non essential to the operation of the system.
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/avahi-dnsconfd
12 command_args="$avahi_dnsconfd_args -D"
13 pidfile=@VARBASE@/run/avahi-dnsconfd.pid
14 name="Avahi DNS Configuration Daemon"
15
16 depend()
17 {
18 use dns
19 need localmount dbus
20 after bootmisc
21 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/avahi-daemon
12 command_args="$avahid_args -D"
13 pidfile=@VARBASE@/run/avahi-daemon/pid
14 name="Avahi Service Advertisement Daemon"
15
16 depend()
17 {
18 use dns
19 need localmount dbus
20 after bootmisc
21 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/bin/dbus-daemon
12 pidfile=@VARBASE@/run/dbus/pid
13 command_args="${dbusd_args---system}"
14 name="Message Bus Daemon"
15
16 depend()
17 {
18 need localmount net
19 after bootmisc
20 }
21
22 start_pre()
23 {
24 mkdir -p $(dirname $pidfile)
25 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=/sbin/dhcpcd
12 pidfile=/var/run/dhcpcd.pid
13 command_args=-q
14 name="DHCP Client Daemon"
15
16 depend()
17 {
18 provide net
19 need localmount
20 use logger
21 after bootmisc modules
22 before dns
23 }
24
25 stop_pre()
26 {
27 # When shutting down, kill dhcpcd but preserve network
28 # We do this as /var/run/dhcpcd could be cleaned out when we
29 # return to multiuser.
30 if yesno $RC_GOINGDOWN; then
31 : ${stopsig:=SIGKILL}
32 fi
33 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/dnsmasq
12 command_args=$dnsmasq_args
13 pidfile=@VARBASE@/run/dnsmasq.pid
14 required_files=/etc/dnsmasq.conf
15
16 extra_started_commands="reload"
17
18 depend()
19 {
20 provide dns
21 need localmount net
22 after bootmisc
23 }
24
25 reload()
26 {
27 ebegin "Reloading $RC_SVCNAME"
28 start-stop-daemon --signal SIGHUP --pidfile "$pidfile"
29 eend $?
30 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/hald
12 pidfile=@VARBASE@/run/hald/hald.pid
13 command_args=$hald_args
14 name="Hardware Abstraction Layer Daemon"
15
16 depend()
17 {
18 need dbus
19 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=/usr/sbin/named
12 command_args=$named_args
13 pidfile=@VARBASE@/run/named.pid
14 name="Domain Name server"
15 extra_started_commands="reload"
16
17 namedb=/etc/namedb
18 uid=named
19 case "$RC_UNAME" in
20 FreeBSD)
21 uid=bind
22 pidfile=@VARBASE@/run/named/pid
23 ;;
24 Linux)
25 uid=bind
26 ;;
27 esac
28 : ${named_uid:=${uid}}
29
30 depend()
31 {
32 provide dns
33 need localmount
34 after bootmisc
35 }
36
37 start_pre()
38 {
39 if [ -n "$named_chroot" ]; then
40 # Create (or update) the chroot directory structure
41 if [ -r /etc/mtree/BIND.chroot.dist ]; then
42 mtree -deU -f /etc/mtree/BIND.chroot.dist -p "$named_chroot"
43 else
44 ewarn "/etc/mtree/BIND.chroot.dist missing,"
45 ewarn "chroot directory structure not updated"
46 fi
47
48 if [ ! -d "$named_chroot"/. ]; then
49 eerror "chroot directory $named_chroot missing"
50 exit 1
51 fi
52
53 # Create /etc/namedb symlink
54 if [ ! -L "$namedb" ]; then
55 if [ -d "$namedb" ]; then
56 ewarn "named chroot: $namedb is a directory!"
57 elif [ -e "$namedb" ]; then
58 ewarn "named chroot: $namedb exists!"
59 else
60 ln -s "$named_chroot$namedb" "$namedb"
61 fi
62 else
63 # Make sure it points to the right place.
64 ln -shf "$named_chroot$namedb" "$namedb"
65 fi
66
67 case "$RC_UNAME" in
68 *BSD|DragonFly)
69 # Mount a devfs in the chroot directory if needed
70 umount "$named_chroot"/dev 2>/dev/null
71 mount -t devfs dev "$named_chroot"/dev
72 devfs -m "$named_chroot"/dev \
73 ruleset devfsrules_hide_all
74 devfs -m "$named_chroot"/dev \
75 rule apply path null unhide
76 devfs -m "$named_chroot"/dev \
77 rule apply path random unhide
78 ;;
79 esac
80
81 # Copy local timezone information if it is not up to date.
82 if [ -r /etc/localtime ]; then
83 cmp -s /etc/localtime "$named_chroot/etc/localtime" ||
84 cp -p /etc/localtime "$named_chroot/etc/localtime"
85 fi
86
87 command_args="$command_args -t $named_chroot"
88
89 ln -fs "$named_chroot$pidfile" "$pidfile"
90 fi
91
92 if [ ! -s "$named_chroot$namedb/rndc.conf" ]; then
93 local confgen="${command%/named}/rndc-confgen -a -b256 -u $named_uid \
94 -c $named_chrootdir/etc/namedb/rndc.key"
95 if [ -s "$named_chroot$namedb/rndc.key" ]; then
96 local getuser="stat -f%Su"
97 [ "$RC_UNAME" = Linux ] && getuser="stat -c%U"
98 case $(${getuser} "$named_chroot$namedb"/rndc.key) in
99 root|"$named_uid");;
100 *) $confgen;;
101 esac
102 else
103 $confgen
104 fi
105 fi
106 }
107
108 reload()
109 {
110 rndc reload
111 }
112
113 stop_post()
114 {
115 if [ -n "$named_chroot" -a -c "$named_chroot"/dev/null ]; then
116 umount "$named_chroot"/dev 2>/dev/null || true
117 fi
118 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 : ${ntpd_config:=/etc/ntp.conf}
12 : ${ntpd_drift:=/var/db/ntpd.drift}
13
14 command=/usr/sbin/ntpd
15 required_files=$ntpd_config
16 pidfile=/var/run/ntpd.pid
17 command_args="$ntpd_args -c $ntpd_config -f $ntpd_drift -p $pidfile"
18 name="Network Time Protocol Daemon"
19
20 depend()
21 {
22 use dns
23 need localmount
24 after bootmisc ntp-client
25 }
26
27 start_pre()
28 {
29 if [ -n "$ntpd_chroot" ]; then
30 case "$RC_UNAME" in
31 *BSD|DragonFly)
32 if [ ! -c "$ntpd_chroot/dev/clockctl" ]; then
33 rm -f "$ntpd_chroot/dev/clockctl"
34 (cd /dev; /bin/pax -rw -pe clockctl \
35 "$ntpd_chroot/dev")
36 fi
37 ;;
38 esac
39 ln -fs "$ntpd_chroot$ntpd_drift" "$ntpd_drift"
40
41 command_args="$command_args -u ntpd:ntpd -i $ntpd_chroot"
42 fi
43 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 vpn=${RC_SVCNAME#*.}
12 name="OpenVPN"
13 [ "$vpn" != openvpn ] && name="$name ($vpn)"
14 command=@PKG_PREFIX@/sbin/openvpn
15
16 pidfile=@VARBASE@/run/"$RC_SVCNAME".pid
17 : ${openvpn_dir:=@PKG_PREFIX@/etc/openvpn}
18 : ${openvpn_config:=$openvpn_dir/$vpn.conf}
19 command_args="$openvpn_args --daemon --config $openvpn_config"
20 command_args="$command_args --writepid $pidfile"
21 required_dirs=$openvpn_dir
22 required_files=$openvpn_config
23
24 # If we're an openvpn client, then supply a nice default config
25 # You can find sample up/down scripts in the OpenRC support/openvpn dir
26 if yesno $openvpn_client; then
27 : ${openvpn_up:=${openvpn_dir}/up.sh}
28 : ${openvpn_down:=${openvpn_dir}/down.sh}
29 command_args="$command_args --nobind --up-delay --up-restart --down-pre"
30 command_args="$command_args --up $openvpn_up"
31 command_args="$command_args --down $openvpn_down"
32 required_files="$required_files $openvpn_up $openvpn_down"
33
34 in_background_fake="start stop"
35 start_inactive=YES
36 fi
37
38 depend()
39 {
40 need localmount net
41 use dns
42 after bootmisc
43 }
44
45 start_pre()
46 {
47 # Linux has good dynamic tun/tap creation
48 if [ "$RC_UNAME" = Linux ]; then
49 if [ ! -e /dev/net/tun ]; then
50 if ! modprobe tun; then
51 eerror "TUN/TAP support is not available in this kernel"
52 return 1
53 fi
54 fi
55 if [ -h /dev/net/tun -a -c /dev/misc/net/tun ]; then
56 ebegin "Detected broken /dev/net/tun symlink, fixing..."
57 rm -f /dev/net/tun
58 ln -s /dev/misc/net/tun /dev/net/tun
59 eend $?
60 fi
61 else
62 if command -v kldload >/dev/null 2>&1; then
63 # Hammer the modules home by default
64 sysctl -a | grep -q '\.tun\.' || kldload if_tun
65 sysctl -a | grep -q '\.tap\.' || kldload if_tap
66 fi
67 fi
68
69 # If the config file does not specify the cd option, we do
70 if ! grep -q "^[ \t]*cd[ \t].*" "$openvpn_config"; then
71 command_args="$command_args --cd $openvpn_dir"
72 fi
73 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=@PKG_PREFIX@/sbin/polkitd
12 pidfile=@VARBASE@/run/polkitd/polkitd.pid
13 command_args="$polkitd_args"
14 name="PolicyKit Daemon"
15
16 depend()
17 {
18 need dbus
19 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=/usr/sbin/sshd
12 command_args=$sshd_args
13 pidfile=@VARBASE@/run/sshd.pid
14 required_files=/etc/ssh/sshd_config
15
16 depend()
17 {
18 use logger dns
19 need net
20 }
21
22 start_pre()
23 {
24 if [ ! -e /etc/ssh/ssh_host_key ]; then
25 ebegin "Generating Hostkey"
26 ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N ''
27 eend $? || return 1
28 fi
29 if [ ! -e /etc/ssh/ssh_host_dsa_key ]; then
30 ebegin "Generating DSA Hostkey"
31 ssh-keygen -d -f /etc/ssh/ssh_host_dsa_key -N ''
32 eend $? || return 1
33 fi
34 if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then
35 ebegin "Generating RSA Hostkey"
36 ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
37 eend $? || return 1
38 fi
39
40 $command -t
41 }
0 #!@SBINDIR@/openrc-run
1 # Copyright (c) 2007-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 command=/usr/sbin/wpa_supplicant
12 : ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf}
13 wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if
14 command_args="$wpa_supplicant_args -B -c$wpa_supplicant_conf $wpa_supplicant_if"
15 name="WPA Supplicant Daemon"
16
17 depend()
18 {
19 need localmount
20 use logger
21 after bootmisc modules
22 before dns dhcpcd net
23 keyword -shutdown
24 }
25
26 find_wireless()
27 {
28 local iface=
29
30 case "$RC_UNAME" in
31 Linux)
32 for iface in /sys/class/net/*; do
33 if [ -e "$iface"/wireless -o \
34 -e "$iface"/phy80211 ]
35 then
36 echo "${iface##*/}"
37 return 0
38 fi
39 done
40 ;;
41 FreeBSD)
42 for iface in $(sysctl -b net.wlan.devices 2>/dev/null); do
43 echo "${iface##*/}"
44 done
45 ;;
46 *)
47 for iface in /dev/net/* $(ifconfig -l 2>/dev/null); do
48 if ifconfig "${iface##*/}" 2>/dev/null | \
49 grep -q "[ ]*ssid "
50 then
51 echo "${iface##*/}"
52 return 0
53 fi
54 done
55 ;;
56 esac
57
58 return 1
59 }
60
61 append_wireless()
62 {
63 local iface= i=
64
65 iface=$(find_wireless)
66 if [ -n "$iface" ]; then
67 for i in $iface; do
68 command_args="$command_args -i$i"
69 done
70 else
71 eerror "Could not find a wireless interface"
72 fi
73 }
74
75 start_pre()
76 {
77 case " $command_args" in
78 *" -i"*) ;;
79 *) append_wireless;;
80 esac
81 }
0 MK= ../../mk
1 include ${MK}/os.mk
2
3 DIR= ${DATADIR}/support/openvpn
4 BIN= down.sh up.sh
5 INC= README.md
6
7
8 include ${MK}/scripts.mk
+0
-8
support/openvpn/README less more
0 These handy scripts setup any dns information that OpenVPN may push.
1 They also handle the interaction with OpenRC so that the OpenVPN service
2 can become "inactive". This means that when it starts, it goes inactive and
3 OpenRC continues on its merry way booting the system. When OpenVPN connects
4 to an endpoint it then re-starts the OpenVPN service and starts up any
5 services that depend on us. A similar thing happens when we shut down.
6
7 Of course, this is all optional.
0 These handy scripts setup any dns information that OpenVPN may push.
1 They also handle the interaction with OpenRC so that the OpenVPN service
2 can become "inactive". This means that when it starts, it goes inactive and
3 OpenRC continues on its merry way booting the system. When OpenVPN connects
4 to an endpoint it then re-starts the OpenVPN service and starts up any
5 services that depend on us. A similar thing happens when we shut down.
6
7 Of course, this is all optional.
0 MK= ../../mk
1 include ${MK}/os.mk
2
3 DIR= ${DATADIR}/support/sysvinit
4 INC= inittab README.md
5
6
7 include ${MK}/scripts.mk
+0
-2
support/sysvinit/README less more
0 Here's a sample inittab for use with sysvinit for Linux based systems.
1 We don't install it by default as sysvinit packages normally own this file.
0 Here's a sample inittab for use with sysvinit for Linux based systems.
1 We don't install it by default as sysvinit packages normally own this file.
88 top_builddir=${top_builddir:-${top_srcdir}}
99 builddir=${builddir:-${srcdir}}
1010
11 LD_LIBRARY_PATH=${top_builddir}/src/libeinfo:${top_builddir}/src/librc:${LD_LIBRARY_PATH}
12 PATH=${top_builddir}/src/rc:${PATH}
13 export LD_LIBRARY_PATH PATH
14
1115 if [ ! -f ${top_srcdir}/sh/functions.sh ] ; then
1216 echo "functions.sh not yet created !?" 1>&2
1317 exit 1
1620 exit 1
1721 fi
1822
19 LD_LIBRARY_PATH=${top_builddir}/src/libeinfo:${top_builddir}/src/librc:${LD_LIBRARY_PATH}
20 PATH=${top_builddir}/src/rc:${PATH}
21 export LD_LIBRARY_PATH PATH
22