xref: /openbsd-src/share/man/man8/rc.d.8 (revision 4c1e55dc91edd6e69ccc60ce855900fbc12cf34f)
1.\" 	$OpenBSD: rc.d.8,v 1.21 2012/02/22 10:38:24 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: February 22 2012 $
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
66Setting this option will force operations with the given action.
67If
68.Ar daemon Ns _flags
69is set to
70.Dq NO ,
71execution will continue with the script's own defaults unless other
72flags are specified.
73.El
74.Pp
75Each such script responds to the following
76.Ar actions :
77.Pp
78.Bl -tag -width restart -offset indent -compact
79.It Cm start
80Start the service, if not already running.
81.It Cm stop
82Stop the service.
83.It Cm reload
84Tell the daemon to reload its configuration.
85.It Cm restart
86Perform a stop, then a start.
87.It Cm check
88Return 0 if the daemon is running or 1 if it is not.
89.El
90.Sh ENVIRONMENT
91Daemon control scripts use a fixed number of
92.Xr sh 1
93variables when starting a daemon.
94The following two can be overridden by site-specific values provided in
95.Xr rc.conf.local 8 :
96.Pp
97.Bl -tag -width daemon_flags -offset indent -compact
98.It Ar daemon Ns _flags
99Arguments to call the daemon with.
100If set to
101.Dq NO ,
102it will prevent the daemon from starting even when listed in
103.Va pkg_scripts .
104.It Ar daemon Ns _user
105User to run the daemon as, using
106.Xr su 1 .
107.El
108.Pp
109To obtain the actual variable names, replace
110.Ar daemon
111with the name of the script.
112For example, postgres is managed through
113.Pa /etc/rc.d/postgresql .
114To run the daemon using a site-specific user account, define the following in
115.Xr rc.conf.local 8 :
116.Pp
117.Dl postgresql_user=mypgsqluser
118.Pp
119Each script may define its own defaults, as explained in
120.Xr rc.subr 8 .
121.Pp
122.Va daemon_class
123is a special read-only variable.
124It is set to
125.Dq daemon
126unless there is a login class configured in
127.Xr login.conf 5
128with the same name as the
129.Nm rc.d
130script itself,
131in which case it will be set to that login class.
132.Sh FILES
133.Bl -tag -width Ds
134.It Pa /etc/rc.d/
135Directory containing daemon control scripts.
136.It Pa /etc/rc.d/rc.subr
137Functions and variables used by
138.Nm rc.d
139scripts.
140.It Pa /var/run/rc.d/
141Directory containing files recording the
142.Va pexp
143variable used by
144.Xr pkill 1
145for currently running daemons.
146.El
147.Sh SEE ALSO
148.Xr rc 8 ,
149.Xr rc.conf 8 ,
150.Xr rc.subr 8
151.Sh HISTORY
152The
153.Pa /etc/rc.d
154directory
155first appeared in
156.Ox 4.9 .
157