j5

aditionnal tools for the s6 service manager
Log | Files | Refs | README

commit 7d24f195c441f57a2c5580df4453fdee794bd263
parent 1ad5933ced8f15c613c3a5cf95c82da3ef67c293
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 27 Jan 2019 00:11:47 +0100

Add documentation: man page and readme

Diffstat:
MMakefile | 2++
MREADME | 34++++++++++++++++++++++++----------
Aj5-envdir.1 | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 117 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile @@ -12,6 +12,8 @@ clean: install: all mkdir -p ${PREFIX}/bin cp ${bin} ${PREFIX}/bin + mkdir -p ${PREFIX}/share/man/man1 + cp *.1 ${PREFIX}/share/man/man1 j5-envdir: j5-envdir.o ${obj} ./make-bin $@ j5-envdir.o ${obj} diff --git a/README b/README @@ -1,14 +1,28 @@ -import PACK_LOG -import PACK_DEF -import PACK_OUT +j5 - s6 extensions +================== -export PREFIX -export one variable per dependency with all non-alnum replaced by '_'. +j5 is set of tools to provide tiny parts that I needed and s6 does not provide. -copy ${PACK_DEF}/${pack}/${version}/data and ${PACK_DEF}/${pack}/default/data - to ${PACK_OUT}/ -read ${PACK_DEF}/${pack}/default/version +j5-envdir +--------- -read ${PACK_LOG}/${pack}/${version}/dependencies -read ${PACK_LOG}/${pack}/default/dependencies +[s6-envdir][1] exports environment variables according to the content of an +envdir: every file name becomes a variable name, whose value gets the content +of the file. + +This conveniently stores state of variables on the filesystem and permit to +programatically write environment variables before a daemon start. + +[execline][2] comes with multisubstitute and importas which permit to substitute +command line argument with environment variable content like in a shell scipt. +This however require to add an importas statement for each variable to +substitute. Substituting *all* arguments is not desireable neither, as environment +variables comes from various sources. + +Therefore, j5-envdir is the program that handles variables sent to a daemon before it +starts: it subsitute them directly on the command line and on a configuration file +as they get found from the envdir directly instead of doing it by hand with importas. + +[1]: https://skarnet.org/software/s6/s6-envdir.html +[2]: https://skarnet.org/software/execline/importas.html diff --git a/j5-envdir.1 b/j5-envdir.1 @@ -0,0 +1,91 @@ +.Dt J5-ENVDIR 1 +.Dd $Mdocdate: January 26 2019$ +.Os +. +. +.Sh NAME +. +.Nm j5-envdir +.Nd substitute variables given the content of a directory +. +. +.Sh SYNOPSIS +. +.Nm j5-envdir +.Op Fl a +.Op Fl f Ar file +.Op Fl n Ar chomp +.Op Fl p Ar prefix +.Op Fl s Ar suffix +.Ar dir +.Ar cmd +.Op Ar arguments ... +. +. +.Sh DESCRIPTION +. +The +.Nm +utility reads +.Ar dir +and for every file (or symlink to a file), it perform substitution for +variables whose key is the name of the file, and whose value is the content of +the file. +. +.Pp +It then execute the rest of the file +. +.Bl -tag -width 6n +. +.It Fl a +Perform substitution on command line arguments. +. +.It Fl f Ar file +Perform substitution on the content of +.Ar file +replacing it in-place. +. +.It Fl n Ar chomp +Strip the trailing characters if these are among the +.Ar chmop +string. +By default, the characters are newline, space and tab. +. +.It Fl p Ar prefix +Set the prefix that start a variable occurence. +By default, the prefix is +.Dq ${ . +. +.It Fl s Ar suffix +Set the suffix that end a variable occurence. +By default, the suffix is +.Dq } . +. +.El +. +. +.Sh EXIT STATUS +. +.Ex -std +. +. +.Sh EXAMPLES +. +Substitute all variables given from the +.Pa env +directory in both the file +.Pa config +and in command line arguments then start a server: +. +.Dl $ j5-envdir -a -f config env somethingd -fla -g '${GROUP}' +. +. +.Sh SEE ALSO +. +.Lk http://skarnet.org/software/s6/s6-envdir.html "s6: the s6-envdir program" +. +. +.Sh AUTHORS +. +.An Josuah Demangeon +.Aq Mt mail@josuah.net