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