Debian Codegraph @

doc/config/sysv.md

raw symbols SCIP
1 SysV Init Compatibility
2 =======================
3
4 It is not possible to run unmodified SysV init systems with Finit. This
5 was never the intention and is not the strength of Finit. However, it
6 comes with a few SysV Init compatibility features to ease the transition
7 from a serialized boot process.
8
9 SysV Init Scripts
10 -----------------
11
12 **Syntax:** `sysv [LVLS] <COND> /path/to/init-script -- Optional description`
13
14 > `<COND>` is described in the [Services](services.md) section.
15
16 Similar to `task` is the `sysv` stanza, which can be used to call SysV
17 style scripts. The primary intention for this command is to be able to
18 reuse much of existing setup and init scripts in Linux distributions.
19
20 When entering an allowed runlevel, Finit calls `init-script start`, when
21 entering a disallowed runlevel, Finit calls `init-script stop`, and if
22 the Finit .conf, where `sysv` stanza is declared, is modified, Finit
23 calls `init-script restart` on `initctl reload`. Similar to how
24 `service` stanzas work.
25
26 Forking services started with `sysv` scripts can be monitored by Finit
27 by declaring the PID file to look for: `pid:!/path/to/pidfile.pid`.
28 Notice the leading `!`, it signifies Finit should not try to create the
29 file, but rather watch that file for the resulting forked-off PID. This
30 syntax also works for forking daemons that do not have a command line
31 option to run it in the foreground, more on this below in `service`.
32
33 > [!TIP]
34 > See also [SysV Init Compatibility](#sysv-init-compatibility).
35
36 `runparts DIRECTORY`
37 --------------------
38
39 For a directory with traditional start/stop scripts that should run, in
40 order, at bootstrap, Finit provides the `runparts` directive. It runs
41 in runlevel S, at the very end of it (before calling `/etc/rc.local`)
42 making it perfect for most scenarios.
43
44 For syntax details, see the [Run-parts Scripts](runparts.md) section.
45 Here is an example take from a Debian installation:
46
47 runparts /etc/rc2.d
48
49 Files in these directories are usually named `SNNfoo` and `KNNfoo`,
50 which Finit knows about and automatically appends the correct argument:
51
52 /bin/sh -c /etc/rc2.d/S01openbsd-inetd start
53
54 or
55
56 /bin/sh -c /etc/rc0.d/K01openbsd-inetd stop
57
58 Files that do not match this pattern are started similarly but without
59 the extra command line argument.
60
61 Start/Stop Scripts
62 ------------------
63
64 For syntax details, see [SysV Init Scripts](#sysv-init-scripts), above.
65 Here follows an example taken from a Debian installation:
66
67 sysv [2345] <pid/syslogd> /etc/init.d/openbsd-inetd -- OpenBSD inet daemon
68
69 The init script header could be parsed to extract `Default-Start:` and
70 other parameters for the `sysv` command to Finit. There is currently no
71 way to detail a generic syslogd dependency in Finit, so `Should-Start:`
72 in the header must be mapped to the condition system in Finit using an
73 absolute reference, here we depend on the sysklogd project's syslogd.
74
75 `/etc/rc.local`
76 ---------------
77
78 One often requested feature, early on, was a way to run a site specific
79 script to set up, e.g., static routes or firewall rules. A user can add
80 a `task` or `run` command in the Finit configuration for this, but for
81 compatibility reasons the more widely know `/etc/rc.local` is used if
82 it exists, and is executable. It is called very late in the boot process
83 when the system has left runlevel S, stopped all old and started all new
84 services in the target runlevel (default 2).
85
86 > In Finit releases before v4.5 this script blocked Finit execution and
87 > made it as good as impossible to call `initctl` during that time.
88
89 `init q`
90 --------
91
92 When `/sbin/finit` is installed as `/sbin/init`, it is possible to use
93 `init q` to reload the configuration. This is the same as calling
94 `initctl reload`.