summaryrefslogtreecommitdiffstats
path: root/upstream/opensuse-leap-15-6/man5/systemd.preset.5
blob: 9e9a24e433bd1dc505ec6629651fe277e7dd7bd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
'\" t
.TH "SYSTEMD\&.PRESET" "5" "" "systemd 254" "systemd.preset"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
systemd.preset \- Service enablement presets
.SH "SYNOPSIS"
.PP
/etc/systemd/system\-preset/*\&.preset
.PP
/run/systemd/system\-preset/*\&.preset
.PP
/usr/lib/systemd/system\-preset/*\&.preset
.PP
/etc/systemd/user\-preset/*\&.preset
.PP
/run/systemd/user\-preset/*\&.preset
.PP
/usr/lib/systemd/user\-preset/*\&.preset
.SH "DESCRIPTION"
.PP
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
\fBsystemctl preset\fR
which uses this information to enable or disable a unit\&. Depending on that policy,
\fBsystemctl preset\fR
is identical to
\fBsystemctl enable\fR
or
\fBsystemctl disable\fR\&.
\fBsystemctl preset\fR
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
\fBsystemctl\fR(1)\&.
.PP
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\&.
.PP
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\&.)
.PP
When the machine is booted for the first time,
\fBsystemd\fR(1)
will enable/disable all units according to preset policy, similarly to
\fBsystemctl preset\-all\fR\&. Also see "First Boot Semantics" in
\fBmachine-id\fR(5)\&.
.SH "PRESET FILE FORMAT"
.PP
The preset files contain a list of directives, one per line\&. Empty lines and lines whose first non\-whitespace character is
"#"
or
";"
are ignored\&. Each directive consists of one of the words
"enable",
"disable", or
"ignore", followed by whitespace and a unit name\&. The unit name may contain shell\-style wildcards\&.
.PP
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\&.
.PP
Presets must refer to the "real" unit file, and not to any aliases\&. See
\fBsystemd.unit\fR(5)
for a description of unit aliasing\&.
.PP
Three different directives are understood:
"enable"
may be used to enable units by default,
"disable"
to disable units by default, and
"ignore"
to ignore units and leave existing configuration intact\&.
.PP
If multiple lines apply to a unit name, the first matching one takes precedence over all others\&.
.PP
Each preset file shall be named in the style of
<priority>\-<policy\-name>\&.preset\&. Files in
/etc/
override files with the same name in
/usr/lib/
and
/run/\&. Files in
/run/
override files with the same name in
/usr/lib/\&. Packages should install their preset files in
/usr/lib/\&. Files in
/etc/
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\&.
.PP
If the administrator wants to disable a preset file supplied by the vendor, the recommended way is to place a symlink to
/dev/null
in
/etc/systemd/system\-preset/
bearing the same filename\&.
.SH "EXAMPLES"
.PP
\fBExample\ \&1.\ \&Default to off\fR
.sp
.if n \{\
.RS 4
.\}
.nf
# /usr/lib/systemd/system\-preset/99\-default\&.preset

disable *
.fi
.if n \{\
.RE
.\}
.PP
This disables all units\&. Due to the filename prefix
"99\-", it will be read last and hence can easily be overridden by spin or administrator preset policy\&.
.PP
\fBExample\ \&2.\ \&Enable multiple template instances\fR
.sp
.if n \{\
.RS 4
.\}
.nf
# /usr/lib/systemd/system\-preset/80\-dirsrv\&.preset

enable dirsrv@\&.service foo bar baz
.fi
.if n \{\
.RE
.\}
.PP
This enables all three of
dirsrv@foo\&.service,
dirsrv@bar\&.service
and
dirsrv@baz\&.service\&.
.PP
\fBExample\ \&3.\ \&A GNOME spin\fR
.sp
.if n \{\
.RS 4
.\}
.nf
# /usr/lib/systemd/system\-preset/50\-gnome\&.preset

enable gdm\&.service
enable colord\&.service
enable accounts\-daemon\&.service
enable avahi\-daemon\&.*
.fi
.if n \{\
.RE
.\}
.PP
This enables the three mentioned units, plus all
avahi\-daemon
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\&.
.PP
\fBExample\ \&4.\ \&Administrator policy\fR
.sp
.if n \{\
.RS 4
.\}
.nf
# /etc/systemd/system\-preset/00\-lennart\&.preset

enable httpd\&.service
enable sshd\&.service
enable postfix\&.service
disable *
.fi
.if n \{\
.RE
.\}
.PP
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
"00\-"
it will be read early and override all other preset policy files\&.
.SH "MOTIVATION FOR THE PRESET LOGIC"
.PP
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\&.
.PP
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
\fBgdm\fR
as display manager by default, while the Fedora KDE spin will enable
\fBsddm\fR
instead\&.
.PP
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
should be always on, but everything else off", while another one might say "\fBsnmpd\fR
always on, and for everything else use the distribution policy defaults"\&.
.PP
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\&.
.PP
The preset mechanism allows clean separation of the enablement mechanism (inside the package scriptlets, by invoking
\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\&.
.SH "SEE ALSO"
.PP
\fBsystemd\fR(1),
\fBsystemctl\fR(1),
\fBsystemd-delta\fR(1)
.PP
\fBdaemon\fR(7)
has a discussion of packaging scriptlets\&.
.PP
Fedora page introducing the use of presets:
\m[blue]\fBFeatures/PackagePresets\fR\m[]\&\s-2\u[1]\d\s+2\&.
.SH "NOTES"
.IP " 1." 4
Features/PackagePresets
.RS 4
\%https://fedoraproject.org/wiki/Features/PackagePresets
.RE