ninit special subdirs

/etc/ninit

This is ninit HOME. Everything else is below this directory. See also ninit options.

~/sys/

This is the default home of ninit helpers. /etc/ninit/sys/run is a helper program which start service's run.

~/ctrlaltdel/

What should be done if Ctrl+Alt+Del is pressed? If this directory does not exist, nothing will happen when you press Ctrl+Alt+dDel. Usually this is a link to halt service.

~/kbreg/

What should be done if alt+up-arrow is pressed. If this directory does not exist, nothing will happen when pressing the keyboard-request (Alt+UP-Arrow under x86). Usually this is a link to reboot service.

~/default/

The services ninit starts when booting the system. If this directory does not exist, nothing will happen at system startup. Quite bad.

You can start services also from ninit's command line. For example if you add to lilo/grub

init=/sbin/ninit srv1 srv2
then ninit starts srv1 and srv2 instead of default.
See also ninit options.

~/halt/

The service must halt the system. If this directory does not exist, nothing will happen when halting the system. See also ninit-shutdown.

~/reboot/

The service must reboot the system. If this directory does not exist, nothing will happen at reboot. See also ninit-shutdown.

log/

If this directory exists (within another service directory), it is taken as a log service and ninit start it before the service. If the log service can not be started, current service will block if it writes to stdout.

See also in, out and log/.
Please, see daemontools for a very good logging tool.

How to create services

You know already the commands sh, echo, mkdir, rmdir, ln, id, mkfifo, rm, ls, cat? If not - very sorry, ninit in not for you yet! Continue to use /sbin/init!

The files depends, params, environ, wait, soflimit, pidfile can be creted with echo or a text editor like vi/emacs. See also here. The program ninit-service displays a service dir nice.

Examples

Not ready yet! See my private tar-ed directory and list.
I will show only one dnscache service.
  ls -l /etc/dnscache
  -rw-r--r--  root   root     8 Jan 18  2007 depends
  -rw-r--r--  root   root   131 Jan 17  2007 environ
  lrwxrwxrwx  root   root    18 Jan 18  2007 in -> /etc/dnscache/seed@
  lrwxrwxrwx  root   root    12 Dec 20  2006 out -> ../logger/in@
  -rw-r--r--  root   root     0 Dec 21  2006 respawn
  lrwxrwxrwx  root   root    23 Jan 17  2007 run -> /usr/local/bin/dnscache@
  -rw-r--r--  root   root    32 May 20 23:55 softlimit
  cat /etc/ninit/dnscache/depends
  tynydns
  cat /etc/ninit/dnscache/environ
  UID=208
  GID=502
  ROOT=/etc/dnscache/root
  IP=127.0.0.1
  IPSEND=0.0.0.0
  CACHESIZE=286600
  DUMPCACHE=7200:dump/data
  SLURPCACHE=dump/data
  cat /etc/ninit/dnscache/softlimit
  o250
  m1500000
  d3000000
  f1000000
The variable DUMPCACHE is defined in my djbdns-dumpcache patch.

/etc/inittab -> services

The conveter ninit-inittab make a service using the first field in /etc/inittab. In most cases gettys are _1,_2,_3,_4,_5,_6. You can do
	sed -e '/getty/s/^/T/' /etc/inittab > /tmp/inittab
	ninit-inittab /tmp/inittab /etc/ninit /tmp/ninit.sh
	/tmp/ninit.sh
Then your services for gettys will be _T1,_T2,_T3,_T4,_T5,_T6.

Similarly you can edit first a copy of /etc/inittab and obtain a shell script creating services. You can copy/exec only parts of the output script.

See also here for some network services. The greatest rule is here!