supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: "Casper Ti. Vector" <caspervector@gmail.com>
To: supervision@list.skarnet.org
Subject: Converter from single-file init/rc input formats
Date: Mon, 26 Mar 2018 11:09:36 +0800	[thread overview]
Message-ID: <20180326030936.GA28169@CasperVector> (raw)

[-- 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]
}


                 reply	other threads:[~2018-03-26  3:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180326030936.GA28169@CasperVector \
    --to=caspervector@gmail.com \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).