]>
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> | |
1655cdee | 139 | <title>Examples</title> |
798d3a52 ZJS |
140 | |
141 | <example> | |
1655cdee | 142 | <title>Default to off</title> |
798d3a52 | 143 | |
1655cdee ZJS |
144 | <programlisting># /usr/lib/systemd/system-preset/99-default.preset |
145 | ||
146 | disable *</programlisting> | |
798d3a52 ZJS |
147 | </example> |
148 | ||
149 | <para>This disables all units. Due to the filename prefix | |
150 | <literal>99-</literal>, it will be read last and hence can easily | |
1655cdee | 151 | be overridden by spin or administrator preset policy.</para> |
798d3a52 ZJS |
152 | |
153 | <example> | |
1655cdee | 154 | <title>A GNOME spin</title> |
798d3a52 | 155 | |
1655cdee ZJS |
156 | <programlisting># /usr/lib/systemd/system-preset/50-gnome.preset |
157 | ||
158 | enable gdm.service | |
75d67e68 LP |
159 | enable colord.service |
160 | enable accounts-daemon.service | |
161 | enable avahi-daemon.*</programlisting> | |
162 | ||
798d3a52 | 163 | </example> |
75d67e68 | 164 | |
798d3a52 ZJS |
165 | <para>This enables the three mentioned units, plus all |
166 | <filename>avahi-daemon</filename> regardless of which unit type. A | |
167 | file like this could be useful for inclusion in a GNOME spin of a | |
168 | distribution. It will ensure that the units necessary for GNOME | |
169 | are properly enabled as they are installed. It leaves all other | |
170 | units untouched, and subject to other (later) preset files, for | |
171 | example like the one from the first example above.</para> | |
75d67e68 | 172 | |
798d3a52 | 173 | <example> |
1655cdee ZJS |
174 | <title>Administrator policy</title> |
175 | ||
176 | <programlisting># /etc/systemd/system-preset/00-lennart.preset | |
75d67e68 | 177 | |
1655cdee | 178 | enable httpd.service |
75d67e68 LP |
179 | enable sshd.service |
180 | enable postfix.service | |
181 | disable *</programlisting> | |
798d3a52 ZJS |
182 | </example> |
183 | ||
184 | <para>This enables three specific services and disables all | |
185 | others. This is useful for administrators to specifically select | |
186 | the units to enable, and disable all others. Due to the filename | |
1655cdee ZJS |
187 | prefix <literal>00-</literal> it will be read early and |
188 | override all other preset policy files.</para> | |
798d3a52 ZJS |
189 | </refsect1> |
190 | ||
191 | <refsect1> | |
192 | <title>See Also</title> | |
193 | <para> | |
194 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
195 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
196 | <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
197 | </para> | |
198 | </refsect1> | |
75d67e68 LP |
199 | |
200 | </refentry> |