pavement

Usr/local/etc/rc.d

From FreeBSDwiki
Revision as of 15:40, 20 June 2006 by Ninereasons (Talk | contribs)
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:

#!/bin/sh

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

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