From FreeBSDwiki
Jump to: navigation, search

/usr/local/etc/rc.d isn't actually a config file, it's a directory. Any executable shell script in this directory will be executed (using the Bourne shell) with the argument "start" when the system boots, and again with the argument "stop" when the system is shut down.

You may find this generic rc.d script (shown as I use it to start bind9) handy for general purpose use:


case "$1" in
        /usr/sbin/named -c /etc/namedb/named.conf &
        echo "bind9"
        exit 0
        exec killall named
        echo "Usage: `basename $0` {start|stop}" >&2
        exit 64

Note that scripts in /usr/local/etc/rc.d cannot and will not execute, at boot time or otherwise, if you do not set the permissions to allow their execution. In most cases, you will want to chmod 755 any rc.d scripts, though you may also consider 700 on root-owned rc.d scripts to make sure that unprivileged users don't mess with attempting to start or stop sensitive services.

The most recent versions of FreeBSD make rc.conf more integral to the startup of local services. For information about the way that daemons are started in the newest versions of FreeBSD, see rc.subr.

Personal tools