1.\" $OpenBSD: rc.d.8,v 1.16 2011/07/08 17:43:58 sthen Exp $ 2.\" 3.\" Copyright (c) 2011 Robert Nagy, Antoine Jacoutot, Ingo Schwarze 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19.\" IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd $Mdocdate: July 8 2011 $ 28.Dt RC.D 8 29.Os 30.Sh NAME 31.Nm rc.d 32.Nd daemon control scripts 33.Sh SYNOPSIS 34.Nm /etc/rc.d/ Ns Ar daemon action 35.Sh DESCRIPTION 36The 37.Pa /etc/rc.d 38directory contains shell scripts to start, stop, and reconfigure daemon 39programs 40.Pq Dq services . 41.Pp 42Services installed from 43.Xr packages 7 44may be started at boot time in the order specified by the 45.Va pkg_scripts 46variable from 47.Xr rc.conf 8 ; 48the order will be reversed during shutdown. 49Services comprising 50.Ox 51base are started by 52.Xr rc 8 . 53.Pp 54Each such script responds to the following 55.Ar actions : 56.Pp 57.Bl -tag -width restart -offset indent -compact 58.It Cm start 59Start the service, if not already running. 60.It Cm stop 61Stop the service. 62.It Cm reload 63Tell the daemon to reload its configuration. 64.It Cm restart 65Perform a stop, then a start. 66.It Cm check 67Return 0 if the daemon is running or 1 if it is not. 68.El 69.Sh ENVIRONMENT 70Daemon control scripts use a fixed number of 71.Xr sh 1 72variables when starting a daemon. 73The following two can be overridden by site-specific values provided in 74.Xr rc.conf.local 8 : 75.Pp 76.Bl -tag -width daemon_flags -offset indent -compact 77.It Ar daemon Ns _flags 78Arguments to call the daemon with. 79If set to 80.Dq NO , 81it will prevent the daemon from starting even when listed in 82.Va pkg_scripts . 83.It Ar daemon Ns _user 84User to run the daemon as, using 85.Xr su 1 . 86.El 87.Pp 88To obtain the actual variable names, replace 89.Ar daemon 90with the name of the script. 91For example, postgres is managed through 92.Pa /etc/rc.d/postgresql . 93To run the daemon using a site-specific user account, define the following in 94.Xr rc.conf.local 8 : 95.Pp 96.Dl postgresql_user=mypgsqluser 97.Pp 98Each script may define its own defaults, as explained in 99.Xr rc.subr 8 . 100.Pp 101.Va daemon_class 102is a special read-only variable. 103It is set to 104.Dq daemon 105unless there is a login class configured in 106.Xr login.conf 5 107with the same name as the 108.Nm rc.d 109script itself, 110in which case it will be set to that login class. 111.Bl -tag -width "RC_DEBUG" 112.It Va RC_DEBUG 113Setting this variable will print the function names as they are called 114and prevent the 115.Xr rc.subr 8 116framework from redirecting stdin and stderr to /dev/null. 117This is used to allow debugging of failed 118.Ar actions . 119.El 120.Sh FILES 121.Bl -tag -width Ds 122.It Pa /etc/rc.d/ 123Directory containing daemon control scripts. 124.It Pa /etc/rc.d/rc.subr 125Functions and variables used by 126.Nm rc.d 127scripts. 128.El 129.Sh SEE ALSO 130.Xr rc 8 , 131.Xr rc.conf 8 , 132.Xr rc.subr 8 133.Sh HISTORY 134The 135.Pa /etc/rc.d 136directory 137first appeared in 138.Ox 4.9 . 139.Sh BUGS 140Changing 141.Ar daemon Ns _flags 142in 143.Xr rc.conf.local 8 144will change the corresponding pattern used with 145.Xr pkill 1 , 146so that 147.Ar actions 148may not work on already running processes. 149