xref: /openbsd-src/usr.sbin/rcctl/rcctl.8 (revision c1a45aed656e7d5627c30c92421893a76f370ccb)
1.\"	$OpenBSD: rcctl.8,v 1.39 2022/04/01 10:13:35 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: April 1 2022 $
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.Sm off
30.Cm check | reload | restart | stop | start
31.Sm on
32.Ar daemon ...
33.Nm rcctl
34.Cm disable Ns | Ns Cm enable Ns | Ns Cm order
35.Op Ar daemon ...
36.Nm rcctl
37.Cm ls
38.Sm off
39.Cm all | failed | on | off | rogue | started | stopped
40.Sm on
41.Sh DESCRIPTION
42The
43.Nm
44utility can enable or disable a base system
45.Ar service
46or a base system or package
47.Ar daemon
48in
49.Xr rc.conf.local 8
50or display its configuration and status.
51For a
52.Ar daemon ,
53it can also change the command line arguments, the user to run as, the
54.Xr rc.d 8
55action timeout or call its
56.Xr rc.d 8
57.Ar daemon
58control script.
59.Pp
60The following commands are available
61.Po
62.Ar variable
63can be one of
64.Cm class ,
65.Cm flags ,
66.Cm logger ,
67.Cm rtable ,
68.Cm status ,
69.Cm timeout
70or
71.Cm user
72.Pc :
73.Bl -tag -width Ds
74.It Oo Fl df Oc Ar action daemon ...
75Run the
76.Xr rc.d 8
77.Ar daemon
78scripts with the
79.Ar action
80argument, passing through the specified options, if any.
81.It Cm disable Ar service ... | daemon ...
82Alias for
83.Cm set Ar service Ns | Ns Ar daemon Cm status off .
84.It Cm enable Ar service ... | daemon ...
85Alias for
86.Cm set Ar service Ns | Ns Ar daemon Cm status on .
87.It Cm get Ar service | daemon Op Ar variable
88Display the value of
89.Ar service
90or
91.Ar daemon Ns _ Ns Ar variable .
92If
93.Ar variable
94is empty, display all
95.Ar service
96or
97.Ar daemon
98variables and values in a format
99compatible with
100.Xr rc.conf 8 .
101When
102.Ar daemon
103is set to
104.Qq all ,
105.Ar variable
106must not be set and
107.Nm
108will display all services and daemons variables.
109.It Cm getdef Ar service | daemon Op Ar variable
110Like
111.Cm get
112but returns the default values.
113.It Cm ls Ar lsarg
114Display a list of services and daemons matching
115.Ar lsarg ,
116which can be one of:
117.Pp
118.Bl -tag -width stopped -offset indent -compact
119.It Cm all
120all services and daemons
121.It Cm failed
122enabled but stopped daemons
123.It Cm off
124disabled services and daemons
125.It Cm on
126enabled services and daemons
127.It Cm rogue
128daemons which are disabled but currently running
129.It Cm started
130running daemons
131.It Cm stopped
132stopped daemons
133.El
134.It Cm order Op Ar daemon ...
135Move the specified package daemons to the beginning of
136.Va pkg_scripts .
137They need to be already enabled.
138If no
139.Ar daemon
140is specified, display the current order.
141.Pp
142The
143.Cm order
144command is only needed after enabling a new daemon
145that needs to run before one or more already enabled daemons.
146Specify the new daemon preceded by all that need to run before it,
147but not the ones depending on it.
148.It Cm set Ar service | daemon variable Op Ar arguments
149For a daemon, set the variable
150.Ar daemon Ns _ Ns Ar variable
151to the specified
152.Ar arguments .
153If
154.Ar variable
155is already set,
156.Ar daemon Ns _ Ns Ar variable
157is reset to the optionally provided
158.Ar arguments
159or to its default value.
160.Pp
161The
162.Cm status
163.Ar variable
164must be provided with the
165.Cm on
166or
167.Cm off
168.Ar arguments .
169It is used to enable or disable
170.Ar service
171or
172.Ar daemon
173in
174.Xr rc.conf.local 8 .
175When a disabled package daemon is enabled, it is appended to the end of
176.Va pkg_scripts .
177When a package daemon is disabled, it is removed from
178.Va pkg_scripts
179and its variables are removed if any.
180.El
181.Sh EXIT STATUS
182.Nm Ar action
183returns with the exit status of the
184.Xr rc.d 8
185.Ar daemon
186script.
187.Nm Cm get Ar daemon | service Op Cm status
188exits with 0 if the daemon or service is enabled and 1 if it is not.
189.Nm Cm getdef Ar daemon | service Op Cm status
190exits with 0 if the daemon or service is enabled by default
191and 1 if it is not.
192.Nm Cm ls failed
193exits with 1 if an enabled daemon is not running.
194Otherwise, the
195.Nm
196utility exits with 0 on success, and >0 if an error occurs
197.Po 2 indicates a non-existent
198.Ar daemon | service
199.Pc .
200.Sh EXAMPLES
201Enable and set
202.Xr apmd 8
203flags:
204.Bd -literal -offset indent
205# rcctl set apmd status on
206# rcctl set apmd flags -A
207# rcctl get apmd
208apmd_class=daemon
209apmd_flags=-A
210apmd_logger=
211apmd_rtable=0
212apmd_timeout=30
213apmd_user=root
214# echo $?
2150
216.Ed
217.Pp
218The recommended way to run a second copy of a given daemon for a
219different purpose is to create a symbolic link to its
220.Xr rc.d 8
221control script:
222.Bd -literal -offset indent
223# ln -s /etc/rc.d/snmpd /etc/rc.d/snmpd6
224# rcctl set snmpd6 status on
225# rcctl set snmpd6 flags -D addr=2001:db8::1234
226# rcctl start snmpd6
227.Ed
228.Sh SEE ALSO
229.Xr rc.conf.local 8 ,
230.Xr rc.d 8
231.Sh HISTORY
232.Nm
233first appeared in
234.Ox 5.7 .
235.Sh AUTHORS
236.Nm
237was written by
238.An Antoine Jacoutot Aq Mt ajacoutot@openbsd.org .
239