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