:: Re: [DNG] OpenRC: was s6-rc, a s6-…
Pàgina inicial
Delete this message
Reply to this message
Autor: Isaac Dunham
Data:  
A: Steve Litt
CC: dng
Assumpte: Re: [DNG] OpenRC: was s6-rc, a s6-based service manager for Unix systems
On Tue, Sep 29, 2015 at 11:00:23AM -0400, Steve Litt wrote:
> On Mon, 28 Sep 2015 16:05:22 -0400 (EDT)
> Rob Owens <rowens@???> wrote:
>
>
> > This system is supposed to mount several NFS shares
> > on boot, but it always fails -- even when using openrc (which is
> > dependency-based) on Funtoo.
>
> Am I the only person who doesn't like OpenRC? It can't respawn
> (supervise, whatever you call it). Its init scripts are every bit as
> complicated as those of sysvinit, but must be written in a special

Huh?

#!/sbin/openrc-run

name="busybox cron"
command="/usr/sbin/crond"
pidfile="/var/run/crond.pid"
command_args="$CRON_OPTS"

depend() {
    need localmount
    need logger
}


That's cron on my Alpine system; it's configureable in /etc/conf.d/cron.

OpenRC can automatically figure out how to start a daemon based on the
command and so on.
The script author doesn't need to set a series of rather obscure
options in a magic comment block; he just writes
need ...
before ...
after ...

And the system administrator doesn't need to fight to add it to a custom
runlevel, or remove it from a default runlevel.
> language that's confusingly almost but not quite /bin/sh. To be


Not quite /bin/sh?
My research indicates that it basically sets up a custom
environment in a /bin/sh script that sources the one you use:
see /lib/rc/sh/openrc-run.sh for more.

If you're referring to the commands, those don't determine the language:
shell script was designed to be extensible by adding new commands.
And any *good* sysvinit script uses several "commands" that are
really shell functions.

> complete, therefore, it must spawn daemontools-encore or s6 to
> supervise things like dhcpd and wpa_supplicant.

True.
But it does integrate some support for that, rather than requiring
the user to figure it out from scratch.

> I agree that OpenRC is better than world-dominator systemd and Upstart,
> but I'd choose sysvinit over it. And I'd *certainly* choose Epoch or
> any of the daemontools inspired inits (or even Suckless Init +
> daemontools-encore + LittKit) over it.


Pedantry: OpenRC competes with sysv-rc, not sysvinit.
Some of the daemontools-style stuff are rc systems, some include init.

> OpenRC? I just don't get it.


Simple:
It's POSIX sh like sysv-rc, minus the boilerplate...stuff like
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# ...
### END INIT INFO

[ -e /etc/default/$NAME ] && . /etc/default/$NAME
...
case "$1" in
  start)
    ...
    ;;
  stop)
    ...
    ;;
  ...)
    ;;
  esac


is stripped down to the depends() function and optionally extra_commands="".
It's also *more* obvious, since you use a shell fuction rather than a
magic comment block.
It handles pretty-printing the status for you, but that's just the icing
on the cake:
most of the functionality that's implemented in shell functions calling
several external helpers in sysv-rc is instead handled in a fairly small
multi-call binary.
And it works close enough to sysv-rc overall that it's fairly easy to
make the move...only a lot of the things that were less obvious now have
simple tools.


Thanks,
Isaac Dunham