disable reserved blocks for checkpointing in yaffs2 on rb532 and adm5120
[openwrt.git] / docs / init-scripts.tex
1 Because OpenWrt uses its own init script system, all init scripts must be installed
2 as \texttt{/etc/init.d/\textit{name}} use \texttt{/etc/rc.common} as a wrapper.
3
4 Example: \texttt{/etc/init.d/httpd}
5
6 \begin{Verbatim}
7 #!/bin/sh /etc/rc.common
8 # Copyright (C) 2006 OpenWrt.org
9
10 START=50
11 start() {
12 [ -d /www ] && httpd -p 80 -h /www -r OpenWrt
13 }
14
15 stop() {
16 killall httpd
17 }
18 \end{Verbatim}
19
20 as you can see, the script does not actually parse the command line arguments itself.
21 This is done by the wrapper script \texttt{/etc/rc.common}.
22
23 \texttt{start()} and \texttt{stop()} are the basic functions, which almost any init
24 script should provide. \texttt{start()} is called when the user runs \texttt{/etc/init.d/httpd start}
25 or (if the script is enabled and does not override this behavior) at system boot time.
26
27 Enabling and disabling init scripts is done by running \texttt{/etc/init.d/\textit{name} enable}
28 or \texttt{/etc/init.d/\textit{name} disable}. This creates or removes symbolic links to the
29 init script in \texttt{/etc/rc.d}, which is processed by \texttt{/etc/init.d/rcS} at boot time.
30
31 The order in which these scripts are run is defined in the variable \texttt{START} in the init
32 script, which is optional and defaults to \texttt{50}. Changing it requires running
33 \texttt{/etc/init.d/\textit{name} enable} again.
34
35 You can also override these standard init script functions:
36 \begin{itemize}
37 \item \texttt{boot()} \\
38 Commands to be run at boot time. Defaults to \texttt{start()}
39
40 \item \texttt{restart()} \\
41 Restart your service. Defaults to \texttt{stop(); start()}
42
43 \item \texttt{reload()} \\
44 Reload the configuration files for your service. Defaults to \texttt{restart()}
45
46 \end{itemize}
47
48 You can also add custom commands by creating the appropriate functions and referencing them
49 in the \texttt{EXTRA\_COMMANDS} variable. Helptext is added in \texttt{EXTRA\_HELP}.
50
51 Example:
52
53 \begin{Verbatim}
54 status() {
55 # print the status info
56 }
57
58 EXTRA_COMMANDS="status"
59 EXTRA_HELP=" status Print the status of the service"
60 \end{Verbatim}
61
This page took 0.043038 seconds and 5 git commands to generate.