Index · Directives systemd 263~devel

Name

systemd-update-helper — Enable, disable, stop, and restart units when packages are installed, upgraded, or removed

Synopsis

/usr/lib/systemd/systemd-update-helper [OPTIONS...] {COMMAND} [UNIT...]

Description

Package managers call systemd-update-helper from the scriptlets of packages that contain unit files. The systemd RPM macros and file triggers call it. It has to run as root.

By default, the commands operate on the system service manager and the system unit directories. With --global, they operate on the global user unit configuration and on every running user service manager, i.e. every active user@UID.service unit. A user service manager that fails or does not finish the operation within 15 seconds is skipped and does not affect the others. The timeout is set at build time with the -Dupdate-helper-user-timeout-sec= option.

If the system was not booted with systemd, or the helper runs in a chroot(2) environment, the commands only change unit files and skip all operations on service managers. Set $SYSTEMD_OFFLINE= to override this detection, see Known Environment Variables.

A UNIT argument is either a unit name or the absolute path of a unit file directly in /usr/lib/systemd/system/ or /etc/systemd/system/, or in /usr/lib/systemd/user/ or /etc/systemd/user/ with --global. The path does not have to exist. Template units passed to remove-units, mark-restart-units, and mark-reload-units apply to all active instances of the template.

Commands

install-units UNIT…

Enables or disables the units according to the preset policy, like systemctl preset does. With --global, applies the user preset policy to the global user unit configuration, like systemctl --global preset does.

Added in version 263.

remove-units UNIT…

Disables the units and stops them. With --global, each running user service manager also disables the units in the configuration of its user, where systemctl --user enable creates its symlinks.

Added in version 263.

mark-restart-units UNIT…, mark-reload-units UNIT…

Marks the units to be restarted or reloaded by the next enqueue-marked. See enqueue-marked in systemctl(1).

Added in version 263.

daemon-reload

Reloads the configuration of the service manager. With --global, reloads every running user service manager.

Added in version 263.

enqueue-marked

Restarts or reloads the units that are marked for it, and waits for the jobs to finish.

Added in version 263.

daemon-reload-enqueue-marked

Runs daemon-reload, then enqueue-marked.

Added in version 263.

Options

--system

Operates on the system service manager and the system unit directories. This is the default.

Added in version 263.

--global

Operates on the global user unit configuration and on every running user service manager.

Added in version 263.

--stdin

Reads the units from standard input, one unit name or unit file path per line, instead of from the arguments. Lines that do not name a unit, or name a path outside of the unit directories, are ignored. The RPM file triggers pass the unit files of removed packages this way.

Added in version 263.

--dry-run

Logs the changes and operations without performing them.

Added in version 263.

-q, --quiet

Only logs errors.

Added in version 263.

-h, --help

Print a short help text and exit.

--version

Print a short version string and exit.

Exit status

On success, 0 is returned, a non-zero failure code otherwise. A failure to preset a unit with install-units makes the command fail. Failures to disable, stop, mark, restart, or reload individual units, and failures of individual user service managers, are logged and do not change the exit status.

Examples

Example 1. Disable and stop the units of a removed package

# printf '%s\n' /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd@.service | \
    /usr/lib/systemd/systemd-update-helper --stdin remove-units

This disables sshd.service and sshd@.service, and stops sshd.service and all active instances of sshd@.service.


See Also

systemd(1), systemctl(1), systemd.preset(5), daemon(7)