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