xref: /openbsd-src/share/man/man8/rc.d.8 (revision 0b7734b3d77bb9b21afec6f4621cae6c805dbd45)
1.\"	$OpenBSD: rc.d.8,v 1.31 2016/04/26 17:43:12 ajacoutot 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: April 26 2016 $
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
35.Op Fl df
36.Ar action
37.Sh DESCRIPTION
38The
39.Pa /etc/rc.d
40directory contains shell scripts to start, stop, and reconfigure daemon
41programs
42.Pq Dq services .
43.Pp
44Services installed from
45.Xr packages 7
46may be started at boot time in the order specified by the
47.Va pkg_scripts
48variable from
49.Xr rc.conf 8 ;
50the order will be reversed during shutdown.
51Services comprising
52.Ox
53base are started by
54.Xr rc 8 .
55.Pp
56The options are as follows:
57.Bl -tag -width Ds
58.It Fl d
59Setting this option will print the function names as they are called
60and prevent the
61.Xr rc.subr 8
62framework from redirecting stdin and stderr to /dev/null.
63This is used to allow debugging of failed
64.Ar actions .
65.It Fl f
66This option only affects the
67.Cm start
68action.
69It will forcibly start the daemon whatever value
70.Va daemon_flags
71is set to.
72If
73.Va daemon_flags
74is set to
75.Dq NO ,
76execution will continue with the script's own defaults unless other
77flags are specified.
78.El
79.Pp
80Each such script responds to the following
81.Ar actions :
82.Pp
83.Bl -tag -width restart -offset indent -compact
84.It Cm start
85Start the service, if not already running.
86.It Cm stop
87Stop the service.
88.It Cm reload
89Tell the daemon to reload its configuration.
90.It Cm restart
91Perform a stop, then a start.
92.It Cm check
93Return 0 if the daemon is running or 1 if it is not.
94.El
95.Sh ENVIRONMENT
96Daemon control scripts use a fixed number of
97.Xr sh 1
98variables when starting a daemon.
99The following three can be overridden by site-specific values provided in
100.Xr rc.conf.local 8 :
101.Bl -tag -width daemon_timeout -offset indent
102.It Ar daemon Ns _flags
103Additional arguments to call the daemon with.
104These will be appended to any mandatory arguments already contained in the
105.Va daemon
106variable defined in the control script.
107If
108.Ar daemon Ns _flags
109is set to
110.Dq NO ,
111it will prevent the daemon from starting even when listed in
112.Va pkg_scripts .
113.It Ar daemon Ns _rtable
114Routing table to run the daemon under, using
115.Xr route 8 .
116.It Ar daemon Ns _timeout
117Maximum time in seconds to wait for the
118.Cm start
119(only if
120.Va rc_bg
121is set),
122.Cm stop
123and
124.Cm reload
125actions to return.
126This is only guaranteed with the default
127.Ic rc_start ,
128.Ic rc_stop
129and
130.Ic rc_reload
131functions.
132.It Ar daemon Ns _user
133User to run the daemon as, using
134.Xr su 1 .
135.El
136.Pp
137To obtain the actual variable names, replace
138.Ar daemon
139with the name of the script.
140For example, postgres is managed through
141.Pa /etc/rc.d/postgresql :
142.Pp
143.Dl daemon_flags=-w -l /var/postgresql/logfile
144.Pp
145To override this and increase the debug log level (keeping the existing
146flags), define the following in
147.Xr rc.conf.local 8 :
148.Pp
149.Dl postgresql_flags=-w -l /var/postgresql/logfile -d 5
150.Pp
151Each script may define its own defaults, as explained in
152.Xr rc.subr 8 .
153.Pp
154.Va daemon_class
155is a special read-only variable.
156It is set to
157.Dq daemon
158unless there is a login class configured in
159.Xr login.conf 5
160with the same name as the
161.Nm rc.d
162script itself,
163in which case it will be set to that login class.
164This allows setting many initial process properties, for example
165environment variables, scheduling priority, and process limits
166such as maximum memory use and number of files.
167.Sh FILES
168.Bl -tag -width Ds
169.It Pa /etc/rc.d/
170Directory containing daemon control scripts.
171.It Pa /etc/rc.d/rc.subr
172Functions and variables used by
173.Nm rc.d
174scripts.
175.It Pa /var/run/rc.d/
176Directory containing files recording the variables of currently running daemons.
177Some are informational and some are for matching daemons using
178.Xr pgrep 1
179and
180.Xr pkill 1 .
181.El
182.Sh SEE ALSO
183.Xr rc 8 ,
184.Xr rc.conf 8 ,
185.Xr rc.subr 8 ,
186.Xr rcctl 8
187.Sh HISTORY
188The
189.Pa /etc/rc.d
190directory
191first appeared in
192.Ox 4.9 .
193