Gentoo Archives: gentoo-dev

From: James Le Cuirot <chewi@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Providing a `service` scripts that speaks OpenRC and systemd
Date: Sat, 30 Sep 2017 08:07:37
Message-Id: E9861D3F-ADBB-4C02-8873-FFD68A213F88@gentoo.org
In Reply to: Re: [gentoo-dev] Providing a `service` scripts that speaks OpenRC and systemd by "Michał Górny"
1 On 30 September 2017 08:19:36 BST, "Michał Górny" <mgorny@g.o> wrote:
2 >W dniu sob, 30.09.2017 o godzinie 00∶20 -0400, użytkownik Walter Dnes
3 >napisał:
4 >> On Thu, Sep 28, 2017 at 04:27:31PM -0500, Austin English wrote
5 >> > (Note: serious discussion, please take systemd trolling elsewhere).
6 >> >
7 >> > While having the pleasure of working with some proprietary software
8 >> > recently, I was asked to run `service foo restart`, and was
9 >surprised to
10 >> > see:
11 >> > foobar ~ # service foo restart
12 >> > * service: service `foo' does not exist
13 >>
14 >> Ridiculous! We need to develop one universal standard that covers
15 >> everyone's use cases. https://xkcd.com/927/
16 >>
17 >> But if you insist, why not just set up a short bash script called
18 >> "service" rather than monkeying with every init system's internals?
19 >>
20 >>
21 >> #!/bin/bash
22 >> if [[ <condition_running_systemd> ]] ; then
23 >> systemctl ${2} ${1}
24 >> elif [[ <condition_running_initrc> ]] ; then
25 >> /etc/init.d/${1} ${2}
26 >> elif [[ <condition_running_some_other_init> ]] ; then
27 >> <do whatever that init system requires>
28 >> else
29 >> echo "ERROR: Unsupported init system; 'service' call failed"
30 >> fi
31 >>
32 >>
33 >> This can handle a large number of different inits, with as many
34 >"elif"
35 >> lines as you care to add. But, how do we reliably detect the
36 >currently
37 >> running init system? Are there running processes, or entries in
38 >/sys/
39 >> or /proc/ or /dev that are unique to to each init system?
40 >>
41 >
42 >You forgot the huge mapping between different service names. Then
43 >complex mapping from services that are split/merged. Next we need a
44 >tool
45 >that will update conf.d for OpenRC services which are split in systemd,
46 >to allow people controlling them independently.
47
48 Names aren't consistent between Debian and Red Hat either so that isn't really an issue.
49 --
50 Sent from my Android device with K-9 Mail. Please excuse my brevity.