OpenBSD's new rcctl(8) utility

OpenBSD 5.7 includes a new control utility, rcctl(8), for managing daemons/services. Manually editing /etc/rc.conf.local or rc.conf(5) will still be supported, however, this new method will make scripting configuration easier and provide an equivalent to service(8) on Linux and sysrc(8) on FreeBSD.

rcctl - configure and control daemons and services

Examples from the manual page for rcctl(8), with a few additional:

Disable ntpd(8) and check its status, returns 1 if disabled:

# rcctl disable ntpd		# alias for: 'set ntpd status off'
$ rcctl get ntpd flags
NO 
$ rcctl getdef ntpd		# display default flags/variables for ntpd; see rc.d(8)
ntpd_class=daemon
ntpd_flags=
ntpd_rtable=0
ntpd_timeout=30
ntpd_user=root
$ rcctl get ntpd status	# (no output)
$ echo $? 
1

Enable and set ntpd(8) flags, also check its status, 0 if enabled:

# rcctl enable ntpd		# alias for: 'set ntpd status on'
# rcctl set ntpd flags -s	# example; see ntpd(8) for details
$ rcctl get ntpd flags
-s
$ rcctl get ntpd		# display current flags/variables for ntpd; see rc.conf(5)
ntpd_class=daemon
ntpd_flags=-s
ntpd_rtable=0
ntpd_timeout=30
ntpd_user=root
$ rcctl get ntpd status	# (no output)
$ echo $? 
0

Start ntpd(8) and check that it is running ('start' and 'check' are actions passed to rc.d(8) scripts):

# rcctl start ntpd		# hint: cp /etc/examples/ntpd.conf /etc/ntpd.conf
ntpd(ok) 
# rcctl check ntpd 
ntpd(ok) 
# echo $? 
0

Display all daemons/services that are on, but not necessarily started:

$ rcctl ls on 			# lsargs: all/failed/off/on/started/stopped
check_quotas
cron
library_aslr
ntpd
pf
pflogd
slaacd
smtpd
sndiod
syslogd
XXX: 'getall' was deprecated in 5.9 with 'ls lsargs', see here.

Perhaps useful, check if a daemon/service exists, returns 2 ENOENT if not:

$ rcctl get nginx
rcctl: service nginx does not exist
$ echo $?
2

Conclusion

rcctl(8) was written by Antoine Jacoutot (ajacoutot@), assisting automated configuration frameworks like Puppet or Ansible and sysadmins in general.

You can tell him how much you like it on Twitter: @ajacoutot


Copyright © 2018 Bryan Steele.


π