From 2e93770fd86576d1ad46d2cff7e11b2f4d90e3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 9 Jan 2020 12:38:18 +0100 Subject: [PATCH] man: document alias rules and aliases dropin loading --- man/systemd.unit.xml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index 42508f3059..ca2030dc84 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -136,11 +136,25 @@ has the alias dbus-org.freedesktop.network1.service, created during installation as a symlink, so when systemd is asked through D-Bus to load dbus-org.freedesktop.network1.service, it'll load - systemd-networkd.service. Alias names may be used in commands like - disable, start, stop, status, - and similar, and in all unit dependency directives, including Wants=, - Requires=, Before=, After=. Aliases cannot be - used with the preset command. + systemd-networkd.service. As another example, default.target — + the default system target started at boot — is commonly symlinked (aliased) to either + multi-user.target or graphical.target to select what is started + by default. Alias names may be used in commands like disable, + start, stop, status, and similar, and in all + unit dependency directives, including Wants=, Requires=, + Before=, After=. Aliases cannot be used with the + preset command. + + Aliases obey the following restrictions: a unit of a certain type (.service, + .socket, …) can only be aliased by a name with the same type suffix. A plain unit (not + a template or an instance), may only be aliased by a plain name. A template instance may only be aliased + by another template instance, and the instance part must be identical. A template may be aliased by + another template (in which case the alias applies to all instances of the template). As a special case, a + template instance (e.g. alias@inst.service) may be a symlink to different template + (e.g. template@inst.service). In that case, just this specific instance is aliased, + while other instances of the template (e.g. alias@foo.service, + alias@bar.service) are not aliased. Those rule preserve the requirement that the + instance (if any) is always uniquely defined for a given unit and all its aliases. Unit files may specify aliases through the Alias= directive in the [Install] section. When the unit is enabled, symlinks will be created for those names, and removed when the unit is @@ -184,6 +198,16 @@ i.e. foo-bar-.service.d/10-override.conf overrides foo-.service.d/10-override.conf. + In cases of unit aliases (described above), dropins for the aliased name and all aliases are + loaded. In the example of default.target aliasing + graphical.target, default.target.d/, + default.target.wants/, default.target.requires/, + graphical.target.d/, graphical.target.wants/, + graphical.target.requires/ would all be read. For templates, dropins for the + template, any template aliases, the template instance, and all alias instances are read. When just a + specific template instance is aliased, then the dropins for the target template, the target template + instance, and the alias template instance are read. + In addition to /etc/systemd/system, the drop-in .d/ directories for system services can be placed in /usr/lib/systemd/system or /run/systemd/system directories. Drop-in files in /etc