Bug 27390

Summary: [PATCH] lone systemd service support
Product: Sisyphus Reporter: viy <viy>
Component: serviceAssignee: placeholder <placeholder>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P3 CC: aen, glebfm, ldv, legion, piastryyy, placeholder, zerg
Version: unstable   
Hardware: all   
OS: Linux   
URL: http://git.altlinux.org/people/viy/packages/?p=service.git;a=commit;h=a4217a0e9b96b5ba35590b913a60e5d27c8ade52
Bug Depends on:    
Bug Blocks: 27685, 28704, 28705    

Description viy 2012-05-31 23:57:40 MSK
Support for packages that have no sysVinit script but a systemd service.

http://git.altlinux.org/people/viy/packages/?p=service.git;a=commit;h=a4217a0e9b96b5ba35590b913a60e5d27c8ade52
Comment 1 Dmitry V. Levin 2012-06-24 03:06:53 MSK
Proper support of a systemd-only service means that certain chkconfig calls are replaced by corresponding systemctl cals; just omitting chkconfig calls wouldn't qualify to be called "a support".
Comment 2 viy 2012-06-26 17:00:16 MSK
(В ответ на комментарий №1)
> Proper support of a systemd-only service means that certain chkconfig calls are replaced by corresponding systemctl cals; just omitting chkconfig calls
> wouldn't qualify to be called "a support".

Let me recall that the corresponding systemctl calls are performed during the service(8) call (namely, /sbin/service "$1" condrestart), which is _NOT_ omitted in the proposed patch.
I recall, systemd services can be in enabled or disabled state, but system V scripts also have "not installed/uninstalled" state (when a system V script exists, but there are no symlinks in /etc/rc.d) so they need an additional chkconfig call.
systemd scripts does not have this state and just don't need an additional chkconfig call, so we are right to just skip it.
"у нас все точно" (С).
Comment 3 viy 2012-06-26 17:06:02 MSK
the whole idea about the service(8) command is that this command is a portable wrapper that hides the actual implementation (sysV, systemd, upstart,...) is used.
So anayway using the actual systemd calls instead of service would be a bad style.
For example, if user did use sysV init, nothing good happen if we call systemctl.
Comment 4 Dmitry V. Levin 2012-06-26 17:14:36 MSK
How do you propose to implement "systemctl daemon-reload" and "systemctl disable specified.service" commands with "service"?  Up to now this is implemented in chkconfig.
Comment 5 viy 2012-06-26 17:57:36 MSK
(В ответ на комментарий №4)
> How do you propose to implement "systemctl daemon-reload" and "systemctl
> disable specified.service" commands with "service"?  Up to now this is
> implemented in chkconfig.

Indeed. And I was even patching that code...
I am deeply sorry.
Proposed patch is invalid, chkconfig should be tuned instead.
Comment 6 Pavel Shilovsky 2013-03-01 14:32:58 MSK
I created a patch that seems to fix the problem for me:
http://git.altlinux.org/people/piastry/packages/?p=service.git;a=commitdiff;h=950540de8cf8e5987c5694a529efded393ed8bfa

Thoughts?
Comment 7 viy 2013-03-01 23:08:53 MSK
(В ответ на комментарий №6)
> I created a patch that seems to fix the problem for me:
> http://git.altlinux.org/people/piastry/packages/?p=service.git;a=commitdiff;h=950540de8cf8e5987c5694a529efded393ed8bfa

Thanks! This is an important fix.
Comment 8 Repository Robot 2013-03-05 20:41:44 MSK
service-0.5.24-alt1 -> sisyphus:

* Thu Feb 28 2013 Dmitry V. Levin <ldv@altlinux> 0.5.24-alt1
- Implemented systemd-only service support in {post,preun}_service
  (closes: #27390) and native support of systemd services.
  Due to systemctl limitations, when systemd is active,
  post_service will no longer be able to enable sysv-only services.
- Added /sbin/sd_booted utility.
Comment 9 Sergey V Turchin 2013-03-12 18:13:01 MSK
chkconfig --add some.service
не работает. При этом
systemctl enable some.service
отрабатывает нормально

Т.е. %post_service не работает.
Comment 10 Dmitry V. Levin 2013-03-12 18:34:19 MSK
(In reply to comment #9)
> chkconfig --add some.service
> не работает. При этом
> systemctl enable some.service
> отрабатывает нормально
> 
> Т.е. %post_service не работает.

Если systemd активен, то %post_service использует systemctl вместо chkconfig,
и если при этом сервис sysvinit-only, то он не будет включен.  Об этом написано в %changelog'е пакета.
Comment 11 Dmitry V. Levin 2013-03-12 18:37:03 MSK
См. тж. systemd.preset(5) и /lib/systemd/system-preset/99-default.preset
Comment 12 Sergey V Turchin 2013-03-12 18:52:20 MSK
Тогда вручную должно работать, как
systemctl enable тотжесамый.service
Comment 13 Sergey V Turchin 2013-03-12 18:54:07 MSK
(В ответ на комментарий №11)
> См. тж. systemd.preset(5) и /lib/systemd/system-preset/99-default.preset
Т.е. вне зависимости от наличия %post_service в пакете, сервисы, указанные в preset-е включаются специальными триггерами?
Comment 14 Dmitry V. Levin 2013-03-12 18:55:07 MSK
(In reply to comment #12)
> Тогда вручную должно работать, как
> systemctl enable тотжесамый.service

systemctl enable тотжесамый.service работает.
Comment 15 Dmitry V. Levin 2013-03-12 18:57:40 MSK
(In reply to comment #13)
> (В ответ на комментарий №11)
> > См. тж. systemd.preset(5) и /lib/systemd/system-preset/99-default.preset
> Т.е. вне зависимости от наличия %post_service в пакете, сервисы, указанные в
> preset-е включаются специальными триггерами?

Нет, автоматически preset-ы сейсас никто не включает, их включает %post_service
при первой установке пакета.  Хотя это действительно можно было бы реализовать файлтриггерами, %post_service все равно нужен, так что зачем?
Comment 16 Sergey V Turchin 2013-03-12 19:17:36 MSK
Зачем пытаться кое-что кое-где возможно если повезет включить, когда надо *включить* ?

Или firetrigger нужно сделать и игнорировать chkconfig в %post_service или chkconfig должен включать вне зависимости от preset-ов.
Comment 17 Sergey V Turchin 2013-03-12 19:30:13 MSK
Оказывается, механизм, аналогичый system-preset присутствует в init-файлах, но в каждом индивидуально. В поле "chkconfig:" первым параметром написано, запускать ли его не каких-то runlevel-ах по умолчанию.

Аналог этой информации для systemd у нас на данный момент отсутствует.
Comment 18 Sergey V Turchin 2013-03-15 15:07:51 MSK
Может, убрать из %post_service поддержку systemd и сделать firetrigger для включения systemd-шных сервисов? А то как-то странновато в результате получается в случае с systemd.
Comment 19 Sergey V Turchin 2013-03-15 15:10:24 MSK
И удобно будет: положил preset и не паришься больше ни о чем.
Иначе приходится городить костыли. У меня, например, installer-feature-kdesktop-services, а у других свои.