Debian Codegraph @

upstream/debian-trixie/man5/systemd.preset.5

raw
1 '\" t
2 .TH "SYSTEMD\&.PRESET" "5" "" "systemd 257.13" "systemd.preset"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 systemd.preset \- Service enablement presets
24 .SH "SYNOPSIS"
25 .PP
26 .RS 4
27 /etc/systemd/system\-preset/*\&.preset
28 .RE
29 .RS 4
30 /run/systemd/system\-preset/*\&.preset
31 .RE
32 .RS 4
33 /usr/local/lib/systemd/system\-preset/*\&.preset
34 .RE
35 .RS 4
36 /usr/lib/systemd/system\-preset/*\&.preset
37 .RE
38 .RS 4
39 /etc/systemd/user\-preset/*\&.preset
40 .RE
41 .RS 4
42 /run/systemd/user\-preset/*\&.preset
43 .RE
44 .RS 4
45 /usr/local/lib/systemd/user\-preset/*\&.preset
46 .RE
47 .RS 4
48 /usr/lib/systemd/user\-preset/*\&.preset
49 .RE
50 .SH "DESCRIPTION"
51 .PP
52 Preset files may be used to encode policy which units shall be enabled by default and which ones shall be disabled\&. They are read by
53 \fBsystemctl preset\fR
54 which uses this information to enable or disable a unit\&. Depending on that policy,
55 \fBsystemctl preset\fR
56 is identical to
57 \fBsystemctl enable\fR
58 or
59 \fBsystemctl disable\fR\&.
60 \fBsystemctl preset\fR
61 is used by the post install scriptlets of rpm packages (or other OS package formats), to enable/disable specific units by default on package installation, enforcing distribution, spin, or administrator preset policy\&. This allows choosing a certain set of units to be enabled/disabled even before installing the actual package\&. For more information, see
62 \fBsystemctl\fR(1)\&.
63 .PP
64 It is not recommended to ship preset files within the respective software packages implementing the units, but rather centralize them in a distribution or spin default policy, which can be amended by administrator policy, see below\&.
65 .PP
66 If no preset files exist, preset operations will enable all units that are installed by default\&. If this is not desired and all units shall rather be disabled, it is necessary to ship a preset file with a single, catchall "disable *" line\&. (See example 1, below\&.)
67 .PP
68 When the machine is booted for the first time,
69 \fBsystemd\fR(1)
70 will enable/disable all units according to preset policy, similarly to
71 \fBsystemctl preset\-all\fR\&. Also see
72 \fIConditionFirstBoot=\fR
73 in
74 \fBsystemd.unit\fR(5)
75 and "First Boot Semantics" in
76 \fBmachine-id\fR(5)\&.
77 .SH "PRESET FILE FORMAT"
78 .PP
79 The preset files contain a list of directives, one per line\&. Empty lines and lines whose first non\-whitespace character is
80 "#"
81 or
82 ";"
83 are ignored\&. Each directive consists of one of the words
84 "enable",
85 "disable", or
86 "ignore", followed by whitespace and a unit name\&. The unit name may contain shell\-style wildcards\&.
87 .PP
88 For the enable directive for template units, one or more instance names may be specified as a space\-separated list after the unit name\&. In this case, those instances will be enabled instead of the instance specified via DefaultInstance= in the unit\&.
89 .PP
90 Presets must refer to the "real" unit file, and not to any aliases\&. See
91 \fBsystemd.unit\fR(5)
92 for a description of unit aliasing\&.
93 .PP
94 Three different directives are understood:
95 "enable"
96 may be used to enable units by default,
97 "disable"
98 to disable units by default, and
99 "ignore"
100 to ignore units and leave existing configuration intact\&.
101 .PP
102 If multiple lines apply to a unit name, the first matching one takes precedence over all others\&.
103 .PP
104 Each preset file shall be named in the style of
105 <priority>\-<policy\-name>\&.preset\&. Files in
106 /etc/
107 override files with the same name in
108 /usr/lib/
109 and
110 /run/\&. Files in
111 /run/
112 override files with the same name in
113 /usr/lib/\&. Packages should install their preset files in
114 /usr/lib/\&. Files in
115 /etc/
116 are reserved for the local administrator, who may use this logic to override the preset files installed by vendor packages\&. All preset files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in\&. If multiple files specify the same unit name, the entry in the file with the lexicographically earliest name will be applied\&. It is recommended to prefix all filenames with a two\-digit number and a dash, to simplify the ordering of the files\&.
117 .PP
118 If the administrator wants to disable a preset file supplied by the vendor, the recommended way is to place a symlink to
119 /dev/null
120 in
121 /etc/systemd/system\-preset/
122 bearing the same filename\&.
123 .SH "EXAMPLES"
124 .PP
125 \fBExample\ \&1.\ \&Default to off\fR
126 .sp
127 .if n \{\
128 .RS 4
129 .\}
130 .nf
131 # /usr/lib/systemd/system\-preset/99\-default\&.preset
132
133 disable *
134 .fi
135 .if n \{\
136 .RE
137 .\}
138 .PP
139 This disables all units\&. Due to the filename prefix
140 "99\-", it will be read last and hence can easily be overridden by spin or administrator preset policy\&.
141 .PP
142 \fBExample\ \&2.\ \&Enable multiple template instances\fR
143 .sp
144 .if n \{\
145 .RS 4
146 .\}
147 .nf
148 # /usr/lib/systemd/system\-preset/80\-dirsrv\&.preset
149
150 enable dirsrv@\&.service foo bar baz
151 .fi
152 .if n \{\
153 .RE
154 .\}
155 .PP
156 This enables all three of
157 dirsrv@foo\&.service,
158 dirsrv@bar\&.service
159 and
160 dirsrv@baz\&.service\&.
161 .PP
162 \fBExample\ \&3.\ \&A GNOME spin\fR
163 .sp
164 .if n \{\
165 .RS 4
166 .\}
167 .nf
168 # /usr/lib/systemd/system\-preset/50\-gnome\&.preset
169
170 enable gdm\&.service
171 enable colord\&.service
172 enable accounts\-daemon\&.service
173 enable avahi\-daemon\&.*
174 .fi
175 .if n \{\
176 .RE
177 .\}
178 .PP
179 This enables the three mentioned units, plus all
180 avahi\-daemon
181 regardless of which unit type\&. A file like this could be useful for inclusion in a GNOME spin of a distribution\&. It will ensure that the units necessary for GNOME are properly enabled as they are installed\&. It leaves all other units untouched, and subject to other (later) preset files, for example like the one from the first example above\&.
182 .PP
183 \fBExample\ \&4.\ \&Administrator policy\fR
184 .sp
185 .if n \{\
186 .RS 4
187 .\}
188 .nf
189 # /etc/systemd/system\-preset/00\-lennart\&.preset
190
191 enable httpd\&.service
192 enable sshd\&.service
193 enable postfix\&.service
194 disable *
195 .fi
196 .if n \{\
197 .RE
198 .\}
199 .PP
200 This enables three specific services and disables all others\&. This is useful for administrators to specifically select the units to enable, and disable all others\&. Due to the filename prefix
201 "00\-"
202 it will be read early and override all other preset policy files\&.
203 .SH "MOTIVATION FOR THE PRESET LOGIC"
204 .PP
205 Different distributions have different policies on which services shall be enabled by default when the package they are shipped in is installed\&. On Fedora all services stay off by default, so that installing a package will not cause a service to be enabled (with some exceptions)\&. On Debian all services are immediately enabled by default, so that installing a package will cause its services to be enabled right\-away\&.
206 .PP
207 Even within a single distribution, different spins (flavours, remixes, whatever you might want to call them) of a distribution also have different policies on what services to enable, and what services to leave off\&. For example, Fedora Workstation will enable
208 \fBgdm\fR
209 as display manager by default, while the Fedora KDE spin will enable
210 \fBsddm\fR
211 instead\&.
212 .PP
213 Different sites might also have different policies what to turn on by default and what to turn off\&. For example, one administrator would prefer to enforce the policy of "\fBsshd\fR
214 should be always on, but everything else off", while another one might say "\fBsnmpd\fR
215 always on, and for everything else use the distribution policy defaults"\&.
216 .PP
217 Traditionally, policy about which services shall be enabled were implemented in each package individually\&. This made it cumbersome to implement different policies per spin or per site, or to create software packages that do the right thing on more than one distribution\&. The enablement mechanism was also encoding the enablement policy\&.
218 .PP
219 The preset mechanism allows clean separation of the enablement mechanism (inside the package scriptlets, by invoking
220 \fBsystemctl preset\fR) and enablement policy (centralized in the preset files), and lifts the configuration out of individual packages\&. Preset files may be written for specific distributions, for specific spins or for specific sites, in order to enforce different policies as needed\&. It is recommended to apply the policy encoded in preset files in package installation scriptlets\&.
221 .SH "SEE ALSO"
222 .PP
223 \fBsystemd\fR(1), \fBsystemctl\fR(1), \fBsystemd-delta\fR(1)
224 .PP
225 \fBdaemon\fR(7)
226 has a discussion of packaging scriptlets\&.
227 .PP
228 Fedora page introducing the use of presets:
229 \m[blue]\fBFeatures/PackagePresets\fR\m[]\&\s-2\u[1]\d\s+2\&.
230 .SH "NOTES"
231 .IP " 1." 4
232 Features/PackagePresets
233 .RS 4
234 \%https://fedoraproject.org/wiki/Features/PackagePresets
235 .RE