xref: /freebsd/share/man/man8/rc.8 (revision e5accd3ca17c0d0061f2ad9a5b68c48efe255efe)
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.
15dda5b397SEitan Adler.\" 3. Neither the name of the University nor the names of its contributors
16afe61c15SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
17afe61c15SRodney W. Grimes.\"    without specific prior written permission.
18afe61c15SRodney W. Grimes.\"
19afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22afe61c15SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29afe61c15SRodney W. Grimes.\" SUCH DAMAGE.
30afe61c15SRodney W. Grimes.\"
31afe61c15SRodney W. Grimes.\"     @(#)rc.8	8.2 (Berkeley) 12/11/93
327f3dea24SPeter Wemm.\" $FreeBSD$
33afe61c15SRodney W. Grimes.\"
340607c830SBrooks Davis.Dd April 25, 2017
35afe61c15SRodney W. Grimes.Dt RC 8
363d45e180SRuslan Ermilov.Os
37afe61c15SRodney W. Grimes.Sh NAME
38afe61c15SRodney W. Grimes.Nm rc
39d962d52aSRuslan Ermilov.Nd command scripts for auto-reboot and daemon startup
40afe61c15SRodney W. Grimes.Sh SYNOPSIS
414b66483fSRuslan Ermilov.Nm
42e4f980d3SJordan K. Hubbard.Nm rc.conf
43e4f980d3SJordan K. Hubbard.Nm rc.conf.local
44d962d52aSRuslan Ermilov.Nm rc.d/
45e4f980d3SJordan K. Hubbard.Nm rc.firewall
46afe61c15SRodney W. Grimes.Nm rc.local
47e4f980d3SJordan K. Hubbard.Nm rc.shutdown
4854e347fbSGordon Tetlow.Nm rc.subr
49afe61c15SRodney W. Grimes.Sh DESCRIPTION
508d74f63dSPhilippe CharnierThe
518d74f63dSPhilippe Charnier.Nm
5254e347fbSGordon Tetlowutility is the command script which controls the automatic boot process
5354e347fbSGordon Tetlowafter being called by
5454e347fbSGordon Tetlow.Xr init 8 .
5554e347fbSGordon TetlowThe
56afe61c15SRodney W. Grimes.Nm rc.local
5754e347fbSGordon Tetlowscript contains commands which are pertinent only
58d962d52aSRuslan Ermilovto a specific site.
59d962d52aSRuslan ErmilovTypically, the
60d962d52aSRuslan Ermilov.Pa /usr/local/etc/rc.d/
6154e347fbSGordon Tetlowmechanism is used instead of
6254e347fbSGordon Tetlow.Nm rc.local
6354e347fbSGordon Tetlowthese days but if
6454e347fbSGordon Tetlowyou want to use
65d962d52aSRuslan Ermilov.Nm rc.local ,
66d962d52aSRuslan Ermilovit is still supported.
67d962d52aSRuslan ErmilovIn this case, it should source
68d962d52aSRuslan Ermilov.Pa /etc/rc.conf
6954e347fbSGordon Tetlowand contain additional custom startup code for your system.
7054e347fbSGordon TetlowThe best way to handle
71d962d52aSRuslan Ermilov.Nm rc.local ,
7254e347fbSGordon Tetlowhowever, is to separate it out into
73d962d52aSRuslan Ermilov.Nm rc.d/
74d962d52aSRuslan Ermilovstyle scripts and place them under
75d962d52aSRuslan Ermilov.Pa /usr/local/etc/rc.d/ .
768d74f63dSPhilippe CharnierThe
778d74f63dSPhilippe Charnier.Nm rc.conf
788d74f63dSPhilippe Charnierfile contains the global system configuration information referenced
7954e347fbSGordon Tetlowby the startup scripts, while
80e4f980d3SJordan K. Hubbard.Nm rc.conf.local
816575e6daSRuslan Ermilovcontains the local system configuration.
826575e6daSRuslan ErmilovSee
8354e347fbSGordon Tetlow.Xr rc.conf 5
8454e347fbSGordon Tetlowfor more information.
85e4f980d3SJordan K. Hubbard.Pp
8691e06c00SBen SmithurstThe
87d962d52aSRuslan Ermilov.Nm rc.d/
8891e06c00SBen Smithurstdirectories contain scripts which will be automatically
8991e06c00SBen Smithurstexecuted at boot time and shutdown time.
90d962d52aSRuslan Ermilov.Ss Operation of Nm
9154e347fbSGordon Tetlow.Bl -enum
9254e347fbSGordon Tetlow.It
9354e347fbSGordon TetlowIf autobooting, set
94d962d52aSRuslan Ermilov.Va autoboot Ns = Ns Li yes
9554e347fbSGordon Tetlowand enable a flag
96d962d52aSRuslan Ermilov.Pq Va rc_fast Ns = Ns Li yes ,
9754e347fbSGordon Tetlowwhich prevents the
98d962d52aSRuslan Ermilov.Nm rc.d/
9954e347fbSGordon Tetlowscripts from performing the check for already running processes
10054e347fbSGordon Tetlow(thus speeding up the boot process).
10154e347fbSGordon TetlowThis
102d962d52aSRuslan Ermilov.Va rc_fast Ns = Ns Li yes
103d962d52aSRuslan Ermilovspeedup will not occur when
10454e347fbSGordon Tetlow.Nm
10554e347fbSGordon Tetlowis started up after exiting the single-user shell.
10654e347fbSGordon Tetlow.It
1079eb99781SDoug BartonDetermine whether the system is booting diskless,
1089eb99781SDoug Bartonand if so run the
1099eb99781SDoug Barton.Pa /etc/rc.initdiskless
1109eb99781SDoug Bartonscript.
1119eb99781SDoug Barton.It
1129eb99781SDoug BartonSource
1139eb99781SDoug Barton.Pa /etc/rc.subr
1149eb99781SDoug Bartonto load various
1159eb99781SDoug Barton.Xr rc.subr 8
1169eb99781SDoug Bartonshell functions to use.
1179eb99781SDoug Barton.It
1189eb99781SDoug BartonLoad the configuration files.
1199eb99781SDoug Barton.It
1209eb99781SDoug BartonDetermine if booting in a jail,
1219eb99781SDoug Bartonand add
12281ae4b8dSRuslan Ermilov.Dq Li nojail
1236a774190SJamie Gritton(no jails allowed) or
1246a774190SJamie Gritton.Dq Li nojailvnet
1256a774190SJamie Gritton(only allow vnet-enabled jails) to the list of KEYWORDS to skip in
1269eb99781SDoug Barton.Xr rcorder 8 .
1279eb99781SDoug Barton.It
128cabad264SColin PercivalIf the file
129cabad264SColin Percival.Va ${firstboot_sentinel}
130cabad264SColin Percivaldoes not exist, add
131cabad264SColin Percival.Dq Li firstboot
132cabad264SColin Percivalto the list of KEYWORDS to skip in
133cabad264SColin Percival.Xr rcorder 8 .
134cabad264SColin Percival.It
13554e347fbSGordon TetlowInvoke
13654e347fbSGordon Tetlow.Xr rcorder 8
13754e347fbSGordon Tetlowto order the files in
13854e347fbSGordon Tetlow.Pa /etc/rc.d/
13954e347fbSGordon Tetlowthat do not have a
140d962d52aSRuslan Ermilov.Dq Li nostart
1419eb99781SDoug BartonKEYWORD (refer to
142d962d52aSRuslan Ermilov.Xr rcorder 8 Ns 's
14354e347fbSGordon Tetlow.Fl s
1449eb99781SDoug Bartonflag).
14554e347fbSGordon Tetlow.It
146d962d52aSRuslan ErmilovCall each script in turn using
147d962d52aSRuslan Ermilov.Fn run_rc_script
148d962d52aSRuslan Ermilov(from
14954e347fbSGordon Tetlow.Xr rc.subr 8 ) ,
15054e347fbSGordon Tetlowwhich sets
151d962d52aSRuslan Ermilov.Va $1
15254e347fbSGordon Tetlowto
153d962d52aSRuslan Ermilov.Dq Li start ,
15454e347fbSGordon Tetlowand sources the script in a subshell.
15554e347fbSGordon TetlowIf the script has a
156d962d52aSRuslan Ermilov.Pa .sh
15754e347fbSGordon Tetlowsuffix then it is sourced directly into the current shell.
1589eb99781SDoug BartonStop processing when the script that is the value of the
1599eb99781SDoug Barton.Va $early_late_divider
1609eb99781SDoug Bartonhas been run.
1619eb99781SDoug Barton.It
162cabad264SColin PercivalCheck again to see if the file
163cabad264SColin Percival.Va ${firstboot_sentinel}
164cabad264SColin Percivalexists (in case it is located on a newly mounted file system)
165cabad264SColin Percivaland adjust the list of KEYWORDs to skip appropriately.
166cabad264SColin Percival.It
1679eb99781SDoug BartonRe-run
1689eb99781SDoug Barton.Xr rcorder 8 ,
1699eb99781SDoug Bartonthis time including the scripts in the
1709eb99781SDoug Barton.Va $local_startup
1719eb99781SDoug Bartondirectories.
1729eb99781SDoug BartonIgnore everything up to the
1739eb99781SDoug Barton.Va $early_late_divider ,
1749eb99781SDoug Bartonthen start executing the scripts as described above.
175cabad264SColin Percival.It
176cabad264SColin PercivalIf the file
177cabad264SColin Percival.Va ${firstboot_sentinel}
178cabad264SColin Percivalexists, delete it.
179cabad264SColin PercivalIf the file
180cabad264SColin Percival.Va ${firstboot_sentinel}-reboot
181cabad264SColin Percivalalso exists (because it was created by a script), then delete it and reboot.
18254e347fbSGordon Tetlow.El
183d962d52aSRuslan Ermilov.Ss Operation of Nm rc.shutdown
18454e347fbSGordon Tetlow.Bl -enum
18554e347fbSGordon Tetlow.It
18654e347fbSGordon TetlowSource
18754e347fbSGordon Tetlow.Pa /etc/rc.subr
18854e347fbSGordon Tetlowto load various
18954e347fbSGordon Tetlow.Xr rc.subr 8
19054e347fbSGordon Tetlowshell functions to use.
19154e347fbSGordon Tetlow.It
1929eb99781SDoug BartonLoad the configuration files.
1939eb99781SDoug Barton.It
19454e347fbSGordon TetlowInvoke
19554e347fbSGordon Tetlow.Xr rcorder 8
19654e347fbSGordon Tetlowto order the files in
19754e347fbSGordon Tetlow.Pa /etc/rc.d/
1989eb99781SDoug Bartonand the
1999eb99781SDoug Barton.Va $local_startup
2009eb99781SDoug Bartondirectories
20154e347fbSGordon Tetlowthat have a
202d962d52aSRuslan Ermilov.Dq Li shutdown
2039eb99781SDoug BartonKEYWORD (refer to
204d962d52aSRuslan Ermilov.Xr rcorder 8 Ns 's
20554e347fbSGordon Tetlow.Fl k
20654e347fbSGordon Tetlowflag),
207d962d52aSRuslan Ermilovreverse that order, and assign the result to a variable.
20854e347fbSGordon Tetlow.It
209d962d52aSRuslan ErmilovCall each script in turn using
210d962d52aSRuslan Ermilov.Fn run_rc_script
211d962d52aSRuslan Ermilov(from
21254e347fbSGordon Tetlow.Xr rc.subr 8 ) ,
21354e347fbSGordon Tetlowwhich sets
214d962d52aSRuslan Ermilov.Va $1
21554e347fbSGordon Tetlowto
216d962d52aSRuslan Ermilov.Dq Li stop ,
21754e347fbSGordon Tetlowand sources the script in a subshell.
21854e347fbSGordon TetlowIf the script has a
219d962d52aSRuslan Ermilov.Pa .sh
22054e347fbSGordon Tetlowsuffix then it is sourced directly into the current shell.
22154e347fbSGordon Tetlow.El
222d962d52aSRuslan Ermilov.Ss Contents of Nm rc.d/
22354e347fbSGordon Tetlow.Nm rc.d/
22454e347fbSGordon Tetlowis located in
225d962d52aSRuslan Ermilov.Pa /etc/rc.d/ .
22654e347fbSGordon TetlowThe following file naming conventions are currently used in
22754e347fbSGordon Tetlow.Nm rc.d/ :
228d962d52aSRuslan Ermilov.Bl -tag -width ".Pa ALLUPPERCASE" -offset indent
22954e347fbSGordon Tetlow.It Pa ALLUPPERCASE
23054e347fbSGordon TetlowScripts that are
231d962d52aSRuslan Ermilov.Dq placeholders
23254e347fbSGordon Tetlowto ensure that certain operations are performed before others.
23354e347fbSGordon TetlowIn order of startup, these are:
234d962d52aSRuslan Ermilov.Bl -tag -width ".Pa NETWORKING"
23554e347fbSGordon Tetlow.It Pa NETWORKING
23654e347fbSGordon TetlowEnsure basic network services are running, including general
2379eb99781SDoug Bartonnetwork configuration.
23854e347fbSGordon Tetlow.It Pa SERVERS
2399eb99781SDoug BartonEnsure basic services
24054e347fbSGordon Tetlowexist for services that start early (such as
24154c22eeaSSergey Kandaurov.Pa nisdomain ) ,
242d962d52aSRuslan Ermilovbecause they are required by
24354e347fbSGordon Tetlow.Pa DAEMON
24454e347fbSGordon Tetlowbelow.
24554e347fbSGordon Tetlow.It Pa DAEMON
24654e347fbSGordon TetlowCheck-point before all general purpose daemons such as
24754e347fbSGordon Tetlow.Pa lpd
24854e347fbSGordon Tetlowand
24954e347fbSGordon Tetlow.Pa ntpd .
25054e347fbSGordon Tetlow.It Pa LOGIN
25154e347fbSGordon TetlowCheck-point before user login services
25254e347fbSGordon Tetlow.Pa ( inetd
25354e347fbSGordon Tetlowand
25454e347fbSGordon Tetlow.Pa sshd ) ,
25554e347fbSGordon Tetlowas well as services which might run commands as users
25654e347fbSGordon Tetlow.Pa ( cron
25754e347fbSGordon Tetlowand
25854e347fbSGordon Tetlow.Pa sendmail ) .
25954e347fbSGordon Tetlow.El
26054e347fbSGordon Tetlow.It Pa foo.sh
26154e347fbSGordon TetlowScripts that are to be sourced into the current shell rather than a subshell
26254e347fbSGordon Tetlowhave a
263d962d52aSRuslan Ermilov.Pa .sh
26454e347fbSGordon Tetlowsuffix.
26554e347fbSGordon TetlowExtreme care must be taken in using this, as the startup sequence will
26654e347fbSGordon Tetlowterminate if the script does.
26754e347fbSGordon Tetlow.It Pa bar
26854e347fbSGordon TetlowScripts that are sourced in a subshell.
2693d03791bSMike MakonnenThe boot does not stop if such a script terminates with a non-zero status,
2703d03791bSMike Makonnenbut a script can stop the boot if necessary by invoking the
2713d03791bSMike Makonnen.Fn stop_boot
2723d03791bSMike Makonnenfunction (from
2733d03791bSMike Makonnen.Xr rc.subr 8 ) .
27454e347fbSGordon Tetlow.El
27554e347fbSGordon Tetlow.Pp
27654e347fbSGordon TetlowEach script should contain
27754e347fbSGordon Tetlow.Xr rcorder 8
27854e347fbSGordon Tetlowkeywords, especially an appropriate
279d962d52aSRuslan Ermilov.Dq Li PROVIDE
28054e347fbSGordon Tetlowentry, and if necessary
281d962d52aSRuslan Ermilov.Dq Li REQUIRE
28254e347fbSGordon Tetlowand
283d962d52aSRuslan Ermilov.Dq Li BEFORE
284d962d52aSRuslan Ermilovkeywords.
28554e347fbSGordon Tetlow.Pp
28654e347fbSGordon TetlowEach script is expected to support at least the following arguments, which
287d962d52aSRuslan Ermilovare automatically supported if it uses the
288d962d52aSRuslan Ermilov.Fn run_rc_command
289d962d52aSRuslan Ermilovfunction:
290d962d52aSRuslan Ermilov.Bl -tag -width ".Cm restart" -offset indent
291d962d52aSRuslan Ermilov.It Cm start
29254e347fbSGordon TetlowStart the service.
29354e347fbSGordon TetlowThis should check that the service is to be started as specified by
29454e347fbSGordon Tetlow.Xr rc.conf 5 .
29554e347fbSGordon TetlowAlso checks if the service is already running and refuses to start if
29654e347fbSGordon Tetlowit is.
29754e347fbSGordon TetlowThis latter check is not performed by standard
29854e347fbSGordon Tetlow.Fx
29954e347fbSGordon Tetlowscripts if the system is starting directly to multi-user mode, to
30054e347fbSGordon Tetlowspeed up the boot process.
30154e347fbSGordon TetlowIf
302d962d52aSRuslan Ermilov.Cm forcestart
30354e347fbSGordon Tetlowis given, ignore the
30454e347fbSGordon Tetlow.Xr rc.conf 5
30554e347fbSGordon Tetlowcheck and start anyway.
306d962d52aSRuslan Ermilov.It Cm stop
30754e347fbSGordon TetlowIf the service is to be started as specified by
30854e347fbSGordon Tetlow.Xr rc.conf 5 ,
30954e347fbSGordon Tetlowstop the service.
310d962d52aSRuslan ErmilovThis should check that the service is running and complain if it is not.
31154e347fbSGordon TetlowIf
312d962d52aSRuslan Ermilov.Cm forcestop
31354e347fbSGordon Tetlowis given, ignore the
31454e347fbSGordon Tetlow.Xr rc.conf 5
31554e347fbSGordon Tetlowcheck and attempt to stop.
316d962d52aSRuslan Ermilov.It Cm restart
31754e347fbSGordon TetlowPerform a
318d962d52aSRuslan Ermilov.Cm stop
31954e347fbSGordon Tetlowthen a
320d962d52aSRuslan Ermilov.Cm start .
321d962d52aSRuslan Ermilov.It Cm status
32254e347fbSGordon TetlowIf the script starts a process (rather than performing a one-off
32354e347fbSGordon Tetlowoperation), show the status of the process.
324d962d52aSRuslan ErmilovOtherwise it is not necessary to support this argument.
32554e347fbSGordon TetlowDefaults to displaying the process ID of the program (if running).
3261980d11bSLars Engels.It Cm describe
3271980d11bSLars EngelsPrint a short description of what the script does.
3281980d11bSLars Engels.It Cm extracommands
3291980d11bSLars EngelsPrint the script's non-standard commands.
330d962d52aSRuslan Ermilov.It Cm poll
33154e347fbSGordon TetlowIf the script starts a process (rather than performing a one-off
33254e347fbSGordon Tetlowoperation), wait for the command to exit.
333d962d52aSRuslan ErmilovOtherwise it is not necessary to support this argument.
33449cede74SDag-Erling Smørgrav.It Cm enabled
33549cede74SDag-Erling SmørgravReturn 0 if the service is enabled and 1 if it is not.
33649cede74SDag-Erling SmørgravThis command does not print anything.
337d962d52aSRuslan Ermilov.It Cm rcvar
33854e347fbSGordon TetlowDisplay which
33954e347fbSGordon Tetlow.Xr rc.conf 5
34054e347fbSGordon Tetlowvariables are used to control the startup of the service (if any).
34154e347fbSGordon Tetlow.El
34254e347fbSGordon Tetlow.Pp
34354e347fbSGordon TetlowIf a script must implement additional commands it can list them in
34454e347fbSGordon Tetlowthe
345d962d52aSRuslan Ermilov.Va extra_commands
346d962d52aSRuslan Ermilovvariable, and define their actions in a variable constructed from
34754e347fbSGordon Tetlowthe command name (see the
34854e347fbSGordon Tetlow.Sx EXAMPLES
34954e347fbSGordon Tetlowsection).
35054e347fbSGordon Tetlow.Pp
35154e347fbSGordon TetlowThe following key points apply to old-style scripts in
352d962d52aSRuslan Ermilov.Pa /usr/local/etc/rc.d/ :
353d962d52aSRuslan Ermilov.Bl -bullet
35491e06c00SBen Smithurst.It
35591e06c00SBen SmithurstScripts are only executed if their
35691e06c00SBen Smithurst.Xr basename 1
35791e06c00SBen Smithurstmatches the shell globbing pattern
35891e06c00SBen Smithurst.Pa *.sh ,
35991e06c00SBen Smithurstand they are executable.
36091e06c00SBen SmithurstAny other files or directories present within the directory are silently
36191e06c00SBen Smithurstignored.
36291e06c00SBen Smithurst.It
36391e06c00SBen SmithurstWhen a script is executed at boot time, it is passed the string
364d962d52aSRuslan Ermilov.Dq Li start
36591e06c00SBen Smithurstas its first and only argument.
36691e06c00SBen SmithurstAt shutdown time, it is passed the string
367d962d52aSRuslan Ermilov.Dq Li stop
36891e06c00SBen Smithurstas its first and only argument.
36991e06c00SBen SmithurstAll
370d962d52aSRuslan Ermilov.Nm rc.d/
371d4bbfee2SJens Schweikhardtscripts are expected to handle these arguments appropriately.
37291e06c00SBen SmithurstIf no action needs to be taken at a given time
373d962d52aSRuslan Ermilov(either boot time or shutdown time),
37491e06c00SBen Smithurstthe script should exit successfully and without producing an error message.
37591e06c00SBen Smithurst.It
37691e06c00SBen SmithurstThe scripts within each directory are executed in lexicographical order.
37791e06c00SBen SmithurstIf a specific order is required,
37891e06c00SBen Smithurstnumbers may be used as a prefix to the existing filenames,
37991e06c00SBen Smithurstso for example
38091e06c00SBen Smithurst.Pa 100.foo
38191e06c00SBen Smithurstwould be executed before
38291e06c00SBen Smithurst.Pa 200.bar ;
38391e06c00SBen Smithurstwithout the numeric prefixes the opposite would be true.
38454e347fbSGordon Tetlow.It
38591e06c00SBen SmithurstThe output from each script is traditionally a space character,
38691e06c00SBen Smithurstfollowed by the name of the software package being started or shut down,
38791e06c00SBen Smithurst.Em without
38891e06c00SBen Smithursta trailing newline character (see the
38991e06c00SBen Smithurst.Sx EXAMPLES
39091e06c00SBen Smithurstsection).
39154e347fbSGordon Tetlow.El
392d962d52aSRuslan Ermilov.Sh SCRIPTS OF INTEREST
39354e347fbSGordon TetlowWhen an automatic reboot is in progress,
39454e347fbSGordon Tetlow.Nm
39554e347fbSGordon Tetlowis invoked with the argument
396d962d52aSRuslan Ermilov.Cm autoboot .
39754e347fbSGordon TetlowOne of the scripts run from
398d962d52aSRuslan Ermilov.Pa /etc/rc.d/
39954e347fbSGordon Tetlowis
40054e347fbSGordon Tetlow.Pa /etc/rc.d/fsck .
40154e347fbSGordon TetlowThis script runs
40254e347fbSGordon Tetlow.Xr fsck 8
40354e347fbSGordon Tetlowwith option
40454e347fbSGordon Tetlow.Fl p
40554e347fbSGordon Tetlowand
40654e347fbSGordon Tetlow.Fl F
407d962d52aSRuslan Ermilovto
408d962d52aSRuslan Ermilov.Dq preen
409d962d52aSRuslan Ermilovall the disks of minor inconsistencies resulting
410d962d52aSRuslan Ermilovfrom the last system shutdown.
411d962d52aSRuslan ErmilovIf this fails, then checks/repairs of serious inconsistencies
412d962d52aSRuslan Ermilovcaused by hardware or software failure will be performed
413d962d52aSRuslan Ermilovin the background at the end of the booting process.
414d962d52aSRuslan ErmilovIf
415d962d52aSRuslan Ermilov.Cm autoboot
416d962d52aSRuslan Ermilovis not set, when going from single-user to multi-user mode for example,
417d962d52aSRuslan Ermilovthe script does not do anything.
41891e06c00SBen Smithurst.Pp
41954e347fbSGordon TetlowThe
420d962d52aSRuslan Ermilov.Pa /etc/rc.d/local
42154e347fbSGordon Tetlowscript can execute scripts from multiple
422d962d52aSRuslan Ermilov.Nm rc.d/
42391e06c00SBen Smithurstdirectories.
4249a0e6be2SXin LIThe default location includes
4259a0e6be2SXin LI.Pa /usr/local/etc/rc.d/ ,
42691e06c00SBen Smithurstbut these may be overridden with the
42791e06c00SBen Smithurst.Va local_startup
42891e06c00SBen Smithurst.Xr rc.conf 5
42991e06c00SBen Smithurstvariable.
43091e06c00SBen Smithurst.Pp
4318d74f63dSPhilippe CharnierThe
432d962d52aSRuslan Ermilov.Pa /etc/rc.d/serial
4338d74f63dSPhilippe Charnierscript is used to set any special configurations for serial devices.
434afe61c15SRodney W. Grimes.Pp
4358d74f63dSPhilippe CharnierThe
4368d74f63dSPhilippe Charnier.Nm rc.firewall
4378d74f63dSPhilippe Charnierscript is used to configure rules for the kernel based firewall
4381111b49cSSheldon Hearnservice.
4391111b49cSSheldon HearnIt has several possible options:
440e4f980d3SJordan K. Hubbard.Pp
441d962d52aSRuslan Ermilov.Bl -tag -width ".Ar filename" -compact -offset indent
442d962d52aSRuslan Ermilov.It Cm open
443d962d52aSRuslan Ermilovwill allow anyone in
444d962d52aSRuslan Ermilov.It Cm client
445d962d52aSRuslan Ermilovwill try to protect just this machine
446d962d52aSRuslan Ermilov.It Cm simple
447d962d52aSRuslan Ermilovwill try to protect a whole network
448d962d52aSRuslan Ermilov.It Cm closed
449d962d52aSRuslan Ermilovtotally disables IP services except via
450d962d52aSRuslan Ermilov.Pa lo0
451d962d52aSRuslan Ermilovinterface
452d962d52aSRuslan Ermilov.It Cm UNKNOWN
453d962d52aSRuslan Ermilovdisables the loading of firewall rules
454d962d52aSRuslan Ermilov.It Ar filename
455e4f980d3SJordan K. Hubbardwill load the rules in the given filename (full path required).
456e4f980d3SJordan K. Hubbard.El
457e4f980d3SJordan K. Hubbard.Pp
45854e347fbSGordon TetlowMost daemons, including network related daemons, have their own script in
459d962d52aSRuslan Ermilov.Pa /etc/rc.d/ ,
46054e347fbSGordon Tetlowwhich can be used to start, stop, and check the status of the service.
461e4f980d3SJordan K. Hubbard.Pp
46254e347fbSGordon TetlowAny architecture specific scripts, such as
46354e347fbSGordon Tetlow.Pa /etc/rc.d/apm
46454e347fbSGordon Tetlowfor example, specifically check that they are on that architecture
46554e347fbSGordon Tetlowbefore starting the daemon.
466e4f980d3SJordan K. Hubbard.Pp
46754e347fbSGordon TetlowFollowing tradition, all startup files reside in
468afe61c15SRodney W. Grimes.Pa /etc .
4699cbda590SRuslan Ermilov.Sh FILES
470e9074458SGlen Barber.Bl -tag -compact -width Pa
4719cbda590SRuslan Ermilov.It Pa /etc/rc
4729cbda590SRuslan Ermilov.It Pa /etc/rc.conf
4739cbda590SRuslan Ermilov.It Pa /etc/rc.conf.local
4749cbda590SRuslan Ermilov.It Pa /etc/rc.d/
4759cbda590SRuslan Ermilov.It Pa /etc/rc.firewall
4769cbda590SRuslan Ermilov.It Pa /etc/rc.local
4779cbda590SRuslan Ermilov.It Pa /etc/rc.shutdown
4789cbda590SRuslan Ermilov.It Pa /etc/rc.subr
4799cbda590SRuslan Ermilov.It Pa /var/run/dmesg.boot
480a3f9c9fcSRuslan Ermilov.Xr dmesg 8
4819cbda590SRuslan Ermilovresults soon after the
4829cbda590SRuslan Ermilov.Nm
4839cbda590SRuslan Ermilovprocess begins.
484a3f9c9fcSRuslan ErmilovUseful when
485a3f9c9fcSRuslan Ermilov.Xr dmesg 8
486a3f9c9fcSRuslan Ermilovbuffer in the kernel no longer has this information.
4879cbda590SRuslan Ermilov.El
48891e06c00SBen Smithurst.Sh EXAMPLES
48954e347fbSGordon TetlowThe following is a minimal
490d962d52aSRuslan Ermilov.Nm rc.d/
491d962d52aSRuslan Ermilovstyle script.
492d962d52aSRuslan ErmilovMost scripts require little more than the following.
49354e347fbSGordon Tetlow.Bd -literal -offset indent
49454e347fbSGordon Tetlow#!/bin/sh
49554e347fbSGordon Tetlow#
49654e347fbSGordon Tetlow
49754e347fbSGordon Tetlow# PROVIDE: foo
49854e347fbSGordon Tetlow# REQUIRE: bar_service_required_to_precede_foo
49954e347fbSGordon Tetlow
500d962d52aSRuslan Ermilov\&. /etc/rc.subr
50154e347fbSGordon Tetlow
50254e347fbSGordon Tetlowname="foo"
503c86072f5SDoug Bartonrcvar=foo_enable
50454e347fbSGordon Tetlowcommand="/usr/local/bin/foo"
50554e347fbSGordon Tetlow
50654e347fbSGordon Tetlowload_rc_config $name
50754e347fbSGordon Tetlowrun_rc_command "$1"
50854e347fbSGordon Tetlow.Ed
50954e347fbSGordon Tetlow.Pp
510d962d52aSRuslan ErmilovCertain scripts may want to provide enhanced functionality.
511d962d52aSRuslan ErmilovThe user may access this functionality through additional commands.
512d962d52aSRuslan ErmilovThe script may list and define as many commands at it needs.
51354e347fbSGordon Tetlow.Bd -literal -offset indent
51454e347fbSGordon Tetlow#!/bin/sh
51554e347fbSGordon Tetlow#
51654e347fbSGordon Tetlow
51754e347fbSGordon Tetlow# PROVIDE: foo
51854e347fbSGordon Tetlow# REQUIRE: bar_service_required_to_precede_foo
51954e347fbSGordon Tetlow# BEFORE:  baz_service_requiring_foo_to_precede_it
52054e347fbSGordon Tetlow
521d962d52aSRuslan Ermilov\&. /etc/rc.subr
52254e347fbSGordon Tetlow
52354e347fbSGordon Tetlowname="foo"
524c86072f5SDoug Bartonrcvar=foo_enable
52554e347fbSGordon Tetlowcommand="/usr/local/bin/foo"
52654e347fbSGordon Tetlowextra_commands="nop hello"
52754e347fbSGordon Tetlowhello_cmd="echo Hello World."
52854e347fbSGordon Tetlownop_cmd="do_nop"
52954e347fbSGordon Tetlow
53054e347fbSGordon Tetlowdo_nop()
53154e347fbSGordon Tetlow{
53254e347fbSGordon Tetlow	echo "I do nothing."
53354e347fbSGordon Tetlow}
53454e347fbSGordon Tetlow
53554e347fbSGordon Tetlowload_rc_config $name
53654e347fbSGordon Tetlowrun_rc_command "$1"
53754e347fbSGordon Tetlow.Ed
53854e347fbSGordon Tetlow.Pp
53991e06c00SBen SmithurstAs all processes are killed by
54091e06c00SBen Smithurst.Xr init 8
54191e06c00SBen Smithurstat shutdown, the explicit
54291e06c00SBen Smithurst.Xr kill 1
54391e06c00SBen Smithurstis unnecessary, but is often included.
544afe61c15SRodney W. Grimes.Sh SEE ALSO
54591e06c00SBen Smithurst.Xr kill 1 ,
546e4f980d3SJordan K. Hubbard.Xr rc.conf 5 ,
547afe61c15SRodney W. Grimes.Xr init 8 ,
5481c85060aSRuslan Ermilov.Xr rc.subr 8 ,
549121f7af1SBaptiste Daroussin.Xr rcorder 8 ,
550afe61c15SRodney W. Grimes.Xr reboot 8 ,
551*e5accd3cSStefan Eßer.Xr savecore 8 ,
552*e5accd3cSStefan Eßer.Xr sysrc 8
553afe61c15SRodney W. Grimes.Sh HISTORY
554afe61c15SRodney W. GrimesThe
555afe61c15SRodney W. Grimes.Nm
5568d74f63dSPhilippe Charnierutility appeared in
557afe61c15SRodney W. Grimes.Bx 4.0 .
558