diff options
Diffstat (limited to 'riemann.fmi.uni-sofia.bg/ninit/files.html')
| -rw-r--r-- | riemann.fmi.uni-sofia.bg/ninit/files.html | 500 |
1 files changed, 500 insertions, 0 deletions
diff --git a/riemann.fmi.uni-sofia.bg/ninit/files.html b/riemann.fmi.uni-sofia.bg/ninit/files.html new file mode 100644 index 0000000..b819cf6 --- /dev/null +++ b/riemann.fmi.uni-sofia.bg/ninit/files.html @@ -0,0 +1,500 @@ +<html> +<link rel="stylesheet" type="text/css" href="style.css"> +<title>files</title> +<body> + +<div class="top"> +<ul class="nav"> + <li><a href="all.html">All files</a> +</ul> +<div class="endtop"></div> +</div> + + +<h2>/etc/ninit/ global special files</h2> +<table> +<td><ul><li><a href=#Gin>~/in</a><li></ul> +<td><ul><li><a href=#Gin>~/out</a><li></ul> +<td><ul><li><a href=#Grun>~/sys/</a><li></ul> +<td><ul><li><a href=#Gbin>~/bin/</a><li></ul> +</td> +</table> + +<h2>Special files in a service directory</h2> + + +<table> +<td> +<ul> +<li><a href="#In">in</a></li> +<li><a href="#Out">out</a></li> +<li><a href="#Run">run</a></li> +<li><a href="#Log">log/</a></li> +</ul> + +<td> +<ul> +<li><a href="#Depends">depends</a></li> +<li><a href="#Params">params</a></li> +<li><a href="#Respawn">respawn</a></li> +<li><a href="#Sync">sync</a></li> +</ul> + + +<td> +<ul> +<li><a href="#Environ">environ</a></li> +<li><a href="#Softlimit">softlimit</a></li> +<li><a href="#End">end</a></li> +<li><a href="#Uid">uid</a></li> +</ul> + +<td> +<ul> +<!-- <li><a href="#Gid">gid</a></li> --> +<li><a href="#Nice">nice</a></li> +<li><a href="#Sleep">sleep</a></li> +<li><a href="#Alarm">alarm</a></li> +<li><a href="#Pidfile">pidfile</a></li> +<td> + + +<td> +<ul> +<li><a href="#Wait">wait</a></li> +<li><a href="#Maxwait">maixwait</a></li> +<li><a href="#Pause">pause</a></li> +<li><a href="#Pause">pause-wait</a></li> +</ul> +</td> + +<td> +<ul> +<li><a href="#Cron">cron</a></li> +<li><a href="#Setup">setup</a></li> +<li><a href="#Rsetup">rsetup</a></li> +<li><a href="#Sys-rsetup">sys-rsetup</a></li> +</ul> +</td> +</table> + + + +<h2><a name=Gin>~/{in|out}</a></h2> +<tt>in</tt> and <tt>out</tt> +are the FIFOs ninit communicates with its helper programs. +Those have to exist before ninit is started and +they should be owned by root and have mode 600. +<pre> +~$ ls -l /etc/ninit/in /etc/ninit/out +prw------- 1 root root 0 Jan 15 11:14 /etc/ninit/in| +prw------- 1 root root 0 Jan 15 11:14 /etc/ninit/out| +</pre> + +<h2><a name=Grun>~/sys/</a></h2> +This is the default home for ninit helpers. +<pre> +~$ ls -lf /etc/ninit/sys +-rwxr-xr-x 1 root root 2340 Jan 12 22:28 procfs* +-rwxr-xr-x 1 root root 1688 Jan 12 22:28 remove* +-rwxr-xr-x 1 root root 3796 Jan 12 22:28 run* +-rwxr-xr-x 1 root root 4428 Jan 12 22:28 run-wait* +-rwxr-xr-x 1 root root 1924 Jan 12 22:28 update* +</pre> +The most important program here is <b>run</b>. It start a service +checking different files in the service subdirectory. +Never start these files! +Please, +<b><font color=magenta>don't remove/rename/replace</font></b> +the files here, unless you know what are you doing! +They are helpers for +<b>ninit</b> +and +<b>nsvc</b>. + +<!-- +Helper program - it's ninit's right-hand. +<font size=+1 color=red>Never remove it !!!</font> +You can replace it with a test version using: +<pre> + install /path/to/run.test /etc/ninit/run +</pre> +--> + +<h2><a name=Gbin>~/bin/</a></h2> +Here I put some programs which are useful for something. +Ninit daemons don't need to start any of them. +If you dislike this directory, simply +<b><font color=magenta>remove</font></b> it! + +One <b>good idea</b> +is to make a symbolic link: +<pre> +ln -s /bin/dash /etc/ninit/bin/sh +</pre> +Then in all shell scripts in /etc/ninit/ three use on the first +line +<pre> +#!/etc/ninit/bin/sh +... +</pre> +You can replace also <b>dash</b> with <b>bash</b> or <b>sh</b> +above. +Since your scripts in <b>/etc/ninit/</b> are simple (I suppose), +any fast, small, non-interactive shell is welcome. +One such candidate is the original Steve Bourne +<b>sh</b> from 1978. +A new port is available +<a href=/sh/>here</a>. +Install it under the name <b>bsh</b> in /bin/. +I recommend to build it using +<a href=http://www.fefe.de/dietlibc/>dietlibc</a>. + +<p> Why I suggest the symbolic link above? I suppose that +in the future someone can write a better shell. Then +we will update only the link - there is no need to edit each +script. + +<p> +<hr> +<p> + +Below all files <tt>{in|out}</tt> +are differnt from <tt>/etc/ninit/{in|out}</tt> +repectively. + +<h2><a name="Depends">depends</a></h2> + A plain text file containing a service name per line. + Example: <tt>/etc/ninit/dnscache/depends</tt> + could contain <tt>tinydns</tt>. + Each of these services will be started before this service is + started. If you need to wait for static initializations to + complete, use the + <a href=#Sync>sync</a> flag. + See also the + <a href=#Wait>wait</a> + flag. + +<h2><a name="Run">run (service's executable)</a></h2> + + A symbolic link to the program name. No hard link, because + <tt>argv[0]</tt> + for the programs is created by extracting the part after the last + slash in the contents of the symbolic link. + <br> + Example: <tt>/usr/bin/sshd</tt> + would be run with <tt>argv[0]=sshd</tt>. + +<h2><a name="Params">params</a></h2> + + A plain text file containing command line parameters for the + service, one parameter per line. No shell expansion is done. If + you need shell expansion, have run point to a shell script instead + of the real daemon. Note: Have the shell script exec the daemon + instead of simply running it to save system resources. + + +<h2><a name="Environ">environ</a></h2> + Similar to depends. The helper + <tt>/etc/ninit/run</tt> adds + the contents of this file + to the system's environ. Example: +<pre> +TERM=linux +PATH=/bin:/usr/bin:/usr/local/bin +UID=321 +GID=432 +BOOT_IMAGE +</pre> +Since BOOT_IMAGE does not have "<b>=</b>" this variable is removed. +If the first line is empty then the system's environ is deleted first. + + +<h2><a name="Wait">wait</a></h2> + Similar to depends. + The helper <tt>/etc/inint/run</tt> + waits for services included in + this file to finish and after that start a current service. + Include wait services also in depends. + <p> + This is different from + <a href=#Sync>sync</a> flag. + Let the service B must be started after the service A finish. + One can sync A. This will block all other services. + In this case it's better to use wait instead of sync. + <p> + It's possible to set wait parameters + (see <a href=#Maxwait>maxwait</a>) at the end of + each entry. Example: +<pre> +some_service:180:3</tt> +other_service:300:5</tt> +</pre> + +<h2><a name="Maxwait">maxwait</a></h2> + + A plain text file containing the values n1[:n2]. Wait no more + than n1 sec the services to finish. See also + <a href="#Wait">wait</a>. Default is 600 sec. The value n1=0 + means - wait until the service finish. + +<h2><a name="Alarm">alarm</a></h2> + + A plain text file containing the value n. + Execs alarm(n) before starting the child. It's timeout like. + Don't use this for services which catch SIGALRM signal. + +<h2><a name="Softlimit">softlimit</a></h2> + Similar to depends. + See Daniel Bernstein + <a href=http://cr.yp.to/daemontools/softlimit.html>softlimit</a> + program. + <br> + Lines with the same options as + <a href=http://cr.yp.to/daemontools/softlimit.html>softlimit</a> + (skip leading '-'). + Example: +<pre> + echo m3000000 > softlimit + echo o30 >> softlimit + echo f200000 >> softlimit +</pre> +The helper +<tt>/etc/ninit/run</tt> execs the service with this restrictions. + +<h2><a name="Respawn">respawn</a></h2> + + Touch this file to make ninit respawn the process when it dies. + This should be touched for getty and network servers. + +<h2><a name="Sync">sync</a></h2> + + Touch this file to make ninit wait until the service ends. sync is + mutually exclusive with + <a href=#Respawn>respawn</a>. This is meant for static + initializations like <tt>ifconfig</tt>. See also + <a href="#Wait">wait</a>. +<!-- + If sync contains a nonzero number n ninit will wait max n sec + the service to finish. If it does not ends until n secs then + ninit continues to start the other services. +--> + +<h2><a name="Log">log/</a></h2> + + If this directory exists, it is taken as service and ninit creates + a FIFO <tt>log/in</tt> and soft link of + <tt>log/in</tt> to <tt>out</tt>. It's equivalent to: +<pre> + test -d log && mkfifo -m 600 log/in && ln -s log/in out +</pre> + If the log + service can not be started, the service will block if it writes + to stdout. See also + <a href="subdirs.html#Log">log</a>. + +<h2><a name="Nice">nice</a></h2> + + A plain text file containing the value to add to the nice level + via the nice system call. + +<h2><a name="Sleep">sleep</a></h2> + + A plain text file containing the value n. Sleep n secs after fork + before running child. Useful if respawning is very fast. + +<h2><a name="In">in</a> (service's input)</h2> + + This file (named pipe) is used for stdin. + +<h2><a name="Out">out</a> (service's output)</h2> + + This file (named pipe) is used for stdout and stderr. + e.g. a symlink to /dev/null +<p> +It's possible to send the output of many services to one logger. +Let for example create one service with: +<pre> + cd /etc/ninit + mkdir logger && cd logger + mkfifo logger/in + ln -s /path/to/multilog run + echo -n 721 > uid + # setup: params, softlimit, depends, environ, uid, ... +</pre> +Then in other service dir we can do: +<pre> + echo logger >> depends + cd /path/to/sevirce-dir + ln -s ../logger/in out +</pre> + +<!-- +</pre> +<h2><a name="Gid">gid</a></h2> + + A plain text file containing a number. + Exec the program with this GID. +--> + +<h2><a name="Uid">uid</a></h2> + A plain text file containing a number. + Exec the program with this UID. It's possible to write + also UID:GID. It's better to use UID, GID smaller than 65530. + It is possible to write here also the supplementary groups. + For example: +<pre> + echo 23:99:240:320:100 > uid +</pre> + start the service with: + UID=23, GID=99, GROUPS=99,240,320,100. + +<h2><a name="End">end (service's executable)</a></h2> + + Similar to <a href=#Run>run</a>. + After the service finish "end" will be executed. + The helper does not set environ, softlimit, uid restrictions. + You can put there for example: +<pre> + #!/bin/sh + exec /bin/nsvc -C+3 service_name +</pre> + Use this option instead of + <a href=#Sync>sync</a> or + <a href=#Wait>wait</a> mode. Let for example + services B,C,D must be started after A finish. There are two + possible solutions: +<br> +<font color=red>Bad</font>: start A in sync mode +<br> +<font color=green>Good</font>: start A i normal mode and put in "end" +<pre> + #!/bin/sh + exec /bin/nsvc -o B C D +</pre> +<b>end</b> is started with arguments: +<pre> + $1=service_name $2=ninit_home $3=ninit_sysdir +</pre> +Example: +<pre> + #!/bin/sh + x=`echo $1 | tr '/' ':'` + rm -f /var/run/ninit-$x.pid +</pre> + +<h2><a name="Setup">setup</a></h2> + + If this file exist it is started just before + <tt>/etc/ninit/service/run</tt> in + sync mode. + If + <a href="#Uid">uid</a> + or + <a href="#Softlimit">softlimit</a> exist they are applied first and + after that setup is executed. Example: +<pre> + #!/bin/sh + PATH=/bin:/usr/bin + id; env +</pre> + <b>setup</b> is started with arguments: +<pre> + $1=service_name $2=ninit_home $3=ninit_sysdir $4=service_pid +</pre> + +<h2><a name="Rsetup">rsetup</a></h2> + Similar to + <a href="#Setup">setup</a>. It is executed before setup as root and + not softlimit, uid, in/out restrictions. + <br> + If you want + to modify some special files see the flag + <a href="#Sys-rsetup">sys-rsetup</a>. Next create pidfile + before the service start. Remove the pidfile with + <a href=#End>end</a> after it finish. +<pre> + #!/bin/sh + x=`echo $1 | tr '/' ':'` + echo $4 > /var/run/ninit-$x.pid +</pre> +I really don't know why we need such +<font color=magenta>nonsense</font> in <i>/var/run/</i>. +In my opinion pids in <i>/var/run/</i> are outdated and +unreliable thinks! + + +<h2><a name="Sys-rsetup">sys-rsetup</a></h2> + Similar to + <a href="#Setup">setup</a>. + It is executed first (before rsetup and setup) as root. +<br> + It can even modify special files like + params, depends, wait, uid... +<br> Example: +<pre> + #!/bin/sh + + export PATH=/bin:/usr/bin + umask 022 + + if test -f "uid-gid" ; then + a=`read name < uid-gid` + echo -n `id -u $name` > uid + echo -n :`id -g $name` >> uid + fi +</pre> + +<h2><a name="Pidfile">pidfile</a></h2> + This is an easy method to setup a service which run in background. + Prepare it as ordinary service and write only + the name of the pidfile. Don't use links for pidfile! + Example: +<pre> + cd /etc/ninit/gpm + echo -n /var/run/gpm.pid > pidfile +</pre> + See also the helper + <a href=man/pidfile.man>ninit-pidfile</a>. + +<h2><a name="Pause">pause</a></h2> + If this file exist then <tt>/etc/ninit/sys/run</tt> + wait for SIGCONT before starting the service's run. + +<h2><a name="Pause-wait">pause-wait</a></h2> + If this file exist then <tt>/etc/ninit/sys/run-wait</tt> + helper wait for SIGCONT before starting the service's run. + Example: +<pre> +x=/tmp/__test; mkdir $x; cd $x +ln -s `which date` run +touch pause; touch pause-wait +nsvc -o $x + +nsvc $s; sleep 3; nsvc -c $x +nsvc $x; sleep 3; nsvc -c $x +nsvc $x +</pre> + +<h2><a name="Cron">cron</a></h2> +A plain text file containing two or three numbers per line. +Example: +<pre> +echo 1d:2h7:0 > cron +</pre> +The service will be started on 02:07:00 UTC every day. +If the third number is nonzero the service will be started +first time immediately (not waiting for cron timestamp). + + +<p> +Last modified: 17 December 2009 + +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> + +Gratuitious blank lines added so that files.html#link works. + +</body> +</html> |
