1.\" $OpenBSD: rcctl.8,v 1.41 2022/07/13 13:36:12 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: July 13 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 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 arguments 150For a daemon, set the variable 151.Ar daemon Ns _ Ns Ar variable 152to the specified 153.Ar arguments . 154If 155.Ar variable 156is already set, 157.Ar daemon Ns _ Ns Ar variable 158is reset to the optionally provided 159.Ar arguments 160or to its default value. 161.Pp 162The 163.Cm status 164.Ar variable 165must be provided with the 166.Cm on 167or 168.Cm off 169.Ar arguments . 170It is used to enable or disable 171.Ar service 172or 173.Ar daemon 174in 175.Xr rc.conf.local 8 . 176When a disabled package daemon is enabled, it is appended to the end of 177.Va pkg_scripts . 178When a package daemon is disabled, it is removed from 179.Va pkg_scripts 180and its variables are removed if any. 181.El 182.Sh EXIT STATUS 183.Nm Ar action 184returns with the exit status of the 185.Xr rc.d 8 186.Ar daemon 187script. 188.Nm Cm get Ar daemon | service Op Cm status 189exits with 0 if the daemon or service is enabled and 1 if it is not. 190.Nm Cm getdef Ar daemon | service Op Cm status 191exits with 0 if the daemon or service is enabled by default 192and 1 if it is not. 193.Nm Cm ls failed 194exits with 1 if an enabled daemon is not running. 195Otherwise, the 196.Nm 197utility exits with 0 on success, and >0 if an error occurs 198.Po 2 indicates a non-existent 199.Ar daemon | service 200.Pc . 201.Sh EXAMPLES 202Enable and set 203.Xr apmd 8 204flags: 205.Bd -literal -offset indent 206# rcctl set apmd status on 207# rcctl set apmd flags -A 208# rcctl get apmd 209apmd_class=daemon 210apmd_execdir= 211apmd_flags=-A 212apmd_logger= 213apmd_rtable=0 214apmd_timeout=30 215apmd_user=root 216# echo $? 2170 218.Ed 219.Pp 220The recommended way to run a second copy of a given daemon for a 221different purpose is to create a symbolic link to its 222.Xr rc.d 8 223control script: 224.Bd -literal -offset indent 225# ln -s /etc/rc.d/snmpd /etc/rc.d/snmpd6 226# rcctl set snmpd6 status on 227# rcctl set snmpd6 flags -D addr=2001:db8::1234 228# rcctl start snmpd6 229.Ed 230.Sh SEE ALSO 231.Xr rc.conf.local 8 , 232.Xr rc.d 8 233.Sh HISTORY 234.Nm 235first appeared in 236.Ox 5.7 . 237.Sh AUTHORS 238.Nm 239was written by 240.An Antoine Jacoutot Aq Mt ajacoutot@openbsd.org . 241