1 |
On Thu, Sep 28, 2017 at 04:27:31PM -0500, Austin English wrote |
2 |
> (Note: serious discussion, please take systemd trolling elsewhere). |
3 |
> |
4 |
> While having the pleasure of working with some proprietary software |
5 |
> recently, I was asked to run `service foo restart`, and was surprised to |
6 |
> see: |
7 |
> foobar ~ # service foo restart |
8 |
> * service: service `foo' does not exist |
9 |
|
10 |
Ridiculous! We need to develop one universal standard that covers |
11 |
everyone's use cases. https://xkcd.com/927/ |
12 |
|
13 |
But if you insist, why not just set up a short bash script called |
14 |
"service" rather than monkeying with every init system's internals? |
15 |
|
16 |
|
17 |
#!/bin/bash |
18 |
if [[ <condition_running_systemd> ]] ; then |
19 |
systemctl ${2} ${1} |
20 |
elif [[ <condition_running_initrc> ]] ; then |
21 |
/etc/init.d/${1} ${2} |
22 |
elif [[ <condition_running_some_other_init> ]] ; then |
23 |
<do whatever that init system requires> |
24 |
else |
25 |
echo "ERROR: Unsupported init system; 'service' call failed" |
26 |
fi |
27 |
|
28 |
|
29 |
This can handle a large number of different inits, with as many "elif" |
30 |
lines as you care to add. But, how do we reliably detect the currently |
31 |
running init system? Are there running processes, or entries in /sys/ |
32 |
or /proc/ or /dev that are unique to to each init system? |
33 |
|
34 |
-- |
35 |
Walter Dnes <waltdnes@××××××××.org> |
36 |
I don't run "desktop environments"; I run useful applications |