xref: /freebsd/share/man/man8/rc.8 (revision 8d74f63d1eeb54b46fd5063644e170fc2333b5cd)
1afe61c15SRodney W. Grimes.\" Copyright (c) 1980, 1991, 1993
2afe61c15SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3afe61c15SRodney W. Grimes.\"
4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions
6afe61c15SRodney W. Grimes.\" are met:
7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
8afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
10afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
11afe61c15SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12afe61c15SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
13afe61c15SRodney W. Grimes.\"    must display the following acknowledgement:
14afe61c15SRodney W. Grimes.\"	This product includes software developed by the University of
15afe61c15SRodney W. Grimes.\"	California, Berkeley and its contributors.
16afe61c15SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
17afe61c15SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
18afe61c15SRodney W. Grimes.\"    without specific prior written permission.
19afe61c15SRodney W. Grimes.\"
20afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23afe61c15SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30afe61c15SRodney W. Grimes.\" SUCH DAMAGE.
31afe61c15SRodney W. Grimes.\"
32afe61c15SRodney W. Grimes.\"     @(#)rc.8	8.2 (Berkeley) 12/11/93
337f3dea24SPeter Wemm.\" $FreeBSD$
34afe61c15SRodney W. Grimes.\"
35afe61c15SRodney W. Grimes.Dd December 11, 1993
36afe61c15SRodney W. Grimes.Dt RC 8
373d45e180SRuslan Ermilov.Os
38afe61c15SRodney W. Grimes.Sh NAME
39afe61c15SRodney W. Grimes.Nm rc
40e4f980d3SJordan K. Hubbard.Nd command scripts for auto\-reboot and daemon startup
41afe61c15SRodney W. Grimes.Sh SYNOPSIS
424b66483fSRuslan Ermilov.Nm
43e4f980d3SJordan K. Hubbard.Nm rc.conf
44e4f980d3SJordan K. Hubbard.Nm rc.conf.local
45eb35eb26SCrist J. Clark.Nm rc.early
4691e06c00SBen Smithurst.Nm rc.d
47e4f980d3SJordan K. Hubbard.Nm rc.serial
48e4f980d3SJordan K. Hubbard.Nm rc.pccard
49e4f980d3SJordan K. Hubbard.Nm rc.network
50e4f980d3SJordan K. Hubbard.Nm rc.firewall
517d5c779cSPoul-Henning Kamp.Nm rc.atm
52e4f980d3SJordan K. Hubbard.Nm rc.<arch>
53afe61c15SRodney W. Grimes.Nm rc.local
54e4f980d3SJordan K. Hubbard.Nm rc.shutdown
55afe61c15SRodney W. Grimes.Sh DESCRIPTION
568d74f63dSPhilippe CharnierThe
578d74f63dSPhilippe Charnier.Nm
588d74f63dSPhilippe Charnierutility is the command script which controls the automatic reboot
59e4f980d3SJordan K. Hubbard(calling the other scripts) and
60afe61c15SRodney W. Grimes.Nm rc.local
61afe61c15SRodney W. Grimesis the script holding commands which are pertinent only
62f633e4c9SMatthew Dillonto a specific site.  Typically, the /usr/local/etc/rc.d
63f633e4c9SMatthew Dillonmechanism is used instead of rc.local these days but if
64f633e4c9SMatthew Dillonyou do want to use rc.local, /etc/rc still supports it.
65f633e4c9SMatthew DillonIn this case, rc.local should source /etc/rc.conf and
66f633e4c9SMatthew Dilloncontain additional custom startup code for your system.
678d74f63dSPhilippe CharnierThe
688d74f63dSPhilippe Charnier.Nm rc.conf
698d74f63dSPhilippe Charnierfile contains the global system configuration information referenced
70e4f980d3SJordan K. Hubbardby the rc files, while
71e4f980d3SJordan K. Hubbard.Nm rc.conf.local
726575e6daSRuslan Ermilovcontains the local system configuration.
736575e6daSRuslan ErmilovSee
746575e6daSRuslan Ermilov.Xr rc.conf 5 .
75e4f980d3SJordan K. Hubbard.Pp
7691e06c00SBen SmithurstThe
7791e06c00SBen Smithurst.Nm rc.d
7891e06c00SBen Smithurstdirectories contain scripts which will be automatically
7991e06c00SBen Smithurstexecuted at boot time and shutdown time.
8091e06c00SBen SmithurstAt boot time,
8191e06c00SBen Smithurstthe specified directories are processed immediately after
8291e06c00SBen Smithurst.Nm rc.local
8391e06c00SBen Smithurstis executed.
8491e06c00SBen Smithurst(See below for details on how to specify directories to check.)
8591e06c00SBen SmithurstAt shutdown time,
8691e06c00SBen Smithurstthe directories are processed by
8791e06c00SBen Smithurst.Nm rc.shutdown .
8891e06c00SBen SmithurstThe following key points apply to the scripts within each directory:
8991e06c00SBen Smithurst.Pp
9091e06c00SBen Smithurst.Bl -bullet -compact
9191e06c00SBen Smithurst.It
9291e06c00SBen SmithurstScripts are only executed if their
9391e06c00SBen Smithurst.Xr basename 1
9491e06c00SBen Smithurstmatches the shell globbing pattern
9591e06c00SBen Smithurst.Pa *.sh ,
9691e06c00SBen Smithurstand they are executable.
9791e06c00SBen SmithurstAny other files or directories present within the directory are silently
9891e06c00SBen Smithurstignored.
9991e06c00SBen Smithurst.It
10091e06c00SBen SmithurstWhen a script is executed at boot time, it is passed the string
10191e06c00SBen Smithurst.Dq start
10291e06c00SBen Smithurstas its first and only argument.
10391e06c00SBen SmithurstAt shutdown time, it is passed the string
10491e06c00SBen Smithurst.Dq stop
10591e06c00SBen Smithurstas its first and only argument.
10691e06c00SBen SmithurstAll
10791e06c00SBen Smithurst.Nm rc.d
10891e06c00SBen Smithurstscripts expected to handle these arguments appropriately.
10991e06c00SBen SmithurstIf no action needs to be taken at a given time
11091e06c00SBen Smithurst(either boot time or shutdown time)
11191e06c00SBen Smithurstthe script should exit successfully and without producing an error message.
11291e06c00SBen Smithurst.It
11391e06c00SBen SmithurstThe scripts within each directory are executed in lexicographical order.
11491e06c00SBen SmithurstIf a specific order is required,
11591e06c00SBen Smithurstnumbers may be used as a prefix to the existing filenames,
11691e06c00SBen Smithurstso for example
11791e06c00SBen Smithurst.Pa 100.foo
11891e06c00SBen Smithurstwould be executed before
11991e06c00SBen Smithurst.Pa 200.bar ;
12091e06c00SBen Smithurstwithout the numeric prefixes the opposite would be true.
12191e06c00SBen Smithurst.El
12291e06c00SBen Smithurst.Pp
12391e06c00SBen SmithurstThe output from each script is traditionally a space character,
12491e06c00SBen Smithurstfollowed by the name of the software package being started or shut down,
12591e06c00SBen Smithurst.Em without
12691e06c00SBen Smithursta trailing newline character (see the
12791e06c00SBen Smithurst.Sx EXAMPLES
12891e06c00SBen Smithurstsection).
12991e06c00SBen Smithurst.Pp
13091e06c00SBen SmithurstThe system initialization scripts can execute scripts from multiple
13191e06c00SBen Smithurst.Nm rc.d
13291e06c00SBen Smithurstdirectories.
13391e06c00SBen SmithurstThe default locations are
13491e06c00SBen Smithurst.Pa /usr/local/etc/rc.d
13591e06c00SBen Smithurstand
13691e06c00SBen Smithurst.Pa /usr/X11R6/etc/rc.d ,
13791e06c00SBen Smithurstbut these may be overridden with the
13891e06c00SBen Smithurst.Va local_startup
13991e06c00SBen Smithurst.Xr rc.conf 5
14091e06c00SBen Smithurstvariable.
14191e06c00SBen Smithurst.Pp
1428d74f63dSPhilippe CharnierThe
1438d74f63dSPhilippe Charnier.Nm rc.shutdown
1448d74f63dSPhilippe Charnierscript contains any necessary commands
145e4f980d3SJordan K. Hubbardto be executed as the system is shut down.
146afe61c15SRodney W. Grimes.Pp
147afe61c15SRodney W. GrimesWhen an automatic reboot is in progress,
1484b66483fSRuslan Ermilov.Nm
149afe61c15SRodney W. Grimesis invoked with the argument
150afe61c15SRodney W. Grimes.Em autoboot .
151afe61c15SRodney W. GrimesThe first portion of
1524b66483fSRuslan Ermilov.Nm
153afe61c15SRodney W. Grimesruns an
154afe61c15SRodney W. Grimes.Xr fsck 8
155afe61c15SRodney W. Grimeswith option
156afe61c15SRodney W. Grimes.Fl p
157afe61c15SRodney W. Grimesto ``preen'' all the disks of minor inconsistencies resulting
158afe61c15SRodney W. Grimesfrom the last system shutdown and to check for serious inconsistencies
159afe61c15SRodney W. Grimescaused by hardware or software failure.
160afe61c15SRodney W. GrimesIf this auto-check and repair succeeds, then the second part of
1614b66483fSRuslan Ermilov.Nm
162afe61c15SRodney W. Grimesis run.
163afe61c15SRodney W. Grimes.Pp
164afe61c15SRodney W. GrimesThe second part of
1654b66483fSRuslan Ermilov.Nm ,
166afe61c15SRodney W. Grimeswhich is run after an auto-reboot succeeds and also if
1674b66483fSRuslan Ermilov.Nm
168afe61c15SRodney W. Grimesis invoked when a single user shell terminates (see
169afe61c15SRodney W. Grimes.Xr init 8 ) ,
170afe61c15SRodney W. Grimesstarts all the daemons on the system, preserves editor files
171afe61c15SRodney W. Grimesand clears the scratch directory
172afe61c15SRodney W. Grimes.Pa /tmp .
173afe61c15SRodney W. Grimes.Pp
1748d74f63dSPhilippe CharnierThe
1758d74f63dSPhilippe Charnier.Nm rc.early
1768d74f63dSPhilippe Charnierscript is run very early in the startup process, immediately before the
177eb35eb26SCrist J. Clarkfilesystem check.
1786ee2a895SCrist J. Clark.Pp
1798d74f63dSPhilippe CharnierThe
1808d74f63dSPhilippe Charnier.Nm rc.serial
1818d74f63dSPhilippe Charnierscript is used to set any special configurations for serial devices.
182afe61c15SRodney W. Grimes.Pp
1838d74f63dSPhilippe CharnierThe
1848d74f63dSPhilippe Charnier.Nm rc.pccard
1858d74f63dSPhilippe Charnierscript is used to enable PC-cards.
186e4f980d3SJordan K. Hubbard.Pp
1878d74f63dSPhilippe CharnierThe
1888d74f63dSPhilippe Charnier.Nm rc.network
1898d74f63dSPhilippe Charnierscript is used to start the network.
190e4f980d3SJordan K. HubbardThe network is started in three passes.
191e4f980d3SJordan K. HubbardThe first pass sets the hostname and domainname, configures the network
192e4f980d3SJordan K. Hubbardinterfaces, turns on any IP firewall rules, and starts routing.
193e4f980d3SJordan K. HubbardThe second pass starts most of the network related daemons.
194e4f980d3SJordan K. HubbardThe third pass starts NFS, amd, rwhod, Kerberos and
195e4f980d3SJordan K. Hubbardthe multicast routing daemon.
196e4f980d3SJordan K. Hubbard.Pp
1978d74f63dSPhilippe CharnierThe
1988d74f63dSPhilippe Charnier.Nm rc.firewall
1998d74f63dSPhilippe Charnierscript is used to configure rules for the kernel based firewall
2001111b49cSSheldon Hearnservice.
2011111b49cSSheldon HearnIt has several possible options:
202e4f980d3SJordan K. Hubbard.Pp
203e4f980d3SJordan K. Hubbard.Bl -tag -width "fBfilename" -compact -offset indent
204e4f980d3SJordan K. Hubbard.It open
205e4f980d3SJordan K. Hubbardwill allow anyone in.
206e4f980d3SJordan K. Hubbard.It client
207e4f980d3SJordan K. Hubbardwill try to protect just this machine.
208e4f980d3SJordan K. Hubbard.It simple
209e4f980d3SJordan K. Hubbardwill try to protect a whole network.
210e4f980d3SJordan K. Hubbard.It closed
211e4f980d3SJordan K. Hubbardtotally disables IP services except via lo0 interface.
212e4f980d3SJordan K. Hubbard.It UNKNOWN
213e4f980d3SJordan K. Hubbarddisables the loading of firewall rules.
214e4f980d3SJordan K. Hubbard.It filename
215e4f980d3SJordan K. Hubbardwill load the rules in the given filename (full path required).
216e4f980d3SJordan K. Hubbard.El
217e4f980d3SJordan K. Hubbard.Pp
2188d74f63dSPhilippe CharnierThe
2198d74f63dSPhilippe Charnier.Nm rc.atm
2208d74f63dSPhilippe Charnierscript is used to configure ATM network interfaces.
2217d5c779cSPoul-Henning KampThe interfaces are configured in three passes.
2227d5c779cSPoul-Henning KampThe first pass performs the initial interface configuration.
2237d5c779cSPoul-Henning KampThe second pass completes the interface configuration and defines PVCs and
2247d5c779cSPoul-Henning Kamppermanent ATMARP entries.
2257d5c779cSPoul-Henning KampThe third pass starts any ATM daemons.
2267d5c779cSPoul-Henning Kamp.Pp
2278d74f63dSPhilippe CharnierThe
2288d74f63dSPhilippe Charnier.Nm rc.<arch>
2298d74f63dSPhilippe Charnierscript runs architecture specific programs.
230e4f980d3SJordan K. Hubbard.Pp
2318d74f63dSPhilippe CharnierThe
2328d74f63dSPhilippe Charnier.Nm rc.local
2338d74f63dSPhilippe Charnierscript is executed after the scripts above, but before the rest of the
2344b66483fSRuslan Ermilov.Nm
235e4f980d3SJordan K. Hubbardfile is completed.
23622d80076SAlexander LangerIn a default installation
237afe61c15SRodney W. Grimes.Nm rc.local
23822d80076SAlexander Langerdoes not exist, but its contents will be executed if the file is created
23922d80076SAlexander Langerby the administrator.
240e4f980d3SJordan K. Hubbard.Pp
241e4f980d3SJordan K. HubbardFollowing tradition, the startup files reside in
242afe61c15SRodney W. Grimes.Pa /etc .
24391e06c00SBen Smithurst.Sh EXAMPLES
24491e06c00SBen SmithurstThe following is a simple, hypothetical example of an
24591e06c00SBen Smithurst.Nm rc.d
24691e06c00SBen Smithurstscript,
24791e06c00SBen Smithurstwhich would start a daemon at boot time,
24891e06c00SBen Smithurstand kill it at shutdown time.
24991e06c00SBen Smithurst.Bd -literal -offset indent
25091e06c00SBen Smithurst#!/bin/sh -
25191e06c00SBen Smithurst#
25291e06c00SBen Smithurst#    initialization/shutdown script for foobar package
25391e06c00SBen Smithurst
25491e06c00SBen Smithurstcase "$1" in
25591e06c00SBen Smithurststart)
25691e06c00SBen Smithurst	/usr/local/sbin/foo -d && echo -n ' foo'
25791e06c00SBen Smithurst	;;
25891e06c00SBen Smithurststop)
25991e06c00SBen Smithurst	kill `cat /var/run/foo.pid` && echo -n ' foo'
26091e06c00SBen Smithurst	;;
26191e06c00SBen Smithurst*)
26291e06c00SBen Smithurst	echo "unknown option: $1 - should be 'start' or 'stop'" >&2
26391e06c00SBen Smithurst	;;
26491e06c00SBen Smithurstesac
26591e06c00SBen Smithurst.Ed
26691e06c00SBen Smithurst.Pp
26791e06c00SBen SmithurstAs all processes are killed by
26891e06c00SBen Smithurst.Xr init 8
26991e06c00SBen Smithurstat shutdown, the explicit
27091e06c00SBen Smithurst.Xr kill 1
27191e06c00SBen Smithurstis unnecessary, but is often included.
272afe61c15SRodney W. Grimes.Sh SEE ALSO
27391e06c00SBen Smithurst.Xr kill 1 ,
274e4f980d3SJordan K. Hubbard.Xr rc.conf 5 ,
275afe61c15SRodney W. Grimes.Xr init 8 ,
276afe61c15SRodney W. Grimes.Xr reboot 8 ,
277afe61c15SRodney W. Grimes.Xr savecore 8
278afe61c15SRodney W. Grimes.Sh HISTORY
279afe61c15SRodney W. GrimesThe
280afe61c15SRodney W. Grimes.Nm
2818d74f63dSPhilippe Charnierutility appeared in
282afe61c15SRodney W. Grimes.Bx 4.0 .
283