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