1.\" $OpenBSD: rcctl.8,v 1.46 2024/09/29 14:36:13 kn 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: September 29 2024 $ 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 daemon Ns | Ns Ar service Op Ar variable Op Ar argument ... 27.Nm rcctl 28.Op Fl df 29.Sm off 30.Cm check | configtest | reload | restart | start | stop 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 | off | on | 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 execdir , 66.Cm flags , 67.Cm logger , 68.Cm rtable , 69.Cm status , 70.Cm timeout 71or 72.Cm user 73.Pc : 74.Bl -tag -width Ds 75.It Oo Fl df Oc Ar action daemon ... 76Run the 77.Xr rc.d 8 78.Ar daemon 79scripts with the 80.Ar action 81argument, passing through the specified options, if any. 82.It Cm disable Ar service ... | daemon ... 83Alias for 84.Cm set Ar service Ns | Ns Ar daemon Cm status off . 85.It Cm enable Ar service ... | daemon ... 86Alias for 87.Cm set Ar service Ns | Ns Ar daemon Cm status on . 88.It Cm get Ar service | daemon Op Ar variable 89Display the value of 90.Ar service 91or 92.Ar daemon Ns _ Ns Ar variable . 93If 94.Ar variable 95is empty, display all 96.Ar service 97or 98.Ar daemon 99variables and values in a format 100compatible with 101.Xr rc.conf 8 . 102When 103.Ar daemon 104is set to 105.Qq all , 106.Ar variable 107must not be set and 108.Nm 109will display all services and daemons variables. 110.It Cm getdef Ar service | daemon Op Ar variable 111Like 112.Cm get 113but returns the default values. 114.It Cm ls Ar lsarg 115Display a list of services and daemons matching 116.Ar lsarg , 117which can be one of: 118.Pp 119.Bl -tag -width stopped -offset indent -compact 120.It Cm all 121all services and daemons 122.It Cm failed 123enabled but stopped daemons 124.It Cm off 125disabled services and daemons 126.It Cm on 127enabled services and daemons 128.It Cm rogue 129daemons which are disabled but currently running 130.It Cm started 131running daemons 132.It Cm stopped 133stopped daemons 134.El 135.It Cm order Op Ar daemon ... 136Move the specified package daemons to the beginning of 137.Va pkg_scripts . 138They need to be already enabled. 139If no 140.Ar daemon 141is specified, display the current order. 142.Pp 143The 144.Cm order 145command is only needed after enabling a new daemon 146that needs to run before one or more already enabled daemons. 147Specify the new daemon preceded by all that need to run before it, 148but not the ones depending on it. 149.It Cm set Ar service | daemon variable Op Ar argument ... 150For a daemon, set the variable 151.Ar daemon Ns _ Ns Ar variable 152to the specified arguments. 153If 154.Ar variable 155is already set, 156.Ar daemon Ns _ Ns Ar variable 157is reset to the optionally provided arguments or to its default value. 158.Pp 159The 160.Cm status 161.Ar variable 162must be provided with the 163.Cm on 164or 165.Cm off 166arguments. 167It is used to enable or disable 168.Ar service 169or 170.Ar daemon 171in 172.Xr rc.conf.local 8 . 173When a disabled package daemon is enabled, it is appended to the end of 174.Va pkg_scripts . 175When a package daemon is disabled, it is removed from 176.Va pkg_scripts 177and its variables are removed if any. 178.El 179.Sh EXIT STATUS 180.Nm Ar action 181returns with the exit status of the 182.Xr rc.d 8 183.Ar daemon 184script. 185.Nm Cm get Ar daemon | service Op Cm status 186exits with 0 if the daemon or service is enabled and 1 if it is not. 187.Nm Cm getdef Ar daemon | service Op Cm status 188exits with 0 if the daemon or service is enabled by default 189and 1 if it is not. 190.Nm Cm ls failed | rogue 191exits with 1 if an enabled daemon is not running or vice versa. 192Otherwise, the 193.Nm 194utility exits with 0 on success, and >0 if an error occurs 195.Po 2 indicates a non-existent 196.Ar daemon | service 197.Pc . 198.Sh EXAMPLES 199Enable and set 200.Xr apmd 8 201flags: 202.Bd -literal -offset indent 203# rcctl set apmd status on 204# rcctl set apmd flags -A 205# rcctl get apmd 206apmd_class=daemon 207apmd_execdir= 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