xref: /openbsd-src/usr.sbin/rcctl/rcctl.8 (revision de8cc8edbc71bd3e3bc7fbffa27ba0e564c37d8b)
1.\"	$OpenBSD: rcctl.8,v 1.36 2021/02/27 09:28:04 ajacoutot Exp $
2.\"
3.\" Copyright (c) 2014 Antoine Jacoutot <ajacoutot@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: February 27 2021 $
18.Dt RCCTL 8
19.Os
20.Sh NAME
21.Nm rcctl
22.Nd configure and control daemons and services
23.Sh SYNOPSIS
24.Nm rcctl
25.Cm get Ns | Ns Cm getdef Ns | Ns Cm set
26.Ar service | daemon Op Ar variable Op Ar arguments
27.Nm rcctl
28.Op Fl df
29.Ar action daemon ...
30.Nm rcctl
31.Cm disable Ns | Ns Cm enable Ns | Ns Cm order
32.Op Ar daemon ...
33.Nm rcctl
34.Cm ls
35.Ar lsarg
36.Sh DESCRIPTION
37The
38.Nm
39utility can enable or disable a base system
40.Ar service
41or a base system or package
42.Ar daemon
43in
44.Xr rc.conf.local 8
45or display its configuration and status.
46For a
47.Ar daemon ,
48it can also change the command line arguments, the user to run as, the
49.Xr rc.d 8
50action timeout or call its
51.Xr rc.d 8
52.Ar daemon
53control script.
54.Pp
55The following commands are available
56.Po
57.Ar variable
58can be one of
59.Cm class ,
60.Cm flags ,
61.Cm logger ,
62.Cm status ,
63.Cm timeout
64or
65.Cm user
66.Pc :
67.Bl -tag -width Ds
68.It Oo Fl df Oc Ar action daemon ...
69Run the
70.Xr rc.d 8
71.Ar daemon
72scripts with the
73.Ar action
74argument, passing through the specified options, if any.
75.It Cm disable Ar service ... | daemon ...
76Alias for
77.Cm set Ar service Ns | Ns Ar daemon Cm status off .
78.It Cm enable Ar service ... | daemon ...
79Alias for
80.Cm set Ar service Ns | Ns Ar daemon Cm status on .
81.It Cm get Ar service | daemon Op Ar variable
82Display the value of
83.Ar service
84or
85.Ar daemon Ns _ Ns Ar variable .
86If
87.Ar variable
88is empty, display all
89.Ar service
90or
91.Ar daemon
92variables and values in a format
93compatible with
94.Xr rc.conf 8 .
95When
96.Ar daemon
97is set to
98.Qq all ,
99.Ar variable
100must not be set and
101.Nm
102will display all services and daemons variables.
103.It Cm getdef Ar service | daemon Op Ar variable
104Like
105.Cm get
106but returns the default values.
107.It Cm ls Ar lsarg
108Display a list of services and daemons matching
109.Ar lsarg ,
110which can be one of:
111.Pp
112.Bl -tag -width stopped -offset indent -compact
113.It Cm all
114all services and daemons
115.It Cm failed
116enabled but stopped daemons
117.It Cm off
118disabled services and daemons
119.It Cm on
120enabled services and daemons
121.It Cm started
122running daemons
123.It Cm stopped
124stopped daemons
125.El
126.It Cm order Op Ar daemon ...
127Move the specified package daemons to the beginning of
128.Va pkg_scripts .
129They need to be already enabled.
130If no
131.Ar daemon
132is specified, display the current order.
133.Pp
134The
135.Cm order
136command is only needed after enabling a new daemon
137that needs to run before one or more already enabled daemons.
138Specify the new daemon preceded by all that need to run before it,
139but not the ones depending on it.
140.It Cm set Ar service | daemon variable Op Ar arguments
141For a daemon, set the variable
142.Ar daemon Ns _ Ns Ar variable
143to the specified
144.Ar arguments .
145If
146.Ar variable
147is already set,
148.Ar daemon Ns _ Ns Ar variable
149is reset to the optionally provided
150.Ar arguments
151or to its default value.
152.Pp
153The
154.Cm status
155.Ar variable
156must be provided with the
157.Cm on
158or
159.Cm off
160.Ar arguments .
161It is used to enable or disable
162.Ar service
163or
164.Ar daemon
165in
166.Xr rc.conf.local 8 .
167When a disabled package daemon is enabled, it is appended to the end of
168.Va pkg_scripts .
169When a package daemon is disabled, it is removed from
170.Va pkg_scripts
171and its variables are removed if any.
172.El
173.Sh EXIT STATUS
174.Nm Ar action
175returns with the exit status of the
176.Xr rc.d 8
177.Ar daemon
178script.
179.Nm Cm get Ar daemon | service Op Cm status
180exits with 0 if the daemon or service is enabled and 1 if it is not.
181.Nm Cm getdef Ar daemon | service Op Cm status
182exits with 0 if the daemon or service is enabled by default
183and 1 if it is not.
184.Nm Cm ls failed
185exits with 1 if an enabled daemon is not running.
186Otherwise, the
187.Nm
188utility exits with 0 on success, and >0 if an error occurs
189.Po 2 indicates a non-existent
190.Ar daemon | service
191.Pc .
192.Sh EXAMPLES
193Enable and set
194.Xr apmd 8
195flags:
196.Bd -literal -offset indent
197# rcctl set apmd status on
198# rcctl set apmd flags -A
199# rcctl get apmd
200apmd_class=daemon
201apmd_flags=-A
202apmd_logger=
203apmd_rtable=0
204apmd_timeout=30
205apmd_user=root
206# echo $?
2070
208.Ed
209.Pp
210The recommended way to run a second copy of a given daemon for a
211different purpose is to create a symbolic link to its
212.Xr rc.d 8
213control script:
214.Bd -literal -offset indent
215# ln -s /etc/rc.d/snmpd /etc/rc.d/snmpd6
216# rcctl set snmpd6 status on
217# rcctl set snmpd6 flags -D addr=2001:db8::1234
218# rcctl start snmpd6
219.Ed
220.Sh SEE ALSO
221.Xr rc.conf.local 8 ,
222.Xr rc.d 8
223.Sh HISTORY
224.Nm
225first appeared in
226.Ox 5.7 .
227.Sh AUTHORS
228.Nm
229was written by
230.An Antoine Jacoutot Aq Mt ajacoutot@openbsd.org .
231