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