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 37afe61c15SRodney W. Grimes.Os BSD 4 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 4591e06c00SBen Smithurst.Nm rc.d 46e4f980d3SJordan K. Hubbard.Nm rc.serial 47e4f980d3SJordan K. Hubbard.Nm rc.pccard 48e4f980d3SJordan K. Hubbard.Nm rc.network 49e4f980d3SJordan K. Hubbard.Nm rc.firewall 507d5c779cSPoul-Henning Kamp.Nm rc.atm 51e4f980d3SJordan K. Hubbard.Nm rc.<arch> 52afe61c15SRodney W. Grimes.Nm rc.local 53e4f980d3SJordan K. Hubbard.Nm rc.shutdown 54afe61c15SRodney W. Grimes.Sh DESCRIPTION 55afe61c15SRodney W. Grimes.Nm Rc 56e4f980d3SJordan K. Hubbardis the command script which controls the automatic reboot 57e4f980d3SJordan K. Hubbard(calling the other scripts) and 58afe61c15SRodney W. Grimes.Nm rc.local 59afe61c15SRodney W. Grimesis the script holding commands which are pertinent only 60f633e4c9SMatthew Dillonto a specific site. Typically, the /usr/local/etc/rc.d 61f633e4c9SMatthew Dillonmechanism is used instead of rc.local these days but if 62f633e4c9SMatthew Dillonyou do want to use rc.local, /etc/rc still supports it. 63f633e4c9SMatthew DillonIn this case, rc.local should source /etc/rc.conf and 64f633e4c9SMatthew Dilloncontain additional custom startup code for your system. 65e4f980d3SJordan K. Hubbard.Nm Rc.conf 66e4f980d3SJordan K. Hubbardcontains the global system configuration information referenced 67e4f980d3SJordan K. Hubbardby the rc files, while 68e4f980d3SJordan K. Hubbard.Nm rc.conf.local 69ab327a82SMatthew Dilloncontains the local system configuration. See rc.conf(5) 70e4f980d3SJordan K. Hubbard.Pp 7191e06c00SBen SmithurstThe 7291e06c00SBen Smithurst.Nm rc.d 7391e06c00SBen Smithurstdirectories contain scripts which will be automatically 7491e06c00SBen Smithurstexecuted at boot time and shutdown time. 7591e06c00SBen SmithurstAt boot time, 7691e06c00SBen Smithurstthe specified directories are processed immediately after 7791e06c00SBen Smithurst.Nm rc.local 7891e06c00SBen Smithurstis executed. 7991e06c00SBen Smithurst(See below for details on how to specify directories to check.) 8091e06c00SBen SmithurstAt shutdown time, 8191e06c00SBen Smithurstthe directories are processed by 8291e06c00SBen Smithurst.Nm rc.shutdown . 8391e06c00SBen SmithurstThe following key points apply to the scripts within each directory: 8491e06c00SBen Smithurst.Pp 8591e06c00SBen Smithurst.Bl -bullet -compact 8691e06c00SBen Smithurst.It 8791e06c00SBen SmithurstScripts are only executed if their 8891e06c00SBen Smithurst.Xr basename 1 8991e06c00SBen Smithurstmatches the shell globbing pattern 9091e06c00SBen Smithurst.Pa *.sh , 9191e06c00SBen Smithurstand they are executable. 9291e06c00SBen SmithurstAny other files or directories present within the directory are silently 9391e06c00SBen Smithurstignored. 9491e06c00SBen Smithurst.It 9591e06c00SBen SmithurstWhen a script is executed at boot time, it is passed the string 9691e06c00SBen Smithurst.Dq start 9791e06c00SBen Smithurstas its first and only argument. 9891e06c00SBen SmithurstAt shutdown time, it is passed the string 9991e06c00SBen Smithurst.Dq stop 10091e06c00SBen Smithurstas its first and only argument. 10191e06c00SBen SmithurstAll 10291e06c00SBen Smithurst.Nm rc.d 10391e06c00SBen Smithurstscripts expected to handle these arguments appropriately. 10491e06c00SBen SmithurstIf no action needs to be taken at a given time 10591e06c00SBen Smithurst(either boot time or shutdown time) 10691e06c00SBen Smithurstthe script should exit successfully and without producing an error message. 10791e06c00SBen Smithurst.It 10891e06c00SBen SmithurstThe scripts within each directory are executed in lexicographical order. 10991e06c00SBen SmithurstIf a specific order is required, 11091e06c00SBen Smithurstnumbers may be used as a prefix to the existing filenames, 11191e06c00SBen Smithurstso for example 11291e06c00SBen Smithurst.Pa 100.foo 11391e06c00SBen Smithurstwould be executed before 11491e06c00SBen Smithurst.Pa 200.bar ; 11591e06c00SBen Smithurstwithout the numeric prefixes the opposite would be true. 11691e06c00SBen Smithurst.El 11791e06c00SBen Smithurst.Pp 11891e06c00SBen SmithurstThe output from each script is traditionally a space character, 11991e06c00SBen Smithurstfollowed by the name of the software package being started or shut down, 12091e06c00SBen Smithurst.Em without 12191e06c00SBen Smithursta trailing newline character (see the 12291e06c00SBen Smithurst.Sx EXAMPLES 12391e06c00SBen Smithurstsection). 12491e06c00SBen Smithurst.Pp 12591e06c00SBen SmithurstThe system initialization scripts can execute scripts from multiple 12691e06c00SBen Smithurst.Nm rc.d 12791e06c00SBen Smithurstdirectories. 12891e06c00SBen SmithurstThe default locations are 12991e06c00SBen Smithurst.Pa /usr/local/etc/rc.d 13091e06c00SBen Smithurstand 13191e06c00SBen Smithurst.Pa /usr/X11R6/etc/rc.d , 13291e06c00SBen Smithurstbut these may be overridden with the 13391e06c00SBen Smithurst.Va local_startup 13491e06c00SBen Smithurst.Xr rc.conf 5 13591e06c00SBen Smithurstvariable. 13691e06c00SBen Smithurst.Pp 137e4f980d3SJordan K. Hubbard.Nm Rc.shutdown 138e4f980d3SJordan K. Hubbardis the command script which contains any necessary commands 139e4f980d3SJordan K. Hubbardto be executed as the system is shut down. 140afe61c15SRodney W. Grimes.Pp 141afe61c15SRodney W. GrimesWhen an automatic reboot is in progress, 1424b66483fSRuslan Ermilov.Nm 143afe61c15SRodney W. Grimesis invoked with the argument 144afe61c15SRodney W. Grimes.Em autoboot . 145afe61c15SRodney W. GrimesThe first portion of 1464b66483fSRuslan Ermilov.Nm 147afe61c15SRodney W. Grimesruns an 148afe61c15SRodney W. Grimes.Xr fsck 8 149afe61c15SRodney W. Grimeswith option 150afe61c15SRodney W. Grimes.Fl p 151afe61c15SRodney W. Grimesto ``preen'' all the disks of minor inconsistencies resulting 152afe61c15SRodney W. Grimesfrom the last system shutdown and to check for serious inconsistencies 153afe61c15SRodney W. Grimescaused by hardware or software failure. 154afe61c15SRodney W. GrimesIf this auto-check and repair succeeds, then the second part of 1554b66483fSRuslan Ermilov.Nm 156afe61c15SRodney W. Grimesis run. 157afe61c15SRodney W. Grimes.Pp 158afe61c15SRodney W. GrimesThe second part of 1594b66483fSRuslan Ermilov.Nm , 160afe61c15SRodney W. Grimeswhich is run after an auto-reboot succeeds and also if 1614b66483fSRuslan Ermilov.Nm 162afe61c15SRodney W. Grimesis invoked when a single user shell terminates (see 163afe61c15SRodney W. Grimes.Xr init 8 ) , 164afe61c15SRodney W. Grimesstarts all the daemons on the system, preserves editor files 165afe61c15SRodney W. Grimesand clears the scratch directory 166afe61c15SRodney W. Grimes.Pa /tmp . 167afe61c15SRodney W. Grimes.Pp 168e4f980d3SJordan K. Hubbard.Nm Rc.serial 169e4f980d3SJordan K. Hubbardis used to set any special configurations for serial devices. 170afe61c15SRodney W. Grimes.Pp 171e4f980d3SJordan K. Hubbard.Nm Rc.pccard 172e4f980d3SJordan K. Hubbardis used to enable PC-cards. 173e4f980d3SJordan K. Hubbard.Pp 174e4f980d3SJordan K. Hubbard.Nm Rc.network 175e4f980d3SJordan K. Hubbardis used to start the network. 176e4f980d3SJordan K. HubbardThe network is started in three passes. 177e4f980d3SJordan K. HubbardThe first pass sets the hostname and domainname, configures the network 178e4f980d3SJordan K. Hubbardinterfaces, turns on any IP firewall rules, and starts routing. 179e4f980d3SJordan K. HubbardThe second pass starts most of the network related daemons. 180e4f980d3SJordan K. HubbardThe third pass starts NFS, amd, rwhod, Kerberos and 181e4f980d3SJordan K. Hubbardthe multicast routing daemon. 182e4f980d3SJordan K. Hubbard.Pp 183e4f980d3SJordan K. Hubbard.Nm Rc.firewall 184e4f980d3SJordan K. Hubbardis used to configure rules for the kernel based firewall 1851111b49cSSheldon Hearnservice. 1861111b49cSSheldon HearnIt has several possible options: 187e4f980d3SJordan K. Hubbard.Pp 188e4f980d3SJordan K. Hubbard.Bl -tag -width "fBfilename" -compact -offset indent 189e4f980d3SJordan K. Hubbard.It open 190e4f980d3SJordan K. Hubbardwill allow anyone in. 191e4f980d3SJordan K. Hubbard.It client 192e4f980d3SJordan K. Hubbardwill try to protect just this machine. 193e4f980d3SJordan K. Hubbard.It simple 194e4f980d3SJordan K. Hubbardwill try to protect a whole network. 195e4f980d3SJordan K. Hubbard.It closed 196e4f980d3SJordan K. Hubbardtotally disables IP services except via lo0 interface. 197e4f980d3SJordan K. Hubbard.It UNKNOWN 198e4f980d3SJordan K. Hubbarddisables the loading of firewall rules. 199e4f980d3SJordan K. Hubbard.It filename 200e4f980d3SJordan K. Hubbardwill load the rules in the given filename (full path required). 201e4f980d3SJordan K. Hubbard.El 202e4f980d3SJordan K. Hubbard.Pp 2037d5c779cSPoul-Henning Kamp.Nm Rc.atm 2047d5c779cSPoul-Henning Kampis used to configure ATM network interfaces. 2057d5c779cSPoul-Henning KampThe interfaces are configured in three passes. 2067d5c779cSPoul-Henning KampThe first pass performs the initial interface configuration. 2077d5c779cSPoul-Henning KampThe second pass completes the interface configuration and defines PVCs and 2087d5c779cSPoul-Henning Kamppermanent ATMARP entries. 2097d5c779cSPoul-Henning KampThe third pass starts any ATM daemons. 2107d5c779cSPoul-Henning Kamp.Pp 211e4f980d3SJordan K. Hubbard.Nm Rc.<arch> 212e4f980d3SJordan K. Hubbardruns architecture specific programs. 213e4f980d3SJordan K. Hubbard.Pp 214e4f980d3SJordan K. Hubbard.Nm Rc.local 215e4f980d3SJordan K. Hubbardis executed after the scripts above, but before the rest of the 2164b66483fSRuslan Ermilov.Nm 217e4f980d3SJordan K. Hubbardfile is completed. 21822d80076SAlexander LangerIn a default installation 219afe61c15SRodney W. Grimes.Nm rc.local 22022d80076SAlexander Langerdoes not exist, but its contents will be executed if the file is created 22122d80076SAlexander Langerby the administrator. 222e4f980d3SJordan K. Hubbard.Pp 223e4f980d3SJordan K. HubbardFollowing tradition, the startup files reside in 224afe61c15SRodney W. Grimes.Pa /etc . 22591e06c00SBen Smithurst.Sh EXAMPLES 22691e06c00SBen SmithurstThe following is a simple, hypothetical example of an 22791e06c00SBen Smithurst.Nm rc.d 22891e06c00SBen Smithurstscript, 22991e06c00SBen Smithurstwhich would start a daemon at boot time, 23091e06c00SBen Smithurstand kill it at shutdown time. 23191e06c00SBen Smithurst.Bd -literal -offset indent 23291e06c00SBen Smithurst#!/bin/sh - 23391e06c00SBen Smithurst# 23491e06c00SBen Smithurst# initialization/shutdown script for foobar package 23591e06c00SBen Smithurst 23691e06c00SBen Smithurstcase "$1" in 23791e06c00SBen Smithurststart) 23891e06c00SBen Smithurst /usr/local/sbin/foo -d && echo -n ' foo' 23991e06c00SBen Smithurst ;; 24091e06c00SBen Smithurststop) 24191e06c00SBen Smithurst kill `cat /var/run/foo.pid` && echo -n ' foo' 24291e06c00SBen Smithurst ;; 24391e06c00SBen Smithurst*) 24491e06c00SBen Smithurst echo "unknown option: $1 - should be 'start' or 'stop'" >&2 24591e06c00SBen Smithurst ;; 24691e06c00SBen Smithurstesac 24791e06c00SBen Smithurst.Ed 24891e06c00SBen Smithurst.Pp 24991e06c00SBen SmithurstAs all processes are killed by 25091e06c00SBen Smithurst.Xr init 8 25191e06c00SBen Smithurstat shutdown, the explicit 25291e06c00SBen Smithurst.Xr kill 1 25391e06c00SBen Smithurstis unnecessary, but is often included. 254afe61c15SRodney W. Grimes.Sh SEE ALSO 25591e06c00SBen Smithurst.Xr kill 1 , 256e4f980d3SJordan K. Hubbard.Xr rc.conf 5 , 257afe61c15SRodney W. Grimes.Xr init 8 , 258afe61c15SRodney W. Grimes.Xr reboot 8 , 259afe61c15SRodney W. Grimes.Xr savecore 8 260afe61c15SRodney W. Grimes.Sh HISTORY 261afe61c15SRodney W. GrimesThe 262afe61c15SRodney W. Grimes.Nm 263afe61c15SRodney W. Grimescommand appeared in 264afe61c15SRodney W. Grimes.Bx 4.0 . 265