1

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

Raoul Debaze
  • 466
  • 1
  • 8
  • 24

2 Answers2

1

the %postun script runs after uninstallation. I think you should also add

%post
%systemd_post yeah.service
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
1

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
Patrick B.
  • 11,773
  • 8
  • 58
  • 101