]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.preset.xml
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / man / systemd.preset.xml
1 <?xml version="1.0"?>
2 <!--*-nxml-*-->
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!--
5 SPDX-License-Identifier: LGPL-2.1+
6 -->
7 <refentry id="systemd.preset">
8
9 <refentryinfo>
10 <title>systemd.preset</title>
11 <productname>systemd</productname>
12
13 <authorgroup>
14 <author>
15 <contrib>Developer</contrib>
16 <firstname>Lennart</firstname>
17 <surname>Poettering</surname>
18 <email>lennart@poettering.net</email>
19 </author>
20 </authorgroup>
21 </refentryinfo>
22
23 <refmeta>
24 <refentrytitle>systemd.preset</refentrytitle>
25 <manvolnum>5</manvolnum>
26 </refmeta>
27
28 <refnamediv>
29 <refname>systemd.preset</refname>
30 <refpurpose>Service enablement presets</refpurpose>
31 </refnamediv>
32
33 <refsynopsisdiv>
34 <para><filename>/etc/systemd/system-preset/*.preset</filename></para>
35 <para><filename>/run/systemd/system-preset/*.preset</filename></para>
36 <para><filename>/usr/lib/systemd/system-preset/*.preset</filename></para>
37 <para><filename>/etc/systemd/user-preset/*.preset</filename></para>
38 <para><filename>/run/systemd/user-preset/*.preset</filename></para>
39 <para><filename>/usr/lib/systemd/user-preset/*.preset</filename></para>
40 </refsynopsisdiv>
41
42 <refsect1>
43 <title>Description</title>
44
45 <para>Preset files may be used to encode policy which units shall
46 be enabled by default and which ones shall be disabled. They are
47 read by <command>systemctl preset</command> (for more information
48 see
49 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
50 which uses this information to enable or disable a unit according
51 to preset policy. <command>systemctl preset</command> is used by
52 the post install scriptlets of RPM packages (or other OS package
53 formats), to enable/disable specific units by default on package
54 installation, enforcing distribution, spin or administrator preset
55 policy. This allows choosing a certain set of units to be
56 enabled/disabled even before installing the actual package.</para>
57
58 <para>For more information on the preset logic please have a look
59 at the <ulink
60 url="https://www.freedesktop.org/wiki/Software/systemd/Preset">Presets</ulink>
61 document.</para>
62
63 <para>It is not recommended to ship preset files within the
64 respective software packages implementing the units, but rather
65 centralize them in a distribution or spin default policy, which
66 can be amended by administrator policy.</para>
67
68 <para>If no preset files exist, <command>systemctl
69 preset</command> will enable all units that are installed by
70 default. If this is not desired and all units shall rather be
71 disabled, it is necessary to ship a preset file with a single,
72 catchall "<filename>disable *</filename>" line. (See example 1,
73 below.)</para>
74 </refsect1>
75
76 <refsect1>
77 <title>Preset File Format</title>
78
79 <para>The preset files contain a list of directives consisting of
80 either the word <literal>enable</literal> or
81 <literal>disable</literal> followed by a space and a unit name
82 (possibly with shell style wildcards), separated by newlines.
83 Empty lines and lines whose first non-whitespace character is # or
84 ; are ignored.</para>
85
86 <para>Presets must refer to the "real" unit file, and not to any aliases. See
87 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
88 for a description of unit aliasing.</para>
89
90 <para>Two different directives are understood:
91 <literal>enable</literal> may be used to enable units by default,
92 <literal>disable</literal> to disable units by default.</para>
93
94 <para>If multiple lines apply to a unit name, the first matching
95 one takes precedence over all others.</para>
96
97 <para>Each preset file shall be named in the style of
98 <filename>&lt;priority&gt;-&lt;policy-name&gt;.preset</filename>. Files
99 in <filename>/etc/</filename> override files with the same name in
100 <filename>/usr/lib/</filename> and <filename>/run/</filename>.
101 Files in <filename>/run/</filename> override files with the same
102 name in <filename>/usr/lib/</filename>. Packages should install
103 their preset files in <filename>/usr/lib/</filename>. Files in
104 <filename>/etc/</filename> are reserved for the local
105 administrator, who may use this logic to override the preset files
106 installed by vendor packages. All preset files are sorted by their
107 filename in lexicographic order, regardless of which of the
108 directories they reside in. If multiple files specify the same
109 unit name, the entry in the file with the lexicographically
110 earliest name will be applied. It is recommended to prefix all
111 filenames with a two-digit number and a dash, to simplify the
112 ordering of the files.</para>
113
114 <para>If the administrator wants to disable a preset file supplied
115 by the vendor, the recommended way is to place a symlink to
116 <filename>/dev/null</filename> in
117 <filename>/etc/systemd/system-preset/</filename> bearing the same
118 filename.</para>
119 </refsect1>
120
121 <refsect1>
122 <title>Examples</title>
123
124 <example>
125 <title>Default to off</title>
126
127 <programlisting># /usr/lib/systemd/system-preset/99-default.preset
128
129 disable *</programlisting>
130 </example>
131
132 <para>This disables all units. Due to the filename prefix
133 <literal>99-</literal>, it will be read last and hence can easily
134 be overridden by spin or administrator preset policy.</para>
135
136 <example>
137 <title>A GNOME spin</title>
138
139 <programlisting># /usr/lib/systemd/system-preset/50-gnome.preset
140
141 enable gdm.service
142 enable colord.service
143 enable accounts-daemon.service
144 enable avahi-daemon.*</programlisting>
145
146 </example>
147
148 <para>This enables the three mentioned units, plus all
149 <filename>avahi-daemon</filename> regardless of which unit type. A
150 file like this could be useful for inclusion in a GNOME spin of a
151 distribution. It will ensure that the units necessary for GNOME
152 are properly enabled as they are installed. It leaves all other
153 units untouched, and subject to other (later) preset files, for
154 example like the one from the first example above.</para>
155
156 <example>
157 <title>Administrator policy</title>
158
159 <programlisting># /etc/systemd/system-preset/00-lennart.preset
160
161 enable httpd.service
162 enable sshd.service
163 enable postfix.service
164 disable *</programlisting>
165 </example>
166
167 <para>This enables three specific services and disables all
168 others. This is useful for administrators to specifically select
169 the units to enable, and disable all others. Due to the filename
170 prefix <literal>00-</literal> it will be read early and
171 override all other preset policy files.</para>
172 </refsect1>
173
174 <refsect1>
175 <title>See Also</title>
176 <para>
177 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
178 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
179 <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>
180 </para>
181 </refsect1>
182
183 </refentry>