aboutsummaryrefslogtreecommitdiff
path: root/riemann.fmi.uni-sofia.bg/ninit/subdirs.html
blob: 06d2dcd5a5dfad6876e3faa600b83af12e455b2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<html>
<link rel="stylesheet" type="text/css" href="style.css">
<title>subdirs</title>
<body>

<div class="top">
<ul class="nav">
  <li><a href="all.html">All files</a>
</ul>

<h1>ninit special subdirs</h1>
<div class="endtop"></div>
</div>

<table>
<td>
<ul>
<li><a href=#Default>~/default/</a></li>
<li><a href=#Ctrlaltdel>~/ctrlaltdel/</a></li>
<li><a href=#Kbreq>~/kbreq/</a></li>
</ul>

<td>
<ul>
<li><a href=#Log>log/</a></li>
<li><a href=#Halt>~/halt/</a></li>
<li><a href=#Reboot>~/reboot/</a></li>
</ul>
</td>

<td>
<ul>
<li><a href="#Services">How to create services</a></li>
<li><a href="#Examples">Examples</a></li>
<li><a href="#Converter"><tt>/etc/inittab</tt> -> services</li>
</ul>
</td>
</table>

<h2>/etc/ninit</h2>
This is ninit HOME. 
Everything else is below this directory.
See also <a href=man/ninit.man>ninit</a> options.

<h2><a name=Run>~/sys/</a></h2>
This is the default home of ninit helpers.
<tt>/etc/ninit/sys/<a href=man/run.html>run</a></tt> is a 
helper program which start 
<a href="files.html#Run">service's</a> <tt>run</tt>.  


<h2><a name=Ctrlaltdel>~/ctrlaltdel/</a></h2>
What should be done if <tt>Ctrl+Alt+Del</tt> is pressed? 
If this directory does not exist, 
nothing will happen when you press <tt>Ctrl+Alt+dDel</tt>.
Usually this is a link to <a href='#Halt'>halt</a> service.

<h2><a name=Kbreq>~/kbreg/</a></h2>
What should be done if <tt>alt+up-arrow</tt> is pressed.  If this
directory does not exist, nothing will happen when pressing the
<tt>keyboard-request</tt> (<tt>Alt+UP-Arrow</tt> under x86).
Usually this is a link to <a href='#Reboot'>reboot</a> service.

<h2><a name="Default">~/default/</a></h2>
The services ninit starts when booting the system. If this directory
does not exist, nothing will happen at system startup. Quite bad.
<p>
You can start services also from ninit's command line.  For example
if you add to <tt>lilo/grub</tt>
<pre>
init=/sbin/ninit srv1 srv2
</pre>
then ninit starts <tt>srv1</tt> and <tt>srv2</tt> instead of
<tt>default</tt>.
<br>
See also <a href=man/ninit.man>ninit</a> options.


<h2><a name=Halt>~/halt/</a></h2>
The service must halt the system. If this directory does not
exist, nothing will happen when halting the system.
See also <a href=man/shutdown.man>ninit-shutdown</a>.

<h2><a name=Reboot>~/reboot/</a></h2>
The service must reboot the system. If this directory does not exist,
nothing will happen at reboot.  
See also <a href=man/shutdown.man>ninit-shutdown</a>.

<h2><a name="Log">log/</a></h2>

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.
<p>
See also 
<a href=files.html#In>in</a>,
<a href=files.html#Out>out</a> and
<a href=files.html#Log>log/</a>.

<br>
Please, see 
<a href=http://cr.yp.to/daemontools/multilog.html>daemontools</a>
 for a very good logging tool.


<h2><a name="Services">How to create services</a></h2>
You know already the commands 
<a name=Shell>sh</a>, echo, mkdir, rmdir, ln, id, mkfifo,
rm, ls, cat?
<font color=red>If not - very sorry, ninit in not for you yet!</font>
Continue to use /sbin/init!
<p>
The files depends, params, environ, wait, soflimit, pidfile
can be creted with <tt>echo</tt> or a text editor like <tt>vi/emacs</tt>.
See also <a href=files.html>here</a>.  The program
<a href=man/service.man>ninit-service</a> displays a service dir nice.

<ul>
<li>the first letter of a service must be [a-z|A-Z]</li>
<li>what start the service <tt>aW2Ute-Po</tt>?  avoid such names!</li>
<li>don't use very long names</li>
<li>avoid symbolic/hard links.  See the scenario:
<pre>
	test -d srv && ln -s srv srv_double
	nsvc -u srv
	nsvc -u srv_double
	nsvc -L
</pre>
   What happen?  Both are running :-)
   </li>
<!--
<li>don't make service <tt>poweroff</tt>.
    In the future I will catch the signal SIGPWR 
    and it will start this service.
-->
<li>avoid also names <tt>/etc/ninit/{etc|usr|bin|var|tmp|sys}</tt>
</li>
<li>I will use for system services only the letters [a-z].  So
  <tt>sys-test</tt> is good name.
  </li>
</ul>

<h2><a name=Examples>Examples</h2>
Not ready yet!  See my private tar-ed
<a href=ninit-data.tar.gz>directory</a>
and <a href=ls-R.txt>list</a>.
<br>
I will show only one dnscache service.   
<pre>
  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
</pre>

<pre>
  cat /etc/ninit/dnscache/depends
  tynydns
</pre>

<pre>
  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
</pre>

<pre>
  cat /etc/ninit/dnscache/softlimit
  o250
  m1500000
  d3000000
  f1000000
</pre>

The variable DUMPCACHE is defined in my 
<a href=http://riemann.fmi.uni-sofia.bg/docs/djbdns-dumpcache.html>
djbdns-dumpcache</a> patch.



<h2><a name=Converter><tt>/etc/inittab</tt> -> services</h2>

The conveter 
<a href=man/inittab.man>ninit-inittab</a> make a service 
using the first field in <tt>/etc/inittab</tt>.  In most cases
gettys are _1,_2,_3,_4,_5,_6.  You can do
<pre>
	sed -e '/getty/s/^/T/' /etc/inittab > /tmp/inittab
	ninit-inittab /tmp/inittab /etc/ninit /tmp/ninit.sh
	/tmp/ninit.sh
</pre>
Then your services for gettys will be _T1,_T2,_T3,_T4,_T5,_T6.
<p>
Similarly you can edit first a copy of <tt>/etc/inittab</tt>
and obtain a shell script creating services.
You can copy/exec only parts of the output script.
<p>

See also 
<a href=http://smarden.org/ipsvd/examples.html>here</a> for some
network services.  The greatest rule is 
<a href=#Shell>here</a>!

<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>
</body>
</html>