OpenBSD uses an rc(8) style startup.
- /etc/rc - Main script. Should not be edited.
- /etc/rc.conf - Configuration file used by /etc/rc to know what daemons should start with the system.
- /etc/netstart - Script used to initialize the network. Shouldn't be edited.
- /etc/rc.local - Script used for local administration. This is where new daemons or host specific information should be stored.
- /etc/rc.securelevel - Script which runs commands that must be run before the security level changes. See init(8)
- /etc/rc.shutdown - Script run on shutdown. Put anything you want done before shutdown in this file. See rc.shutdown(8)
How rc(8) Works
The main files a system administrator should concentrate on are /etc/rc.conf,
/etc/rc.local and /etc/rc.shutdown. To get a look of how the rc(8) procedure
works, here is a the flow:
- After the kernel is booted. /etc/rc is started.
- Filesystems checked. This will always be bypassed if the file /etc/fastboot exists. This is certainly not a good idea though.
- Configuration Variables are read in from /etc/rc.conf
- Filesystems are mounted
- Clears out /tmp and preserves any editor files
- Configures the network via /etc/netstart
- Configures your interfaces up.
- Sets your hostname, domainname, etc.
- Starts system daemons
- Does various checks. (quota's, savecore, etc)
- Local daemons are run, ala /etc/rc.local
Starting Daemons and Services that come with OpenBSD
Most daemons and services that come with OpenBSD by default can be started
on boot by simply editing the /etc/rc.conf configuration file. To start out
take a look at the default /etc/rc.conf file. You'll see lines similar to
this:
ftpd_flags=NO # for non-inetd use: ftpd_flags="-D"
A line like this shows that ftpd is not starting up with the system. (At
least not via rc(8), read the Anonymous FTP FAQ to read more about this.)
In any case, each line also has a comment showing you the flags for NORMAL
usage of that daemon or service. This doesn't mean that you must run that
daemon or service with those flags. You can always use man(1) to see how you
can have that daemon or service start up in any way you like. For example,
Here is the default line pertaining to httpd(8):
httpd_flags=NO # for normal use: "" (or "-DSSL" after reading ssl(8))
Here you can obviously see that starting up httpd normally no flags are
necessary. So a line like: " httpd_flags=""" would be necessary. But to
start httpd with ssl enabled. (Refer to the SSL FAQ or ssl(8)) You should
start with a line like: "httpd_flags="-DSSL"".
Starting up local daemons and configuration
For other daemons that you might install with the system via ports or other
ways, you will use the /etc/rc.local file. For example, I've installed a
daemon which lies at /usr/local/sbin/daemonx. I want this to start at boot
time. I would put an entry into /etc/rc.local like this:
if [ -x /usr/local/sbin/daemonx ]; then
echo -n ' daemonx'; /usr/local/sbin/daemonx
fi
From now on, this daemon will be run at boot. You will be able to see any
errors on boot, a normal boot with no errors would show a line like this:
Starting local daemons: daemonx.
rc.shutdown
/etc/rc.shutdown is a script that is run a shutdown. Anything you want done
before the system shuts down should be added to this file. If you have apm,
you can also set "powerdown=YES". Which will give you the equivalent of
"shutdown -p".