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