7
1
I've been creating RPMS (using CMake's CPack) which install everything into /opt
, and then the postinstall script copies the service definition files to /etc/systemd/system
.
I've toyed around with starting and stopping the services as well in the RPM postinstall and preuninstall scripts, but this doesn't seem to be a good idea, because yum
will run the postinstall script before the preuninstall script if doing an upgrade, and that means that if you try to upgrade a service, you end up with the service not running anyways. Even enable/disable seems to have the same issue.
So the two questions I have
Is it a good idea to install directly into
/etc/systemd
, or should a postinstall copy from/opt
to/etc/systemd
? Iscp
followed bysystemctl daemon-reload
the "right" way of installing the service file?Is there a clean way of
starting/stopping/enable/disable
services from an RPM, or is this better left out of the RPM?
Related question (with no answers) for Debian:
Preferred/Idiomatic method to enable a systemd.service from a Debian package installation
1I believe that in RPM-based distributions, it is frowned upon to ship (or copy) files in /etc. Instead, you should ship them into /lib/systemd. This way, your users can change the files by copying them to /etc, without losing changes on upgrade. – Wouter Verhelst – 2015-07-30T11:02:18.243