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