Skip to content
Snippets Groups Projects
Commit 7b2d00c2 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

update 66-envfile doc and pass to execl-envfile

parent 2b8b9728
No related branches found
No related tags found
No related merge requests found
......@@ -15,69 +15,8 @@
<a href="//obarun.org/">www.obarun.org</a>
</p>
<h1>66-envfile</h1>
<h1> 66-envfile</h1>
<p>
This command is a mix of <a href="https://skarnet.org/software/s6/s6-envdir.html"><tt>s6-envdir</tt></a> and <a href="https://skarnet.org/software/execline/importas.html"><tt>importas</tt></a> <em>program</em>.
It reads files containing variable assignments on the given directory, adds the variables to the environment, then executes a program.
</p>
<h2> Interface </h2>
<pre>
66-envfile [ -h ] [ -f <em>file</em> ] [ -l ] <em>dir</em> <em>prog</em>
</pre>
<p>
This tool expects to find a regular file(s) in <em>dir</em> containing one or multiple <tt>key=value</tt> pair. For earch files found, it will parse the file, import the <tt>key=value</tt> then execs <em>prog</em> with the modified environment.
</p>
<h2> Options </h2>
<ul>
<li> <tt>-h&nbsp;</tt>&nbsp;: prints this help. </li>
<li>
<tt>-f&nbsp;<em>file</em>&nbsp;</tt>&nbsp;: only parse <em>file</em> found in <em>dir</em>.
</li>
<li>
<tt>-l&nbsp;</tt>&nbsp;: loose. do nothing and executes <em>prog</em> directly if <em>dir</em> do not contain any regular file(s) or <em>dir</em> doesn't exist.
</li>
</ul>
<h2> File syntax </h2>
<p><em>file</em> is a text file containing lines of the form <tt>key = value</tt>. Whitespace is permitted before and after <em>key</em>, and before or after <em>value</em>,
Quoting is also possible. In this case, the quoting field is treated as one word.
</p>
<p>Empty lines, or lines containing only whitespace, are ignored. Lines beginning with <tt>#</tt> (possibly after some whitespace) are ignored (and typically used for comments). Comments are <strong>not</strong> possible at the end of lines:
<tt>key = value # comment</tt> is not a valid comment.
</p>
<p>Empty <em>value</em> is <strong>not</strong> permitted.</p>
<p>If <tt>key</tt> begin by a <tt>'!'</tt> character: <tt>!key=value</tt> the <tt>key</tt> will be removed from the environment after the substitution.</p>
<h2> Example of use </h2>
<pre>
#!/usr/bin/execlineb -P
fdmove -c 2 1
66-envfile -f ntpd /etc/66/conf/
foreground { mkdir -p -m 0755 ${RUNDIR} }
execl-cmdline -s { ntpd ${CMD_ARGS} }
</pre>
<tt>/etc/66/conf/ntpd</tt> file contain :
<pre>
!RUNDIR=/run/openntpd
!CMD_ARGS=-d -s
</pre>
<p>66-envfile reads <tt>/etc/66/conf/ntpd</tt> file, parses the file, import the variable <tt>RUNDIR</tt> and <tt>CMD_ARGS</tt>, replaces the <tt>${RUNDIR}</tt> and <tt>${CMD_ARGS}</tt> by the corresponding values, unexport the variable then execs the ntpd commandline.</p>
<p>The strict equivalent with s6-envdir and importas command will be:</p>
<pre>
#!/usr/bin/execlineb -P
fdmove -c 2 1
s6-envdir /etc/66/conf
importas -u RUNDIR RUNDIR
importas -u CMD_ARGS CMD_ARGS
foreground { mkdir -p -m 0755 ${RUNDIR} }
execl-cmdline -s { ntpd ${CMD_ARGS} }
</pre>
<p>where <tt>/etc/66/conf</tt> directory contains two named files <tt>RUNDIR</tt> and <tt>CMD_ARGS</tt> written with <tt>/run/openntpd</tt> and <tt>-d -s</tt> respectively.</p>
<p>This command is now <strong>deprecated</strong> - see <a href="execl-envfile.html">execl-envfile</a> program instead.</p>
</body>
</html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="en" />
<title>The 66 Suite: execl-envfile</title>
<meta name="Description" content="Detailed documentation for the execl-envfile command which is part of the 66 software suite" />
<meta name="Keywords" content="66 command execl-envfile service supervision execute script execline environment importas" />
<!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
</head>
<body>
<p>
<a href="index.html">66</a><br />
<a href="//obarun.org/">www.obarun.org</a>
</p>
<h1>execl-envfile</h1>
<p>
This command is a mix of <a href="https://skarnet.org/software/s6/s6-envdir.html"><tt>s6-envdir</tt></a> and <a href="https://skarnet.org/software/execline/importas.html"><tt>importas</tt></a> <em>program</em>.
It reads files containing variable assignments on the given directory, adds the variables to the environment, then executes a program.
</p>
<h2> Interface </h2>
<pre>
execl-envfile [ -h ] [ -f <em>file</em> ] [ -l ] <em>dir</em> <em>prog</em>
</pre>
<p>
This tool expects to find a regular file(s) in <em>dir</em> containing one or multiple <tt>key=value</tt> pair. For earch files found: it will parse the file, import the <tt>key=value</tt> then execs <em>prog</em> with the modified environment.
</p>
<ul>
<li>It open and read the file.</li>
<li>It parse the file.</li>
<li>It import the <tt>key=value</tt> pair.</li>
<li>It substitute each corresponding <tt>key</tt> by <tt>value</tt> into the file.</li>
<li>It unexport the variable if requested.</li>
<li>It execs <em>prog</em> with the modified environment.</li>
</ul>
<h2> Options </h2>
<ul>
<li> <tt>-h&nbsp;</tt>&nbsp;: prints this help. </li>
<li>
<tt>-f&nbsp;<em>file</em>&nbsp;</tt>&nbsp;: only parse <em>file</em> found in <em>dir</em>.
</li>
<li>
<tt>-l&nbsp;</tt>&nbsp;: loose. do nothing and executes <em>prog</em> directly if <em>dir</em> do not contain any regular file(s) or <em>dir</em> doesn't exist.
</li>
</ul>
<h2> File syntax </h2>
<p><em>file</em> is a text file containing lines of the form <tt>key = value</tt>. Whitespace is permitted before and after <em>key</em>, and before or after <em>value</em>,
Quoting is also possible. In this case, the quoting field is treated as one word.
</p>
<p>Empty lines, or lines containing only whitespace, are ignored. Lines beginning with <tt>#</tt> (possibly after some whitespace) are ignored (and typically used for comments). Comments are <strong>not</strong> possible at the end of lines:
<tt>key = value # comment</tt> is not a valid comment.
</p>
<p>Empty <em>value</em> is <strong>not</strong> permitted.</p>
<p>If <tt>key</tt> begin by a <tt>'!'</tt> character: <tt>!key=value</tt> the <tt>key</tt> will be removed from the environment after the substitution.</p>
<h2> Example of use </h2>
<pre>
#!/usr/bin/execlineb -P
fdmove -c 2 1
execl-envfile -f ntpd /etc/66/conf/
foreground { mkdir -p -m 0755 ${RUNDIR} }
execl-cmdline -s { ntpd ${CMD_ARGS} }
</pre>
<p>The strict equivalent with s6-envdir and importas command will be:</p>
<pre>
#!/usr/bin/execlineb -P
fdmove -c 2 1
s6-envdir /etc/66/conf
importas -u RUNDIR RUNDIR
importas -u CMD_ARGS CMD_ARGS
foreground { mkdir -p -m 0755 ${RUNDIR} }
execl-cmdline -s { ntpd ${CMD_ARGS} }
</pre>
<p>where <tt>/etc/66/conf</tt> directory contains two named files <tt>RUNDIR</tt> and <tt>CMD_ARGS</tt> written with <tt>/run/openntpd</tt> and <tt>-d -s</tt> respectively.</p>
<h2> limits</h2>
<p><em>dir</em> cannot exceed more than 100 files. Each file cannot contains more than 4095 bytes or more than 50 <em>key=value</em> pairs.</p>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment