1.\" $OpenBSD: rcctl.8,v 1.38 2021/10/23 08:19:27 sthen 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: October 23 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 | 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 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 rogue 127daemons which are disabled but currently running 128.It Cm started 129running daemons 130.It Cm stopped 131stopped daemons 132.El 133.It Cm order Op Ar daemon ... 134Move the specified package daemons to the beginning of 135.Va pkg_scripts . 136They need to be already enabled. 137If no 138.Ar daemon 139is specified, display the current order. 140.Pp 141The 142.Cm order 143command is only needed after enabling a new daemon 144that needs to run before one or more already enabled daemons. 145Specify the new daemon preceded by all that need to run before it, 146but not the ones depending on it. 147.It Cm set Ar service | daemon variable Op Ar arguments 148For a daemon, set the variable 149.Ar daemon Ns _ Ns Ar variable 150to the specified 151.Ar arguments . 152If 153.Ar variable 154is already set, 155.Ar daemon Ns _ Ns Ar variable 156is reset to the optionally provided 157.Ar arguments 158or to its default value. 159.Pp 160The 161.Cm status 162.Ar variable 163must be provided with the 164.Cm on 165or 166.Cm off 167.Ar arguments . 168It is used to enable or disable 169.Ar service 170or 171.Ar daemon 172in 173.Xr rc.conf.local 8 . 174When a disabled package daemon is enabled, it is appended to the end of 175.Va pkg_scripts . 176When a package daemon is disabled, it is removed from 177.Va pkg_scripts 178and its variables are removed if any. 179.El 180.Sh EXIT STATUS 181.Nm Ar action 182returns with the exit status of the 183.Xr rc.d 8 184.Ar daemon 185script. 186.Nm Cm get Ar daemon | service Op Cm status 187exits with 0 if the daemon or service is enabled and 1 if it is not. 188.Nm Cm getdef Ar daemon | service Op Cm status 189exits with 0 if the daemon or service is enabled by default 190and 1 if it is not. 191.Nm Cm ls failed 192exits with 1 if an enabled daemon is not running. 193Otherwise, the 194.Nm 195utility exits with 0 on success, and >0 if an error occurs 196.Po 2 indicates a non-existent 197.Ar daemon | service 198.Pc . 199.Sh EXAMPLES 200Enable and set 201.Xr apmd 8 202flags: 203.Bd -literal -offset indent 204# rcctl set apmd status on 205# rcctl set apmd flags -A 206# rcctl get apmd 207apmd_class=daemon 208apmd_flags=-A 209apmd_logger= 210apmd_rtable=0 211apmd_timeout=30 212apmd_user=root 213# echo $? 2140 215.Ed 216.Pp 217The recommended way to run a second copy of a given daemon for a 218different purpose is to create a symbolic link to its 219.Xr rc.d 8 220control script: 221.Bd -literal -offset indent 222# ln -s /etc/rc.d/snmpd /etc/rc.d/snmpd6 223# rcctl set snmpd6 status on 224# rcctl set snmpd6 flags -D addr=2001:db8::1234 225# rcctl start snmpd6 226.Ed 227.Sh SEE ALSO 228.Xr rc.conf.local 8 , 229.Xr rc.d 8 230.Sh HISTORY 231.Nm 232first appeared in 233.Ox 5.7 . 234.Sh AUTHORS 235.Nm 236was written by 237.An Antoine Jacoutot Aq Mt ajacoutot@openbsd.org . 238