Initial import from FreeBSD RELENG_4:
[dragonfly.git] / share / man / man8 / rc.8
1 .\" Copyright (c) 1980, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)rc.8        8.2 (Berkeley) 12/11/93
33 .\" $FreeBSD: src/share/man/man8/rc.8,v 1.9.2.7 2002/08/23 16:57:42 schweikh Exp $
34 .\"
35 .Dd December 11, 1993
36 .Dt RC 8
37 .Os
38 .Sh NAME
39 .Nm rc
40 .Nd command scripts for auto\-reboot and daemon startup
41 .Sh SYNOPSIS
42 .Nm
43 .Nm rc.conf
44 .Nm rc.conf.local
45 .Nm rc.early
46 .Nm rc.d
47 .Nm rc.serial
48 .Nm rc.pccard
49 .Nm rc.network
50 .Nm rc.firewall
51 .Nm rc.atm
52 .Nm rc.<arch>
53 .Nm rc.local
54 .Nm rc.shutdown
55 .Sh DESCRIPTION
56 .Nm Rc
57 is the command script which controls the automatic reboot
58 (calling the other scripts) and
59 .Nm rc.local
60 is the script holding commands which are pertinent only
61 to a specific site.  Typically, the /usr/local/etc/rc.d
62 mechanism is used instead of rc.local these days but if
63 you do want to use rc.local, /etc/rc still supports it.
64 In this case, rc.local should source /etc/rc.conf and
65 contain additional custom startup code for your system.
66 .Nm Rc.conf
67 contains the global system configuration information referenced
68 by the rc files, while
69 .Nm rc.conf.local
70 contains the local system configuration.
71 See
72 .Xr rc.conf 5 .
73 .Pp
74 The
75 .Nm rc.d
76 directories contain scripts which will be automatically
77 executed at boot time and shutdown time.
78 At boot time,
79 the specified directories are processed immediately after
80 .Nm rc.local
81 is executed.
82 (See below for details on how to specify directories to check.)
83 At shutdown time,
84 the directories are processed by
85 .Nm rc.shutdown .
86 The following key points apply to the scripts within each directory:
87 .Pp
88 .Bl -bullet -compact
89 .It
90 Scripts are only executed if their
91 .Xr basename 1
92 matches the shell globbing pattern
93 .Pa *.sh ,
94 and they are executable.
95 Any other files or directories present within the directory are silently
96 ignored.
97 .It
98 When a script is executed at boot time, it is passed the string
99 .Dq start
100 as its first and only argument.
101 At shutdown time, it is passed the string
102 .Dq stop
103 as its first and only argument.
104 All
105 .Nm rc.d
106 scripts are expected to handle these arguments appropriately.
107 If no action needs to be taken at a given time
108 (either boot time or shutdown time)
109 the script should exit successfully and without producing an error message.
110 .It
111 The scripts within each directory are executed in lexicographical order.
112 If a specific order is required,
113 numbers may be used as a prefix to the existing filenames,
114 so for example
115 .Pa 100.foo
116 would be executed before
117 .Pa 200.bar ;
118 without the numeric prefixes the opposite would be true.
119 .El
120 .Pp
121 The output from each script is traditionally a space character,
122 followed by the name of the software package being started or shut down,
123 .Em without
124 a trailing newline character (see the
125 .Sx EXAMPLES
126 section).
127 .Pp
128 The system initialization scripts can execute scripts from multiple
129 .Nm rc.d
130 directories.
131 The default locations are
132 .Pa /usr/local/etc/rc.d
133 and
134 .Pa /usr/X11R6/etc/rc.d ,
135 but these may be overridden with the
136 .Va local_startup
137 .Xr rc.conf 5
138 variable.
139 .Pp
140 .Nm Rc.shutdown
141 is the command script which contains any necessary commands
142 to be executed as the system is shut down.
143 .Pp
144 When an automatic reboot is in progress,
145 .Nm
146 is invoked with the argument
147 .Em autoboot .
148 The first portion of
149 .Nm
150 runs an
151 .Xr fsck 8
152 with option
153 .Fl p
154 to ``preen'' all the disks of minor inconsistencies resulting
155 from the last system shutdown and to check for serious inconsistencies
156 caused by hardware or software failure.
157 If this auto-check and repair succeeds, then the second part of
158 .Nm
159 is run.
160 .Pp
161 The second part of
162 .Nm ,
163 which is run after an auto-reboot succeeds and also if
164 .Nm
165 is invoked when a single user shell terminates (see
166 .Xr init 8 ) ,
167 starts all the daemons on the system, preserves editor files
168 and clears the scratch directory
169 .Pa /tmp .
170 .Pp
171 .Nm Rc.early
172 is run very early in the startup process, immediately before the
173 filesystem check.
174 .Pp
175 .Nm Rc.serial
176 is used to set any special configurations for serial devices.
177 .Pp
178 .Nm Rc.pccard
179 is used to enable PC-cards.
180 .Pp
181 .Nm Rc.network
182 is used to start the network.
183 The network is started in three passes.
184 The first pass sets the hostname and domainname, configures the network
185 interfaces, turns on any IP firewall rules, and starts routing.
186 The second pass starts most of the network related daemons.
187 The third pass starts NFS, amd, rwhod, Kerberos and
188 the multicast routing daemon.
189 .Pp
190 .Nm Rc.firewall
191 is used to configure rules for the kernel based firewall
192 service.
193 It has several possible options:
194 .Pp
195 .Bl -tag -width "fBfilename" -compact -offset indent
196 .It open
197 will allow anyone in.
198 .It client
199 will try to protect just this machine.
200 .It simple
201 will try to protect a whole network.
202 .It closed
203 totally disables IP services except via lo0 interface.
204 .It UNKNOWN
205 disables the loading of firewall rules.
206 .It filename
207 will load the rules in the given filename (full path required).
208 .El
209 .Pp
210 .Nm Rc.atm
211 is used to configure ATM network interfaces.
212 The interfaces are configured in three passes.
213 The first pass performs the initial interface configuration.
214 The second pass completes the interface configuration and defines PVCs and
215 permanent ATMARP entries.
216 The third pass starts any ATM daemons.
217 .Pp
218 .Nm Rc.<arch>
219 runs architecture specific programs.
220 .Pp
221 .Nm Rc.local
222 is executed after the scripts above, but before the rest of the
223 .Nm
224 file is completed.
225 In a default installation
226 .Nm rc.local
227 does not exist, but its contents will be executed if the file is created
228 by the administrator.
229 .Pp
230 Following tradition, the startup files reside in
231 .Pa /etc .
232 .Sh EXAMPLES
233 The following is a simple, hypothetical example of an
234 .Nm rc.d
235 script,
236 which would start a daemon at boot time,
237 and kill it at shutdown time.
238 .Bd -literal -offset indent
239 #!/bin/sh -
240 #
241 #    initialization/shutdown script for foobar package
242
243 case "$1" in
244 start)
245         /usr/local/sbin/foo -d && echo -n ' foo'
246         ;;
247 stop)
248         kill `cat /var/run/foo.pid` && echo -n ' foo'
249         ;;
250 *)
251         echo "unknown option: $1 - should be 'start' or 'stop'" >&2
252         ;;
253 esac
254 .Ed
255 .Pp
256 As all processes are killed by
257 .Xr init 8
258 at shutdown, the explicit
259 .Xr kill 1
260 is unnecessary, but is often included.
261 .Sh SEE ALSO
262 .Xr kill 1 ,
263 .Xr rc.conf 5 ,
264 .Xr init 8 ,
265 .Xr reboot 8 ,
266 .Xr savecore 8
267 .Sh HISTORY
268 The
269 .Nm
270 command appeared in
271 .Bx 4.0 .