Search code examples
rpmsystemdpreset

How to use the systemd presets in an RPM package


I am reading the Fedora packaging guidelines on using systemd presets but am missing a key point:

The macro %systemd_post runs systemctl preset meaning that the information about whether to enable or to disable the service must already be present in the systemd preset files. But where does it go there from in the first place? Should the package first place it own preset file in the location provided (which is not recommended as far as I have read since it complicates the management of the general policy) or add the service being installed into one of the existing systemd preset files? To which then as there are several of them?

I am talking about a self-written service which meets the requirements of being enabled by default and which I would thus like to enable automatically during the installation.


Solution

  • About presets: https://fedoraproject.org/wiki/Features/PackagePresets https://www.freedesktop.org/software/systemd/man/systemd.preset.html

    Those presets are intended for distribution itself (e.g. some service should be enabled for Workstation, but not for Server). Your 3rd party package will never be enabled. So if you really think it should be enabled (think twice) then you simply enable it in %post. This will be rejected if you would like to get your package into Fedora, but I guess that that is not your case.