DevHeads.net

Proper way to keep service enabled when updated from sysv to systemd?

Hi,

I packaged xe-guest-utilities with a systemd service for Fedora.

But there is an upstream rpm package that include the same service as
a sysv one. And the
service is enabled with the 'Default-Start' info in the init script
after '/sbin/chkconfig --del xe-linux-distribution'.

And when people update the package from upstream one to the Fedora
one. Since the service changed to a systemd one. The service is then
disabled by default without regard to the sysv service.

That surprises end users. So the new package should make it compatible
in the scriptlets.
But which is the proper way?

Best Regards
-robin

Comments

Re: Proper way to keep service enabled when updated from sysv to

By Zbigniew =?utf-... at 08/13/2019 - 09:34

On Tue, Aug 13, 2019 at 06:02:42PM +0800, Robin Lee wrote:
You can add a %trigger script. Something like this, completely untested:
%triggerun xe-linux-distribution < …old…version+1…
if test -e /etc/rc.d/rc3.d/Snn-…; then
# enable systemd service based on old status
systemctl enable xe-linux-distribution.service
fi

Please note that for new packages, the general guidelines apply
(<a href="https://docs.fedoraproject.org/en-US/packaging-guidelines/DefaultServices/" title="https://docs.fedoraproject.org/en-US/packaging-guidelines/DefaultServices/">https://docs.fedoraproject.org/en-US/packaging-guidelines/DefaultServices/</a>)
and services should be managed through presets. But keeping enablement
state on upgrade is outside of the guidelines and a nice thing to do.

Zbyszek

Re: Proper way to keep service enabled when updated from sysv to

By Robin 'cheese' Lee at 08/14/2019 - 02:36

On Tue, Aug 13, 2019 at 10:37 PM Zbigniew Jędrzejewski-Szmek
< ... at in dot waw.pl> wrote:
Thanks for your tips!

I now use such version:

%triggerun -- %{name}
if /bin/ls /etc/rc3.d/S*%{service_name} >/dev/null 2>&1; then
# Re-enable the service if it was enabled in sysv mode
/usr/bin/systemctl enable %{service_name} >dev/null 2>&1||:
/bin/rm /etc/rc3.d/S*%{service_name} >/dev/null 2>&1||:
/usr/bin/systemctl try-restart %{service_name} >dev/null 2>&1||:
fi

Re: Proper way to keep service enabled when updated from sysv to

By Nico Kadel-Garcia at 08/13/2019 - 17:56

On Tue, Aug 13, 2019 at 10:36 AM Zbigniew Jędrzejewski-Szmek
< ... at in dot waw.pl> wrote:
Or.... Just use "chkconfig" and "service" for both init and systemd
scrupts, until and unless the migation to systemd is stable.