Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[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 .\" $DragonFly: src/share/man/man8/rc.8,v 1.2 2003/06/17 04:37:01 dillon Exp $
35 .\"
36 .Dd December 11, 1993
37 .Dt RC 8
38 .Os
39 .Sh NAME
40 .Nm rc
41 .Nd command scripts for auto\-reboot and daemon startup
42 .Sh SYNOPSIS
43 .Nm
44 .Nm rc.conf
45 .Nm rc.conf.local
46 .Nm rc.early
47 .Nm rc.d
48 .Nm rc.serial
49 .Nm rc.pccard
50 .Nm rc.network
51 .Nm rc.firewall
52 .Nm rc.atm
53 .Nm rc.<arch>
54 .Nm rc.local
55 .Nm rc.shutdown
56 .Sh DESCRIPTION
57 .Nm Rc
58 is the command script which controls the automatic reboot
59 (calling the other scripts) and
60 .Nm rc.local
61 is the script holding commands which are pertinent only
62 to a specific site.  Typically, the /usr/local/etc/rc.d
63 mechanism is used instead of rc.local these days but if
64 you do want to use rc.local, /etc/rc still supports it.
65 In this case, rc.local should source /etc/rc.conf and
66 contain additional custom startup code for your system.
67 .Nm Rc.conf
68 contains the global system configuration information referenced
69 by the rc files, while
70 .Nm rc.conf.local
71 contains the local system configuration.
72 See
73 .Xr rc.conf 5 .
74 .Pp
75 The
76 .Nm rc.d
77 directories contain scripts which will be automatically
78 executed at boot time and shutdown time.
79 At boot time,
80 the specified directories are processed immediately after
81 .Nm rc.local
82 is executed.
83 (See below for details on how to specify directories to check.)
84 At shutdown time,
85 the directories are processed by
86 .Nm rc.shutdown .
87 The following key points apply to the scripts within each directory:
88 .Pp
89 .Bl -bullet -compact
90 .It
91 Scripts are only executed if their
92 .Xr basename 1
93 matches the shell globbing pattern
94 .Pa *.sh ,
95 and they are executable.
96 Any other files or directories present within the directory are silently
97 ignored.
98 .It
99 When a script is executed at boot time, it is passed the string
100 .Dq start
101 as its first and only argument.
102 At shutdown time, it is passed the string
103 .Dq stop
104 as its first and only argument.
105 All
106 .Nm rc.d
107 scripts are expected to handle these arguments appropriately.
108 If no action needs to be taken at a given time
109 (either boot time or shutdown time)
110 the script should exit successfully and without producing an error message.
111 .It
112 The scripts within each directory are executed in lexicographical order.
113 If a specific order is required,
114 numbers may be used as a prefix to the existing filenames,
115 so for example
116 .Pa 100.foo
117 would be executed before
118 .Pa 200.bar ;
119 without the numeric prefixes the opposite would be true.
120 .El
121 .Pp
122 The output from each script is traditionally a space character,
123 followed by the name of the software package being started or shut down,
124 .Em without
125 a trailing newline character (see the
126 .Sx EXAMPLES
127 section).
128 .Pp
129 The system initialization scripts can execute scripts from multiple
130 .Nm rc.d
131 directories.
132 The default locations are
133 .Pa /usr/local/etc/rc.d
134 and
135 .Pa /usr/X11R6/etc/rc.d ,
136 but these may be overridden with the
137 .Va local_startup
138 .Xr rc.conf 5
139 variable.
140 .Pp
141 .Nm Rc.shutdown
142 is the command script which contains any necessary commands
143 to be executed as the system is shut down.
144 .Pp
145 When an automatic reboot is in progress,
146 .Nm
147 is invoked with the argument
148 .Em autoboot .
149 The first portion of
150 .Nm
151 runs an
152 .Xr fsck 8
153 with option
154 .Fl p
155 to ``preen'' all the disks of minor inconsistencies resulting
156 from the last system shutdown and to check for serious inconsistencies
157 caused by hardware or software failure.
158 If this auto-check and repair succeeds, then the second part of
159 .Nm
160 is run.
161 .Pp
162 The second part of
163 .Nm ,
164 which is run after an auto-reboot succeeds and also if
165 .Nm
166 is invoked when a single user shell terminates (see
167 .Xr init 8 ) ,
168 starts all the daemons on the system, preserves editor files
169 and clears the scratch directory
170 .Pa /tmp .
171 .Pp
172 .Nm Rc.early
173 is run very early in the startup process, immediately before the
174 filesystem check.
175 .Pp
176 .Nm Rc.serial
177 is used to set any special configurations for serial devices.
178 .Pp
179 .Nm Rc.pccard
180 is used to enable PC-cards.
181 .Pp
182 .Nm Rc.network
183 is used to start the network.
184 The network is started in three passes.
185 The first pass sets the hostname and domainname, configures the network
186 interfaces, turns on any IP firewall rules, and starts routing.
187 The second pass starts most of the network related daemons.
188 The third pass starts NFS, amd, rwhod, Kerberos and
189 the multicast routing daemon.
190 .Pp
191 .Nm Rc.firewall
192 is used to configure rules for the kernel based firewall
193 service.
194 It has several possible options:
195 .Pp
196 .Bl -tag -width "fBfilename" -compact -offset indent
197 .It open
198 will allow anyone in.
199 .It client
200 will try to protect just this machine.
201 .It simple
202 will try to protect a whole network.
203 .It closed
204 totally disables IP services except via lo0 interface.
205 .It UNKNOWN
206 disables the loading of firewall rules.
207 .It filename
208 will load the rules in the given filename (full path required).
209 .El
210 .Pp
211 .Nm Rc.atm
212 is used to configure ATM network interfaces.
213 The interfaces are configured in three passes.
214 The first pass performs the initial interface configuration.
215 The second pass completes the interface configuration and defines PVCs and
216 permanent ATMARP entries.
217 The third pass starts any ATM daemons.
218 .Pp
219 .Nm Rc.<arch>
220 runs architecture specific programs.
221 .Pp
222 .Nm Rc.local
223 is executed after the scripts above, but before the rest of the
224 .Nm
225 file is completed.
226 In a default installation
227 .Nm rc.local
228 does not exist, but its contents will be executed if the file is created
229 by the administrator.
230 .Pp
231 Following tradition, the startup files reside in
232 .Pa /etc .
233 .Sh EXAMPLES
234 The following is a simple, hypothetical example of an
235 .Nm rc.d
236 script,
237 which would start a daemon at boot time,
238 and kill it at shutdown time.
239 .Bd -literal -offset indent
240 #!/bin/sh -
241 #
242 #    initialization/shutdown script for foobar package
243
244 case "$1" in
245 start)
246         /usr/local/sbin/foo -d && echo -n ' foo'
247         ;;
248 stop)
249         kill `cat /var/run/foo.pid` && echo -n ' foo'
250         ;;
251 *)
252         echo "unknown option: $1 - should be 'start' or 'stop'" >&2
253         ;;
254 esac
255 .Ed
256 .Pp
257 As all processes are killed by
258 .Xr init 8
259 at shutdown, the explicit
260 .Xr kill 1
261 is unnecessary, but is often included.
262 .Sh SEE ALSO
263 .Xr kill 1 ,
264 .Xr rc.conf 5 ,
265 .Xr init 8 ,
266 .Xr reboot 8 ,
267 .Xr savecore 8
268 .Sh HISTORY
269 The
270 .Nm
271 command appeared in
272 .Bx 4.0 .