1afe61c15SRodney W. Grimes.\" Copyright (c) 1980, 1991, 1993 2afe61c15SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 3afe61c15SRodney W. Grimes.\" 454e347fbSGordon Tetlow.\" Portions of this manual page are Copyrighted by 554e347fbSGordon Tetlow.\" The NetBSD Foundation. 654e347fbSGordon Tetlow.\" 7afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 8afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions 9afe61c15SRodney W. Grimes.\" are met: 10afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 11afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 12afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 13afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 14afe61c15SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 15afe61c15SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 16afe61c15SRodney W. Grimes.\" must display the following acknowledgement: 17afe61c15SRodney W. Grimes.\" This product includes software developed by the University of 18afe61c15SRodney W. Grimes.\" California, Berkeley and its contributors. 19afe61c15SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 20afe61c15SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 21afe61c15SRodney W. Grimes.\" without specific prior written permission. 22afe61c15SRodney W. Grimes.\" 23afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26afe61c15SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33afe61c15SRodney W. Grimes.\" SUCH DAMAGE. 34afe61c15SRodney W. Grimes.\" 35afe61c15SRodney W. Grimes.\" @(#)rc.8 8.2 (Berkeley) 12/11/93 367f3dea24SPeter Wemm.\" $FreeBSD$ 37afe61c15SRodney W. Grimes.\" 38*c86072f5SDoug Barton.Dd January 14, 2012 39afe61c15SRodney W. Grimes.Dt RC 8 403d45e180SRuslan Ermilov.Os 41afe61c15SRodney W. Grimes.Sh NAME 42afe61c15SRodney W. Grimes.Nm rc 43d962d52aSRuslan Ermilov.Nd command scripts for auto-reboot and daemon startup 44afe61c15SRodney W. Grimes.Sh SYNOPSIS 454b66483fSRuslan Ermilov.Nm 46e4f980d3SJordan K. Hubbard.Nm rc.conf 47e4f980d3SJordan K. Hubbard.Nm rc.conf.local 48d962d52aSRuslan Ermilov.Nm rc.d/ 49e4f980d3SJordan K. Hubbard.Nm rc.firewall 50afe61c15SRodney W. Grimes.Nm rc.local 51e4f980d3SJordan K. Hubbard.Nm rc.shutdown 5254e347fbSGordon Tetlow.Nm rc.subr 53afe61c15SRodney W. Grimes.Sh DESCRIPTION 548d74f63dSPhilippe CharnierThe 558d74f63dSPhilippe Charnier.Nm 5654e347fbSGordon Tetlowutility is the command script which controls the automatic boot process 5754e347fbSGordon Tetlowafter being called by 5854e347fbSGordon Tetlow.Xr init 8 . 5954e347fbSGordon TetlowThe 60afe61c15SRodney W. Grimes.Nm rc.local 6154e347fbSGordon Tetlowscript contains commands which are pertinent only 62d962d52aSRuslan Ermilovto a specific site. 63d962d52aSRuslan ErmilovTypically, the 64d962d52aSRuslan Ermilov.Pa /usr/local/etc/rc.d/ 6554e347fbSGordon Tetlowmechanism is used instead of 6654e347fbSGordon Tetlow.Nm rc.local 6754e347fbSGordon Tetlowthese days but if 6854e347fbSGordon Tetlowyou want to use 69d962d52aSRuslan Ermilov.Nm rc.local , 70d962d52aSRuslan Ermilovit is still supported. 71d962d52aSRuslan ErmilovIn this case, it should source 72d962d52aSRuslan Ermilov.Pa /etc/rc.conf 7354e347fbSGordon Tetlowand contain additional custom startup code for your system. 7454e347fbSGordon TetlowThe best way to handle 75d962d52aSRuslan Ermilov.Nm rc.local , 7654e347fbSGordon Tetlowhowever, is to separate it out into 77d962d52aSRuslan Ermilov.Nm rc.d/ 78d962d52aSRuslan Ermilovstyle scripts and place them under 79d962d52aSRuslan Ermilov.Pa /usr/local/etc/rc.d/ . 808d74f63dSPhilippe CharnierThe 818d74f63dSPhilippe Charnier.Nm rc.conf 828d74f63dSPhilippe Charnierfile contains the global system configuration information referenced 8354e347fbSGordon Tetlowby the startup scripts, while 84e4f980d3SJordan K. Hubbard.Nm rc.conf.local 856575e6daSRuslan Ermilovcontains the local system configuration. 866575e6daSRuslan ErmilovSee 8754e347fbSGordon Tetlow.Xr rc.conf 5 8854e347fbSGordon Tetlowfor more information. 89e4f980d3SJordan K. Hubbard.Pp 9091e06c00SBen SmithurstThe 91d962d52aSRuslan Ermilov.Nm rc.d/ 9291e06c00SBen Smithurstdirectories contain scripts which will be automatically 9391e06c00SBen Smithurstexecuted at boot time and shutdown time. 94d962d52aSRuslan Ermilov.Ss Operation of Nm 9554e347fbSGordon Tetlow.Bl -enum 9654e347fbSGordon Tetlow.It 9754e347fbSGordon TetlowIf autobooting, set 98d962d52aSRuslan Ermilov.Va autoboot Ns = Ns Li yes 9954e347fbSGordon Tetlowand enable a flag 100d962d52aSRuslan Ermilov.Pq Va rc_fast Ns = Ns Li yes , 10154e347fbSGordon Tetlowwhich prevents the 102d962d52aSRuslan Ermilov.Nm rc.d/ 10354e347fbSGordon Tetlowscripts from performing the check for already running processes 10454e347fbSGordon Tetlow(thus speeding up the boot process). 10554e347fbSGordon TetlowThis 106d962d52aSRuslan Ermilov.Va rc_fast Ns = Ns Li yes 107d962d52aSRuslan Ermilovspeedup will not occur when 10854e347fbSGordon Tetlow.Nm 10954e347fbSGordon Tetlowis started up after exiting the single-user shell. 11054e347fbSGordon Tetlow.It 1119eb99781SDoug BartonDetermine whether the system is booting diskless, 1129eb99781SDoug Bartonand if so run the 1139eb99781SDoug Barton.Pa /etc/rc.initdiskless 1149eb99781SDoug Bartonscript. 1159eb99781SDoug Barton.It 1169eb99781SDoug BartonSource 1179eb99781SDoug Barton.Pa /etc/rc.subr 1189eb99781SDoug Bartonto load various 1199eb99781SDoug Barton.Xr rc.subr 8 1209eb99781SDoug Bartonshell functions to use. 1219eb99781SDoug Barton.It 1229eb99781SDoug BartonLoad the configuration files. 1239eb99781SDoug Barton.It 1249eb99781SDoug BartonDetermine if booting in a jail, 1259eb99781SDoug Bartonand add 12681ae4b8dSRuslan Ermilov.Dq Li nojail 1279eb99781SDoug Bartonto the list of KEYWORDS to skip in 1289eb99781SDoug Barton.Xr rcorder 8 . 1299eb99781SDoug Barton.It 13054e347fbSGordon TetlowInvoke 13154e347fbSGordon Tetlow.Xr rcorder 8 13254e347fbSGordon Tetlowto order the files in 13354e347fbSGordon Tetlow.Pa /etc/rc.d/ 13454e347fbSGordon Tetlowthat do not have a 135d962d52aSRuslan Ermilov.Dq Li nostart 1369eb99781SDoug BartonKEYWORD (refer to 137d962d52aSRuslan Ermilov.Xr rcorder 8 Ns 's 13854e347fbSGordon Tetlow.Fl s 1399eb99781SDoug Bartonflag). 14054e347fbSGordon Tetlow.It 141d962d52aSRuslan ErmilovCall each script in turn using 142d962d52aSRuslan Ermilov.Fn run_rc_script 143d962d52aSRuslan Ermilov(from 14454e347fbSGordon Tetlow.Xr rc.subr 8 ) , 14554e347fbSGordon Tetlowwhich sets 146d962d52aSRuslan Ermilov.Va $1 14754e347fbSGordon Tetlowto 148d962d52aSRuslan Ermilov.Dq Li start , 14954e347fbSGordon Tetlowand sources the script in a subshell. 15054e347fbSGordon TetlowIf the script has a 151d962d52aSRuslan Ermilov.Pa .sh 15254e347fbSGordon Tetlowsuffix then it is sourced directly into the current shell. 1539eb99781SDoug BartonStop processing when the script that is the value of the 1549eb99781SDoug Barton.Va $early_late_divider 1559eb99781SDoug Bartonhas been run. 1569eb99781SDoug Barton.It 1579eb99781SDoug BartonRe-run 1589eb99781SDoug Barton.Xr rcorder 8 , 1599eb99781SDoug Bartonthis time including the scripts in the 1609eb99781SDoug Barton.Va $local_startup 1619eb99781SDoug Bartondirectories. 1629eb99781SDoug BartonIgnore everything up to the 1639eb99781SDoug Barton.Va $early_late_divider , 1649eb99781SDoug Bartonthen start executing the scripts as described above. 16554e347fbSGordon Tetlow.El 166d962d52aSRuslan Ermilov.Ss Operation of Nm rc.shutdown 16754e347fbSGordon Tetlow.Bl -enum 16854e347fbSGordon Tetlow.It 16954e347fbSGordon TetlowSource 17054e347fbSGordon Tetlow.Pa /etc/rc.subr 17154e347fbSGordon Tetlowto load various 17254e347fbSGordon Tetlow.Xr rc.subr 8 17354e347fbSGordon Tetlowshell functions to use. 17454e347fbSGordon Tetlow.It 1759eb99781SDoug BartonLoad the configuration files. 1769eb99781SDoug Barton.It 17754e347fbSGordon TetlowInvoke 17854e347fbSGordon Tetlow.Xr rcorder 8 17954e347fbSGordon Tetlowto order the files in 18054e347fbSGordon Tetlow.Pa /etc/rc.d/ 1819eb99781SDoug Bartonand the 1829eb99781SDoug Barton.Va $local_startup 1839eb99781SDoug Bartondirectories 18454e347fbSGordon Tetlowthat have a 185d962d52aSRuslan Ermilov.Dq Li shutdown 1869eb99781SDoug BartonKEYWORD (refer to 187d962d52aSRuslan Ermilov.Xr rcorder 8 Ns 's 18854e347fbSGordon Tetlow.Fl k 18954e347fbSGordon Tetlowflag), 190d962d52aSRuslan Ermilovreverse that order, and assign the result to a variable. 19154e347fbSGordon Tetlow.It 192d962d52aSRuslan ErmilovCall each script in turn using 193d962d52aSRuslan Ermilov.Fn run_rc_script 194d962d52aSRuslan Ermilov(from 19554e347fbSGordon Tetlow.Xr rc.subr 8 ) , 19654e347fbSGordon Tetlowwhich sets 197d962d52aSRuslan Ermilov.Va $1 19854e347fbSGordon Tetlowto 199d962d52aSRuslan Ermilov.Dq Li stop , 20054e347fbSGordon Tetlowand sources the script in a subshell. 20154e347fbSGordon TetlowIf the script has a 202d962d52aSRuslan Ermilov.Pa .sh 20354e347fbSGordon Tetlowsuffix then it is sourced directly into the current shell. 20454e347fbSGordon Tetlow.El 205d962d52aSRuslan Ermilov.Ss Contents of Nm rc.d/ 20654e347fbSGordon Tetlow.Nm rc.d/ 20754e347fbSGordon Tetlowis located in 208d962d52aSRuslan Ermilov.Pa /etc/rc.d/ . 20954e347fbSGordon TetlowThe following file naming conventions are currently used in 21054e347fbSGordon Tetlow.Nm rc.d/ : 211d962d52aSRuslan Ermilov.Bl -tag -width ".Pa ALLUPPERCASE" -offset indent 21254e347fbSGordon Tetlow.It Pa ALLUPPERCASE 21354e347fbSGordon TetlowScripts that are 214d962d52aSRuslan Ermilov.Dq placeholders 21554e347fbSGordon Tetlowto ensure that certain operations are performed before others. 21654e347fbSGordon TetlowIn order of startup, these are: 217d962d52aSRuslan Ermilov.Bl -tag -width ".Pa NETWORKING" 21854e347fbSGordon Tetlow.It Pa NETWORKING 21954e347fbSGordon TetlowEnsure basic network services are running, including general 2209eb99781SDoug Bartonnetwork configuration. 22154e347fbSGordon Tetlow.It Pa SERVERS 2229eb99781SDoug BartonEnsure basic services 22354e347fbSGordon Tetlowexist for services that start early (such as 22454e347fbSGordon Tetlow.Pa named ) , 225d962d52aSRuslan Ermilovbecause they are required by 22654e347fbSGordon Tetlow.Pa DAEMON 22754e347fbSGordon Tetlowbelow. 22854e347fbSGordon Tetlow.It Pa DAEMON 22954e347fbSGordon TetlowCheck-point before all general purpose daemons such as 23054e347fbSGordon Tetlow.Pa lpd 23154e347fbSGordon Tetlowand 23254e347fbSGordon Tetlow.Pa ntpd . 23354e347fbSGordon Tetlow.It Pa LOGIN 23454e347fbSGordon TetlowCheck-point before user login services 23554e347fbSGordon Tetlow.Pa ( inetd 23654e347fbSGordon Tetlowand 23754e347fbSGordon Tetlow.Pa sshd ) , 23854e347fbSGordon Tetlowas well as services which might run commands as users 23954e347fbSGordon Tetlow.Pa ( cron 24054e347fbSGordon Tetlowand 24154e347fbSGordon Tetlow.Pa sendmail ) . 24254e347fbSGordon Tetlow.El 24354e347fbSGordon Tetlow.It Pa foo.sh 24454e347fbSGordon TetlowScripts that are to be sourced into the current shell rather than a subshell 24554e347fbSGordon Tetlowhave a 246d962d52aSRuslan Ermilov.Pa .sh 24754e347fbSGordon Tetlowsuffix. 24854e347fbSGordon TetlowExtreme care must be taken in using this, as the startup sequence will 24954e347fbSGordon Tetlowterminate if the script does. 25054e347fbSGordon Tetlow.It Pa bar 25154e347fbSGordon TetlowScripts that are sourced in a subshell. 2523d03791bSMike MakonnenThe boot does not stop if such a script terminates with a non-zero status, 2533d03791bSMike Makonnenbut a script can stop the boot if necessary by invoking the 2543d03791bSMike Makonnen.Fn stop_boot 2553d03791bSMike Makonnenfunction (from 2563d03791bSMike Makonnen.Xr rc.subr 8 ). 25754e347fbSGordon Tetlow.El 25854e347fbSGordon Tetlow.Pp 25954e347fbSGordon TetlowEach script should contain 26054e347fbSGordon Tetlow.Xr rcorder 8 26154e347fbSGordon Tetlowkeywords, especially an appropriate 262d962d52aSRuslan Ermilov.Dq Li PROVIDE 26354e347fbSGordon Tetlowentry, and if necessary 264d962d52aSRuslan Ermilov.Dq Li REQUIRE 26554e347fbSGordon Tetlowand 266d962d52aSRuslan Ermilov.Dq Li BEFORE 267d962d52aSRuslan Ermilovkeywords. 26854e347fbSGordon Tetlow.Pp 26954e347fbSGordon TetlowEach script is expected to support at least the following arguments, which 270d962d52aSRuslan Ermilovare automatically supported if it uses the 271d962d52aSRuslan Ermilov.Fn run_rc_command 272d962d52aSRuslan Ermilovfunction: 273d962d52aSRuslan Ermilov.Bl -tag -width ".Cm restart" -offset indent 274d962d52aSRuslan Ermilov.It Cm start 27554e347fbSGordon TetlowStart the service. 27654e347fbSGordon TetlowThis should check that the service is to be started as specified by 27754e347fbSGordon Tetlow.Xr rc.conf 5 . 27854e347fbSGordon TetlowAlso checks if the service is already running and refuses to start if 27954e347fbSGordon Tetlowit is. 28054e347fbSGordon TetlowThis latter check is not performed by standard 28154e347fbSGordon Tetlow.Fx 28254e347fbSGordon Tetlowscripts if the system is starting directly to multi-user mode, to 28354e347fbSGordon Tetlowspeed up the boot process. 28454e347fbSGordon TetlowIf 285d962d52aSRuslan Ermilov.Cm forcestart 28654e347fbSGordon Tetlowis given, ignore the 28754e347fbSGordon Tetlow.Xr rc.conf 5 28854e347fbSGordon Tetlowcheck and start anyway. 289d962d52aSRuslan Ermilov.It Cm stop 29054e347fbSGordon TetlowIf the service is to be started as specified by 29154e347fbSGordon Tetlow.Xr rc.conf 5 , 29254e347fbSGordon Tetlowstop the service. 293d962d52aSRuslan ErmilovThis should check that the service is running and complain if it is not. 29454e347fbSGordon TetlowIf 295d962d52aSRuslan Ermilov.Cm forcestop 29654e347fbSGordon Tetlowis given, ignore the 29754e347fbSGordon Tetlow.Xr rc.conf 5 29854e347fbSGordon Tetlowcheck and attempt to stop. 299d962d52aSRuslan Ermilov.It Cm restart 30054e347fbSGordon TetlowPerform a 301d962d52aSRuslan Ermilov.Cm stop 30254e347fbSGordon Tetlowthen a 303d962d52aSRuslan Ermilov.Cm start . 304d962d52aSRuslan Ermilov.It Cm status 30554e347fbSGordon TetlowIf the script starts a process (rather than performing a one-off 30654e347fbSGordon Tetlowoperation), show the status of the process. 307d962d52aSRuslan ErmilovOtherwise it is not necessary to support this argument. 30854e347fbSGordon TetlowDefaults to displaying the process ID of the program (if running). 309d962d52aSRuslan Ermilov.It Cm poll 31054e347fbSGordon TetlowIf the script starts a process (rather than performing a one-off 31154e347fbSGordon Tetlowoperation), wait for the command to exit. 312d962d52aSRuslan ErmilovOtherwise it is not necessary to support this argument. 313d962d52aSRuslan Ermilov.It Cm rcvar 31454e347fbSGordon TetlowDisplay which 31554e347fbSGordon Tetlow.Xr rc.conf 5 31654e347fbSGordon Tetlowvariables are used to control the startup of the service (if any). 31754e347fbSGordon Tetlow.El 31854e347fbSGordon Tetlow.Pp 31954e347fbSGordon TetlowIf a script must implement additional commands it can list them in 32054e347fbSGordon Tetlowthe 321d962d52aSRuslan Ermilov.Va extra_commands 322d962d52aSRuslan Ermilovvariable, and define their actions in a variable constructed from 32354e347fbSGordon Tetlowthe command name (see the 32454e347fbSGordon Tetlow.Sx EXAMPLES 32554e347fbSGordon Tetlowsection). 32654e347fbSGordon Tetlow.Pp 32754e347fbSGordon TetlowThe following key points apply to old-style scripts in 328d962d52aSRuslan Ermilov.Pa /usr/local/etc/rc.d/ : 329d962d52aSRuslan Ermilov.Bl -bullet 33091e06c00SBen Smithurst.It 33191e06c00SBen SmithurstScripts are only executed if their 33291e06c00SBen Smithurst.Xr basename 1 33391e06c00SBen Smithurstmatches the shell globbing pattern 33491e06c00SBen Smithurst.Pa *.sh , 33591e06c00SBen Smithurstand they are executable. 33691e06c00SBen SmithurstAny other files or directories present within the directory are silently 33791e06c00SBen Smithurstignored. 33891e06c00SBen Smithurst.It 33991e06c00SBen SmithurstWhen a script is executed at boot time, it is passed the string 340d962d52aSRuslan Ermilov.Dq Li start 34191e06c00SBen Smithurstas its first and only argument. 34291e06c00SBen SmithurstAt shutdown time, it is passed the string 343d962d52aSRuslan Ermilov.Dq Li stop 34491e06c00SBen Smithurstas its first and only argument. 34591e06c00SBen SmithurstAll 346d962d52aSRuslan Ermilov.Nm rc.d/ 347d4bbfee2SJens Schweikhardtscripts are expected to handle these arguments appropriately. 34891e06c00SBen SmithurstIf no action needs to be taken at a given time 349d962d52aSRuslan Ermilov(either boot time or shutdown time), 35091e06c00SBen Smithurstthe script should exit successfully and without producing an error message. 35191e06c00SBen Smithurst.It 35291e06c00SBen SmithurstThe scripts within each directory are executed in lexicographical order. 35391e06c00SBen SmithurstIf a specific order is required, 35491e06c00SBen Smithurstnumbers may be used as a prefix to the existing filenames, 35591e06c00SBen Smithurstso for example 35691e06c00SBen Smithurst.Pa 100.foo 35791e06c00SBen Smithurstwould be executed before 35891e06c00SBen Smithurst.Pa 200.bar ; 35991e06c00SBen Smithurstwithout the numeric prefixes the opposite would be true. 36054e347fbSGordon Tetlow.It 36191e06c00SBen SmithurstThe output from each script is traditionally a space character, 36291e06c00SBen Smithurstfollowed by the name of the software package being started or shut down, 36391e06c00SBen Smithurst.Em without 36491e06c00SBen Smithursta trailing newline character (see the 36591e06c00SBen Smithurst.Sx EXAMPLES 36691e06c00SBen Smithurstsection). 36754e347fbSGordon Tetlow.El 368d962d52aSRuslan Ermilov.Sh SCRIPTS OF INTEREST 36954e347fbSGordon TetlowWhen an automatic reboot is in progress, 37054e347fbSGordon Tetlow.Nm 37154e347fbSGordon Tetlowis invoked with the argument 372d962d52aSRuslan Ermilov.Cm autoboot . 37354e347fbSGordon TetlowOne of the scripts run from 374d962d52aSRuslan Ermilov.Pa /etc/rc.d/ 37554e347fbSGordon Tetlowis 37654e347fbSGordon Tetlow.Pa /etc/rc.d/fsck . 37754e347fbSGordon TetlowThis script runs 37854e347fbSGordon Tetlow.Xr fsck 8 37954e347fbSGordon Tetlowwith option 38054e347fbSGordon Tetlow.Fl p 38154e347fbSGordon Tetlowand 38254e347fbSGordon Tetlow.Fl F 383d962d52aSRuslan Ermilovto 384d962d52aSRuslan Ermilov.Dq preen 385d962d52aSRuslan Ermilovall the disks of minor inconsistencies resulting 386d962d52aSRuslan Ermilovfrom the last system shutdown. 387d962d52aSRuslan ErmilovIf this fails, then checks/repairs of serious inconsistencies 388d962d52aSRuslan Ermilovcaused by hardware or software failure will be performed 389d962d52aSRuslan Ermilovin the background at the end of the booting process. 390d962d52aSRuslan ErmilovIf 391d962d52aSRuslan Ermilov.Cm autoboot 392d962d52aSRuslan Ermilovis not set, when going from single-user to multi-user mode for example, 393d962d52aSRuslan Ermilovthe script does not do anything. 39491e06c00SBen Smithurst.Pp 39554e347fbSGordon TetlowThe 396d962d52aSRuslan Ermilov.Pa /etc/rc.d/local 39754e347fbSGordon Tetlowscript can execute scripts from multiple 398d962d52aSRuslan Ermilov.Nm rc.d/ 39991e06c00SBen Smithurstdirectories. 4009a0e6be2SXin LIThe default location includes 4019a0e6be2SXin LI.Pa /usr/local/etc/rc.d/ , 40291e06c00SBen Smithurstbut these may be overridden with the 40391e06c00SBen Smithurst.Va local_startup 40491e06c00SBen Smithurst.Xr rc.conf 5 40591e06c00SBen Smithurstvariable. 40691e06c00SBen Smithurst.Pp 4078d74f63dSPhilippe CharnierThe 408d962d52aSRuslan Ermilov.Pa /etc/rc.d/serial 4098d74f63dSPhilippe Charnierscript is used to set any special configurations for serial devices. 410afe61c15SRodney W. Grimes.Pp 4118d74f63dSPhilippe CharnierThe 4128d74f63dSPhilippe Charnier.Nm rc.firewall 4138d74f63dSPhilippe Charnierscript is used to configure rules for the kernel based firewall 4141111b49cSSheldon Hearnservice. 4151111b49cSSheldon HearnIt has several possible options: 416e4f980d3SJordan K. Hubbard.Pp 417d962d52aSRuslan Ermilov.Bl -tag -width ".Ar filename" -compact -offset indent 418d962d52aSRuslan Ermilov.It Cm open 419d962d52aSRuslan Ermilovwill allow anyone in 420d962d52aSRuslan Ermilov.It Cm client 421d962d52aSRuslan Ermilovwill try to protect just this machine 422d962d52aSRuslan Ermilov.It Cm simple 423d962d52aSRuslan Ermilovwill try to protect a whole network 424d962d52aSRuslan Ermilov.It Cm closed 425d962d52aSRuslan Ermilovtotally disables IP services except via 426d962d52aSRuslan Ermilov.Pa lo0 427d962d52aSRuslan Ermilovinterface 428d962d52aSRuslan Ermilov.It Cm UNKNOWN 429d962d52aSRuslan Ermilovdisables the loading of firewall rules 430d962d52aSRuslan Ermilov.It Ar filename 431e4f980d3SJordan K. Hubbardwill load the rules in the given filename (full path required). 432e4f980d3SJordan K. Hubbard.El 433e4f980d3SJordan K. Hubbard.Pp 4348d74f63dSPhilippe CharnierThe 435d962d52aSRuslan Ermilov.Pa /etc/rc.d/atm* 43654e347fbSGordon Tetlowscripts are used to configure ATM network interfaces. 4377d5c779cSPoul-Henning KampThe interfaces are configured in three passes. 4387d5c779cSPoul-Henning KampThe first pass performs the initial interface configuration. 4397d5c779cSPoul-Henning KampThe second pass completes the interface configuration and defines PVCs and 4407d5c779cSPoul-Henning Kamppermanent ATMARP entries. 4417d5c779cSPoul-Henning KampThe third pass starts any ATM daemons. 4427d5c779cSPoul-Henning Kamp.Pp 44354e347fbSGordon TetlowMost daemons, including network related daemons, have their own script in 444d962d52aSRuslan Ermilov.Pa /etc/rc.d/ , 44554e347fbSGordon Tetlowwhich can be used to start, stop, and check the status of the service. 446e4f980d3SJordan K. Hubbard.Pp 44754e347fbSGordon TetlowAny architecture specific scripts, such as 44854e347fbSGordon Tetlow.Pa /etc/rc.d/apm 44954e347fbSGordon Tetlowfor example, specifically check that they are on that architecture 45054e347fbSGordon Tetlowbefore starting the daemon. 451e4f980d3SJordan K. Hubbard.Pp 45254e347fbSGordon TetlowFollowing tradition, all startup files reside in 453afe61c15SRodney W. Grimes.Pa /etc . 4549cbda590SRuslan Ermilov.Sh FILES 4559cbda590SRuslan Ermilov.Bl -tag -compact 4569cbda590SRuslan Ermilov.It Pa /etc/rc 4579cbda590SRuslan Ermilov.It Pa /etc/rc.conf 4589cbda590SRuslan Ermilov.It Pa /etc/rc.conf.local 4599cbda590SRuslan Ermilov.It Pa /etc/rc.d/ 4609cbda590SRuslan Ermilov.It Pa /etc/rc.firewall 4619cbda590SRuslan Ermilov.It Pa /etc/rc.local 4629cbda590SRuslan Ermilov.It Pa /etc/rc.shutdown 4639cbda590SRuslan Ermilov.It Pa /etc/rc.subr 4649cbda590SRuslan Ermilov.It Pa /var/run/dmesg.boot 465a3f9c9fcSRuslan Ermilov.Xr dmesg 8 4669cbda590SRuslan Ermilovresults soon after the 4679cbda590SRuslan Ermilov.Nm 4689cbda590SRuslan Ermilovprocess begins. 469a3f9c9fcSRuslan ErmilovUseful when 470a3f9c9fcSRuslan Ermilov.Xr dmesg 8 471a3f9c9fcSRuslan Ermilovbuffer in the kernel no longer has this information. 4729cbda590SRuslan Ermilov.El 47391e06c00SBen Smithurst.Sh EXAMPLES 47454e347fbSGordon TetlowThe following is a minimal 475d962d52aSRuslan Ermilov.Nm rc.d/ 476d962d52aSRuslan Ermilovstyle script. 477d962d52aSRuslan ErmilovMost scripts require little more than the following. 47854e347fbSGordon Tetlow.Bd -literal -offset indent 47954e347fbSGordon Tetlow#!/bin/sh 48054e347fbSGordon Tetlow# 48154e347fbSGordon Tetlow 48254e347fbSGordon Tetlow# PROVIDE: foo 48354e347fbSGordon Tetlow# REQUIRE: bar_service_required_to_precede_foo 48454e347fbSGordon Tetlow 485d962d52aSRuslan Ermilov\&. /etc/rc.subr 48654e347fbSGordon Tetlow 48754e347fbSGordon Tetlowname="foo" 488*c86072f5SDoug Bartonrcvar=foo_enable 48954e347fbSGordon Tetlowcommand="/usr/local/bin/foo" 49054e347fbSGordon Tetlow 49154e347fbSGordon Tetlowload_rc_config $name 49254e347fbSGordon Tetlowrun_rc_command "$1" 49354e347fbSGordon Tetlow.Ed 49454e347fbSGordon Tetlow.Pp 495d962d52aSRuslan ErmilovCertain scripts may want to provide enhanced functionality. 496d962d52aSRuslan ErmilovThe user may access this functionality through additional commands. 497d962d52aSRuslan ErmilovThe script may list and define as many commands at it needs. 49854e347fbSGordon Tetlow.Bd -literal -offset indent 49954e347fbSGordon Tetlow#!/bin/sh 50054e347fbSGordon Tetlow# 50154e347fbSGordon Tetlow 50254e347fbSGordon Tetlow# PROVIDE: foo 50354e347fbSGordon Tetlow# REQUIRE: bar_service_required_to_precede_foo 50454e347fbSGordon Tetlow# BEFORE: baz_service_requiring_foo_to_precede_it 50554e347fbSGordon Tetlow 506d962d52aSRuslan Ermilov\&. /etc/rc.subr 50754e347fbSGordon Tetlow 50854e347fbSGordon Tetlowname="foo" 509*c86072f5SDoug Bartonrcvar=foo_enable 51054e347fbSGordon Tetlowcommand="/usr/local/bin/foo" 51154e347fbSGordon Tetlowextra_commands="nop hello" 51254e347fbSGordon Tetlowhello_cmd="echo Hello World." 51354e347fbSGordon Tetlownop_cmd="do_nop" 51454e347fbSGordon Tetlow 51554e347fbSGordon Tetlowdo_nop() 51654e347fbSGordon Tetlow{ 51754e347fbSGordon Tetlow echo "I do nothing." 51854e347fbSGordon Tetlow} 51954e347fbSGordon Tetlow 52054e347fbSGordon Tetlowload_rc_config $name 52154e347fbSGordon Tetlowrun_rc_command "$1" 52254e347fbSGordon Tetlow.Ed 52354e347fbSGordon Tetlow.Pp 52491e06c00SBen SmithurstAs all processes are killed by 52591e06c00SBen Smithurst.Xr init 8 52691e06c00SBen Smithurstat shutdown, the explicit 52791e06c00SBen Smithurst.Xr kill 1 52891e06c00SBen Smithurstis unnecessary, but is often included. 529afe61c15SRodney W. Grimes.Sh SEE ALSO 53091e06c00SBen Smithurst.Xr kill 1 , 531e4f980d3SJordan K. Hubbard.Xr rc.conf 5 , 532afe61c15SRodney W. Grimes.Xr init 8 , 53354e347fbSGordon Tetlow.Xr rcorder 8 , 5341c85060aSRuslan Ermilov.Xr rc.subr 8 , 535afe61c15SRodney W. Grimes.Xr reboot 8 , 536afe61c15SRodney W. Grimes.Xr savecore 8 537afe61c15SRodney W. Grimes.Sh HISTORY 538afe61c15SRodney W. GrimesThe 539afe61c15SRodney W. Grimes.Nm 5408d74f63dSPhilippe Charnierutility appeared in 541afe61c15SRodney W. Grimes.Bx 4.0 . 542