OxideBSD
RC.SUBR(8) System Manager's Manual RC.SUBR(8)

rc.subr — functions for rc.d scripts

. /etc/rc.subr


checkyesno var

check_pidfile pidfile procname

check_process procname

debug message

err exitval message

force_depend script [var]

info message

load_rc_config [name]

run_rc_command command [argument ...]

wait_for_pids pid ...

warn message

The functions of FreeBSD's rc.subr are built into init_sh(8), so that rc(8) scripts written for it run unchanged. . /etc/rc.subr is accepted and has no effect in init_sh(8); a script started by any other shell re-runs itself under init_sh(8).

A typical script:

#!/sbin/init_sh
#
# PROVIDE: food
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr

name="food"
rcvar="food_enable"
command="/usr/sbin/food"
pidfile="/var/run/food.pid"

load_rc_config $name
run_rc_command "$1"
var
Exit 0 if the variable var is “YES”, “TRUE”, “ON” or “1”, and 1 if it is “NO”, “FALSE”, “OFF” or “0”, in any case. Any other value is reported and counts as no.
pidfile procname
Print the process ID in pidfile if that process exists and is running procname.
procname
Print the IDs of the processes running procname.
message
Print message on the standard error if rc_debug is enabled.
exitval message
Print message on the standard error and exit with status exitval.
script
Start the service /etc/rc.d/script if it is not running, whether or not it is enabled.
message
Print message if rc_info is enabled.
[name]
Load /etc/defaults/rc.conf and the files in rc_conf_files, once, and then /etc/rc.conf.d/name if it exists. The files are read, not run: see rc.conf(5).
command [argument ...]
Carry out command, as described in rc(8), using the variables below.
pid ...
Wait until the processes have exited.
message
Print message on the standard error.

run_rc_command uses these variables:

name
The service's name. Required.
rcvar
The rc.conf(5) variable enabling the service. If empty, the service is always enabled.
command
The program to start, followed by ${name}_flags from rc.conf(5) (or flags) and command_args. ${name}_program overrides it.
pidfile
The file holding the running service's process ID.
procname
The program name that identifies the running service; defaults to command.
sig_stop
The signal that stops the service; default TERM.
extra_commands
Commands besides the standard ones.
required_dirs, required_files
Must exist for the service to start.
${command}_cmd
Replaces the built-in handling of command.
${command}_precmd, ${command}_postcmd
Run before and after command. A failing _precmd stops the command.

rc.conf(5), init_sh(8), rc(8), rcorder(8)

rc.subr first appeared in NetBSD 1.3. These built-ins were written for OxideBSD.

${name}_user is not supported yet.

September 25, 2026 OxideBSD