Gentoo Archives: gentoo-dev

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

Replies