Skip to content

Commit 3e25297

Browse files
committed
doc: major overhaul of distro recs, simplify & clarify
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 6560968 commit 3e25297

File tree

1 file changed

+105
-46
lines changed

1 file changed

+105
-46
lines changed

doc/distro.md

Lines changed: 105 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,139 @@
11
Distro Recommendations
22
======================
33

4-
By default Finit uses the following directories for configuration files:
4+
Finit supports two directory layouts for managing service configurations:
5+
6+
1. **Simple layout** - all configuration files directly in `/etc/finit.d/`
7+
2. **Distro layout** - separate `available/` and `enabled/` directories
8+
9+
The distro layout is recommended for distributions that need clear
10+
separation between installed and enabled services, and want to use the
11+
`initctl enable/disable` commands for service management.
12+
13+
## Simple Layout
14+
15+
Finit supports using a flat directory structure:
516

617
```
718
/etc/
8-
|-- finit.d/ -- Regular (enabled) services
19+
|-- finit.d/ -- All enabled services
920
| |-- lighttpd.conf
1021
| `- *.conf
1122
|-- finit.conf -- Bootstrap tasks and services
1223
:
1324
```
1425

15-
To enable a service one simply drops a small configuration file in the
16-
`/etc/finit.d/` directory. This practice works with systems that
17-
keep disabled services elsewhere, or generates them as needed from some
18-
other tool.
19-
20-
Distributions, however, may want a clearer separation of enabled and
21-
available (installed but not enabled) services. They may even want to
22-
customize the directories used, for brand labeling or uniformity.
26+
In this layout, you enable a service by placing its `.conf` file in
27+
`/etc/finit.d/` and disable it by removing the file. This works well for
28+
embedded systems or custom setups where services are managed by other tools
29+
or generated dynamically.
2330

24-
To that end Finit allows for a sub-directory `/etc/finit.d/available/`
25-
where installed but disabled services can reside. Adding a symlink to a
26-
configuration in this sub-directory enables the service, but it will not
27-
be started.
28-
29-
To change the default configuration directory and configuration file
30-
names the Finit `configure` script offers the following two options at
31-
build time:
32-
33-
```sh
34-
./configure --with-rcsd=/etc/init.d --with-config=/etc/init.d/init.conf
35-
```
31+
> [!NOTE] No tooling support
32+
> The `initctl enable/disable` commands **do not work** with this layout.
33+
> You must manually manage files in `/etc/finit.d/`.
3634
37-
> [!IMPORTANT]
38-
> Remember `--prefix` et al as well, the default is likely *not* what
39-
> you want. See the [build docs][1] for details.
35+
## Distro Layout
4036

41-
The resulting directory structure is depicted below. Please notice how
42-
`/etc/finit.conf` now resides in the same sub-directory as a non-symlink
43-
`/etc/init.d/init.conf`:
37+
Distributions typically want clearer separation between available (installed)
38+
and enabled services. Finit supports this through the `available/` and
39+
`enabled/` subdirectories:
4440

4541
```
4642
/etc/
47-
|-- init.d/
48-
| |-- available/ -- Regular (disabled) services
43+
|-- finit.d/
44+
| |-- available/ -- Installed but disabled services
4945
| | |-- httpd.conf
5046
| | |-- ntpd.conf
5147
| | `-- sshd.conf
52-
| |-- sshd.conf -- Symlink to available/sshd.conf
53-
| `- init.conf -- Bootstrap tasks and services
48+
| |-- enabled/ -- Enabled services (symlinks)
49+
| | `- sshd.conf -- Symlink to ../available/sshd.conf
50+
|-- finit.conf -- Bootstrap tasks and services
5451
:
5552
```
5653

57-
To facilitate the task of managing configurations, be it a service,
58-
task, run, or other stanza, the `initctl` tool has a a few built-in
59-
commands:
54+
In this layout:
55+
- **available/** contains all installed service configurations
56+
- **enabled/** contains symlinks to configurations that should start at boot
57+
- Services are enabled/disabled by creating/removing symlinks
58+
59+
> [!IMPORTANT] Recommended
60+
> This is the recommended layout. In fact, the `initctl enable/disable`
61+
> commands **require** this layout with both `available/` and `enabled/`
62+
> directories and will not work without it.
63+
64+
## Managing Services with initctl
65+
66+
When using the distro layout, the `initctl` tool provides convenient commands
67+
for managing service configurations:
6068

6169
```
6270
list List all .conf in /etc/finit.d/
63-
enable <CONF> Enable .conf in /etc/finit.d/available/
64-
disable <CONF> Disable .conf in /etc/finit.d/[enabled/]
65-
reload Reload *.conf in /etc/finit.d/ (activates changes)
71+
enable <CONF> Enable .conf by creating symlink in enabled/
72+
disable <CONF> Disable .conf by removing symlink from enabled/
73+
reload Reload *.conf in /etc/finit.d/ (activate changes)
74+
```
75+
76+
Example usage:
77+
78+
```bash
79+
# Enable sshd (creates enabled/sshd.conf -> ../available/sshd.conf)
80+
initctl enable sshd
81+
82+
# Disable httpd (removes enabled/httpd.conf symlink)
83+
initctl disable httpd
84+
85+
# Apply changes (reload configuration and start/stop services)
86+
initctl reload
6687
```
6788

68-
To enable a service like `sshd.conf`, above, use
89+
The `.conf` suffix is optional - `initctl` adds it automatically if missing.
6990

70-
initctl enable sshd
91+
> [!NOTE] Remember `initctl reload`
92+
> Changes made with `enable`/`disable` take effect only after running
93+
> `initctl reload`, unless Finit was built with `--enable-auto-reload`
94+
> which automatically detects and applies configuration changes.
7195
72-
The `.conf` suffix is not needed, `initctl` adds it implicitly if it is
73-
missing. The `disable` command works in a similar fashion.
96+
### Service Overrides
97+
98+
The `initctl` tool only operates on symlinks in the `enabled/` directory.
99+
If you place a regular (non-symlink) `.conf` file directly in the parent
100+
directory (e.g., `/etc/finit.d/`), `initctl` will ignore it. This allows
101+
you to create system-level overrides that cannot be accidentally disabled
102+
by package management tools.
103+
104+
## Customizing Directory Paths
105+
106+
Distributions can customize the directory names and locations at build time
107+
using the Finit `configure` script:
108+
109+
```sh
110+
./configure --with-rcsd=/etc/init.d --with-config=/etc/init.d/init.conf
111+
```
112+
113+
This changes the default `/etc/finit.d/` to `/etc/init.d/` and moves the
114+
bootstrap configuration file accordingly.
115+
116+
> [!IMPORTANT] Remember to set `--prefix`
117+
> Remember to set `--prefix` and related options appropriately. The default
118+
> prefix is `/usr/local`, which is likely not what you want for a system
119+
> init. See the [build documentation][1] for details.
120+
121+
Example with custom paths:
122+
123+
```
124+
/etc/
125+
|-- init.d/
126+
| |-- available/ -- Installed services
127+
| | |-- httpd.conf
128+
| | |-- ntpd.conf
129+
| | `-- sshd.conf
130+
| |-- enabled/ -- Enabled services (symlinks)
131+
| | `- sshd.conf -- Symlink to ../available/sshd.conf
132+
| `- init.conf -- Bootstrap tasks and services
133+
:
134+
```
74135

75-
Note, however, that `initctl` only operates on symlinks and it always
76-
requires the `available/` sub-directory. Any non-symlink in the parent
77-
directory, here `/etc/init.d/`, will be considered a system override by
78-
`initctl`.
136+
Notice how both the service directory and bootstrap configuration file now
137+
use the custom `/etc/init.d/` path specified at build time.
79138

80139
[1]: build.md#configure

0 commit comments

Comments
 (0)