Reputation: 498
I'm trying to build a rpm package that enable a systemd service the proper way.
In my rpm spec file, I added:
%{?systemd_requires}
BuildRequires: systemd
...
%postun
%systemd_postun yeah.service
My rpm copy in /usr/lib/systemd/system/ the yeah.service file.
But after package installation, the service is still disable:
root@ansible-1:1:~# systemctl status yeah
Unit yeah.service could not be found.
root@ansible-1:1:~# rpm -Uvh /home/intersec/delivery/yeah.rpm
Preparing... ################################# [100%]
Updating / installing...
1:yeah################################# [100%]
root@ansible-1:1:~# systemctl status yeah
● yeah.service - Yeah
Loaded: loaded (/usr/lib/systemd/system/yeah.service; disabled; vendor preset: disabled)
Active: inactive (dead)
What's wrong?
Raoul
Upvotes: 1
Views: 8832
Reputation: 12353
You'll need to create a preset-file and install it to the right preset-directory. That and using the systemd_*
-macros will enable your service (but not start).
This needs to be added to the spec-file's %install
-section.
%{__install} -Dm644 %{name}.preset %{buildroot}%{_presetdir}/50-%{name}.preset
And this is an example of a preset-file:
enable <your-service-name>.service
Upvotes: 1
Reputation: 37742
the %postun
script runs after uninstallation. I think you should also add
%post
%systemd_post yeah.service
Upvotes: 2