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:

# rcctl disable ntpd	# alias for: 'set ntpd status off'
# rcctl get ntpd flags
NO 
# rcctl get ntpd status	# (no output)
# echo $? 
1

Enable and set ntpd(8) flags:

# rcctl enable ntpd	# alias for: 'set ntpd status on', pre-5.7 'enable' accepted 'flags'
# rcctl set ntpd flags -s
# rcctl get ntpd flags
-s
# 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 and their rc.conf(5) flags, filtering out disabled and variables:

XXX: 'getall' will be deprecated after 5.8 with 'ls lsargs', see here.
# rcctl getall | grep -v NO | grep -Ev '_(timeout|user)'
cron_flags=
ntpd_flags=-s
pflogd_flags=
smtpd_flags=
sndiod_flags=
sshd_flags=
syslogd_flags=
check_quotas=YES
pf=YES

Check if a daemon/service exists, returns 2 ENOENT if not:

# rcctl get httpd
httpd_flags=NO
httpd_timeout=30
httpd_user=root
# 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 © 2015 Bryan Steele.


π