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
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
systemctl daemon-reloadthe "right" way of installing the service file?
Is there a clean way of
starting/stopping/enable/disableservices from an RPM, or is this better left out of the RPM?
Related question (with no answers) for Debian: