| 1 |
'\" t |
| 2 |
.TH "SYSTEMD\&.PRESET" "5" "" "systemd 261~rc3" "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 |
.RS 4 |
| 51 |
/etc/systemd/initrd\-preset/*\&.preset |
| 52 |
.RE |
| 53 |
.RS 4 |
| 54 |
/run/systemd/initrd\-preset/*\&.preset |
| 55 |
.RE |
| 56 |
.RS 4 |
| 57 |
/usr/local/lib/systemd/initrd\-preset/*\&.preset |
| 58 |
.RE |
| 59 |
.RS 4 |
| 60 |
/usr/lib/systemd/initrd\-preset/*\&.preset |
| 61 |
.RE |
| 62 |
.SH "DESCRIPTION" |
| 63 |
.PP |
| 64 |
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 |
| 65 |
\fBsystemctl preset\fR |
| 66 |
which uses this information to enable or disable a unit\&. Depending on that policy, |
| 67 |
\fBsystemctl preset\fR |
| 68 |
is identical to |
| 69 |
\fBsystemctl enable\fR |
| 70 |
or |
| 71 |
\fBsystemctl disable\fR\&. |
| 72 |
\fBsystemctl preset\fR |
| 73 |
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 |
| 74 |
\fBsystemctl\fR(1)\&. |
| 75 |
.PP |
| 76 |
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\&. |
| 77 |
.PP |
| 78 |
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\&.) |
| 79 |
.PP |
| 80 |
When the machine is booted for the first time, |
| 81 |
\fBsystemd\fR(1) |
| 82 |
will enable/disable all units according to preset policy, similarly to |
| 83 |
\fBsystemctl preset\-all\fR\&. Also see |
| 84 |
\fIConditionFirstBoot=\fR |
| 85 |
in |
| 86 |
\fBsystemd.unit\fR(5) |
| 87 |
and "First Boot Semantics" in |
| 88 |
\fBmachine-id\fR(5)\&. |
| 89 |
.SH "PRESET FILE FORMAT" |
| 90 |
.PP |
| 91 |
The preset files contain a list of directives, one per line\&. Empty lines and lines whose first non\-whitespace character is |
| 92 |
"#" |
| 93 |
or |
| 94 |
";" |
| 95 |
are ignored\&. Each directive consists of one of the words |
| 96 |
"enable", |
| 97 |
"disable", or |
| 98 |
"ignore", followed by whitespace and a unit name\&. The unit name may contain shell\-style wildcards\&. |
| 99 |
.PP |
| 100 |
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\&. |
| 101 |
.PP |
| 102 |
Presets must refer to the "real" unit file, and not to any aliases\&. See |
| 103 |
\fBsystemd.unit\fR(5) |
| 104 |
for a description of unit aliasing\&. |
| 105 |
.PP |
| 106 |
Three different directives are understood: |
| 107 |
"enable" |
| 108 |
may be used to enable units by default, |
| 109 |
"disable" |
| 110 |
to disable units by default, and |
| 111 |
"ignore" |
| 112 |
to ignore units and leave existing configuration intact\&. |
| 113 |
.PP |
| 114 |
If multiple lines apply to a unit name, the first matching one takes precedence over all others\&. |
| 115 |
.PP |
| 116 |
Each preset file shall be named in the style of |
| 117 |
<priority>\-<policy\-name>\&.preset\&. Files in |
| 118 |
/etc/ |
| 119 |
override files with the same name in |
| 120 |
/usr/lib/ |
| 121 |
and |
| 122 |
/run/\&. Files in |
| 123 |
/run/ |
| 124 |
override files with the same name in |
| 125 |
/usr/lib/\&. Packages should install their preset files in |
| 126 |
/usr/lib/\&. Files in |
| 127 |
/etc/ |
| 128 |
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\&. |
| 129 |
.PP |
| 130 |
If the administrator wants to disable a preset file supplied by the vendor, the recommended way is to place a symlink to |
| 131 |
/dev/null |
| 132 |
in |
| 133 |
/etc/systemd/system\-preset/ |
| 134 |
bearing the same filename\&. |
| 135 |
.SH "EXAMPLES" |
| 136 |
.PP |
| 137 |
\fBExample\ \&1.\ \&Default to off\fR |
| 138 |
.sp |
| 139 |
.if n \{\ |
| 140 |
.RS 4 |
| 141 |
.\} |
| 142 |
.nf |
| 143 |
# /usr/lib/systemd/system\-preset/99\-default\&.preset |
| 144 |
|
| 145 |
disable * |
| 146 |
.fi |
| 147 |
.if n \{\ |
| 148 |
.RE |
| 149 |
.\} |
| 150 |
.PP |
| 151 |
This disables all units\&. Due to the filename prefix |
| 152 |
"99\-", it will be read last and hence can easily be overridden by spin or administrator preset policy\&. |
| 153 |
.PP |
| 154 |
\fBExample\ \&2.\ \&Enable multiple template instances\fR |
| 155 |
.sp |
| 156 |
.if n \{\ |
| 157 |
.RS 4 |
| 158 |
.\} |
| 159 |
.nf |
| 160 |
# /usr/lib/systemd/system\-preset/80\-dirsrv\&.preset |
| 161 |
|
| 162 |
enable dirsrv@\&.service foo bar baz |
| 163 |
.fi |
| 164 |
.if n \{\ |
| 165 |
.RE |
| 166 |
.\} |
| 167 |
.PP |
| 168 |
This enables all three of |
| 169 |
dirsrv@foo\&.service, |
| 170 |
dirsrv@bar\&.service |
| 171 |
and |
| 172 |
dirsrv@baz\&.service\&. |
| 173 |
.PP |
| 174 |
\fBExample\ \&3.\ \&A GNOME spin\fR |
| 175 |
.sp |
| 176 |
.if n \{\ |
| 177 |
.RS 4 |
| 178 |
.\} |
| 179 |
.nf |
| 180 |
# /usr/lib/systemd/system\-preset/50\-gnome\&.preset |
| 181 |
|
| 182 |
enable gdm\&.service |
| 183 |
enable colord\&.service |
| 184 |
enable accounts\-daemon\&.service |
| 185 |
enable avahi\-daemon\&.* |
| 186 |
.fi |
| 187 |
.if n \{\ |
| 188 |
.RE |
| 189 |
.\} |
| 190 |
.PP |
| 191 |
This enables the three mentioned units, plus all |
| 192 |
avahi\-daemon |
| 193 |
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\&. |
| 194 |
.PP |
| 195 |
\fBExample\ \&4.\ \&Administrator policy\fR |
| 196 |
.sp |
| 197 |
.if n \{\ |
| 198 |
.RS 4 |
| 199 |
.\} |
| 200 |
.nf |
| 201 |
# /etc/systemd/system\-preset/00\-lennart\&.preset |
| 202 |
|
| 203 |
enable httpd\&.service |
| 204 |
enable sshd\&.service |
| 205 |
enable postfix\&.service |
| 206 |
disable * |
| 207 |
.fi |
| 208 |
.if n \{\ |
| 209 |
.RE |
| 210 |
.\} |
| 211 |
.PP |
| 212 |
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 |
| 213 |
"00\-" |
| 214 |
it will be read early and override all other preset policy files\&. |
| 215 |
.SH "MOTIVATION FOR THE PRESET LOGIC" |
| 216 |
.PP |
| 217 |
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\&. |
| 218 |
.PP |
| 219 |
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 |
| 220 |
\fBgdm\fR |
| 221 |
as display manager by default, while the Fedora KDE spin will enable |
| 222 |
\fBsddm\fR |
| 223 |
instead\&. |
| 224 |
.PP |
| 225 |
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 |
| 226 |
should be always on, but everything else off", while another one might say "\fBsnmpd\fR |
| 227 |
always on, and for everything else use the distribution policy defaults"\&. |
| 228 |
.PP |
| 229 |
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\&. |
| 230 |
.PP |
| 231 |
The preset mechanism allows clean separation of the enablement mechanism (inside the package scriptlets, by invoking |
| 232 |
\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\&. |
| 233 |
.SH "SEE ALSO" |
| 234 |
.PP |
| 235 |
\fBsystemd\fR(1), \fBsystemctl\fR(1), \fBsystemd-delta\fR(1) |
| 236 |
.PP |
| 237 |
\fBdaemon\fR(7) |
| 238 |
has a discussion of packaging scriptlets\&. |
| 239 |
.PP |
| 240 |
Fedora page introducing the use of presets: |
| 241 |
\m[blue]\fBFeatures/PackagePresets\fR\m[]\&\s-2\u[1]\d\s+2\&. |
| 242 |
.SH "NOTES" |
| 243 |
.IP " 1." 4 |
| 244 |
Features/PackagePresets |
| 245 |
.RS 4 |
| 246 |
\%https://fedoraproject.org/wiki/Features/PackagePresets |
| 247 |
.RE |