supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* Converter from single-file init/rc input formats
@ 2018-03-26  3:09 Casper Ti. Vector
  0 siblings, 0 replies; only message in thread
From: Casper Ti. Vector @ 2018-03-26  3:09 UTC (permalink / raw)
  To: supervision

[-- Attachment #1: Type: text/plain, Size: 704 bytes --]

For your amusement, I just made a silly converter from a format remotely
like that of OpenRC.  Note that unlike slew.rc which is largely
independent of any particular rc(1) feature, this converter depends on
rc(1)'s ability to handle variables with unconventional names (eg.
`timeout-kill' and `data/test') and to easily use dynamically named
variables (eg. `$$_name').  And seriously, if you really find a
single-file format necessary (for marketing reasons :(), I think a
shell-based format would be better than alternatives like systemd units
or immortal `run.yml' files.

-- 
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C


[-- Attachment #2: conv.rc --]
[-- Type: text/plain, Size: 685 bytes --]

#!/bin/rc -e

_wrap=/etc/slew/lib/wrap.rc
_base=/etc/slew/conv
if (~ $#* 0) exit 1
. $1
if (! ~ $#self 1 || ~ $self */*) exit 1
mkdir $self
cp $1 conv

for (_name in \
	type contents dependencies notification-fd nosetsid \
	timeout-up timeout-down timeout-kill timeout-finish \
	producer-for consumer-for pipeline-name \
) {
	if (! ~ $#$_name 0) {
		echo $$_name | tr -s ' ' '\n' > $self/$_name
	}
}

for (_name in $extra) {
	if (~ $_name */*) mkdir -p `{dirname $self/$_name}
	printf '%s' $$_name > $self/$_name
}

for (_name in up down run finish) {
	if (whatis $_name > /dev/null >[2=1])
	printf '#!/bin/execlineb -P\n%s %s %s\n' \
		$_wrap $_base/$self.rc $_name > $self/$_name
}


[-- Attachment #3: wrap.rc --]
[-- Type: text/plain, Size: 23 bytes --]

#!/bin/rc -e

. $1
$2


[-- Attachment #4: hello.rc --]
[-- Type: text/plain, Size: 137 bytes --]

#!/bin/rc

self=hello
type=longrun
dependencies=(origin)
extra=(data/test)

data/test=''

fn run {
	echo Hello world
	exec cat >[2=1]
}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-26  3:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26  3:09 Converter from single-file init/rc input formats Casper Ti. Vector

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).