bind10 Init Script

ISC release the first release candidate for BIND 10 1.0.0 this week. I decided to give it a try since I’ve been a fan of ISC BIND and DHCPD for a long time, and BIND 10 plans to bring the two together.

There are plenty of guides on building it out there, but I was unable to find a sysvinit style init script for my Debian needs. I found an upstart example in the Ubuntu 12.04 LTS System Notes on the wiki, but I’m not going to dirty up any Debian box with upstart. Here’s what I came up with.

### BEGIN INIT INFO
# Provides:          bind10
# Required-Start:    networking
# Required-Stop:     networking
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start and stop bind10
# Description:       bind10 is a Domain Name Server (DNS) with experimental 
#        DHCPv4 and DHCPv6 server support
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
DAEMON=/usr/local/sbin/bind10
BINDCTL=/usr/local/bin/bindctl
BINDUSER=bind
PIDFILE=/var/run/bind10/bind10.pid
OPTIONS="--user=${BINDUSER} --pid-file=${PIDFILE}"

test -f /etc/default/bind10 && . /etc/default/bind10

. /lib/lsb/init-functions

mkdir -p /var/run/bind10
chown root:bind /var/run/bind10
chmod 775 /var/run/bind10

case "$1" in
    start)
        log_daemon_msg "Starting domain name service..." "bind10"
        if start-stop-daemon --start --oknodo --quiet --background --exec ${DAEMON} -- ${OPTIONS}
        then
            log_end_msg 0
        else
            log_end_msg 1
        fi
    ;;

    stop)
        log_daemon_msg "Stopping domain name service..." "bind10"
        start-stop-daemon --stop --oknodo --quiet --pidfile ${PIDFILE}
        log_end_msg 0
    ;;

    restart)
        $0 stop
        $0 start
    ;;

    status)
        ret=0
        status_of_proc -p /var/run/bind10/bind10.pid /usr/local/libexec/bind10/b10-init bind10 2>/dev/null || ret=$?
        exit $ret
    ;;

    *)
        log_action_msg "Usage: /etc/init.d/bind10 {start|stop|restart|status}"
        exit 1
    ;;
esac

exit 0

Assuming you installed bind10 under the default prefix of /usr/local, you should be able to copy and paste that into /etc/init.d/bind10, then run the following:

sudo chmod +x /etc/init.d/bind10
sudo update-rc.d bind10 defaults
sudo service bind10 start

You'll still need to follow the steps in the BIND 10 Guide to get things going, but the starting and stopping was something I had to get sorted before I got any farther into the setup process.

One thought on “bind10 Init Script

  1. shiva says:

    It didn’t work in centos.
    My default bind10 path is /opt/bind10 not /usr/local/bind10.

    Can you pls help

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>