Gentoo Archives: gentoo-dev

From: "Vadim A. Misbakh-Soloviov" <gentoo@×××.name>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [openrc] [systemd] make `service` common for both OpenRC and SystemD (like Debian/Ubuntu/whatever did)
Date: Sat, 16 Sep 2017 19:56:16
Message-Id: 3005176.dSsCWkhPpk@note
1 Hi there!
3 Every time I switch from mastering service on my work (Ubuntu-powered) to my
4 own server farm (Gentoo powered) I'm going a bit frustrated: Ubuntu (with all
5 my hate to many other things in it) has nice user-friendly way of managing
6 services: you can freely call any of `service <servicename> action` irrelevant
7 to which init-system is currently in use. Will it be systemd, or (whatever
8 there is alternative there). `service` wrapper will detect it anyway and will
9 do the proper things (forward it to either systemd or another service
10 manager).
12 I'd like to suggest to remove `service` widget from openrc and make it the
13 part of (which package? baselayout?)? Here is a pseudocode of how I see it:
15 ```
16 servicename=${1}
17 action=${2}
19 if in_systemd; then
20 systemctl "${action}" "${servicename}"
21 else
22 rc-service "${servicename}" "${action}"
23 fi
24 ```
26 Well, actually, there may be some more logic (for example, instance units
27 (`unit@instance` in `systemd` vs `unit.instance` in openrc), "enable" action
28 (forward it to `rc-update add` for `openrc`, probably) and maybe some more.
29 But anyway, the conception is something like that.
32 What do you think about that?
35 P.S. actually, it also would be nice to add "generators" thing to it too, to
36 make it possible to manage services that have no systemd's units under SystemD
37 and services that have only units under OpenRC (well, that one looks much
38 harder than first variant, but, again, looks like deb/ubuntu guys did that
39 work already and we can try to use their work as cheatsheet)