Since I need that script, I did create one from the original isc-dhcp-server.init.d. You can use it in parallel to the old DHCP version. You'll need to have your config file in /etc/dhcp/dhcpd6.conf and the default file in /etc/default/isc-dhcp6-server (which has the same syntax that the old one).

As always, feedback is welcome to improve the script, and please tell me if I can help integrating it to the package.

By the way, IMHO this is _not_ a feature but a bug, since the binary bundles with the support of a whole new protocol (DHCPv6) that you cannot use by just configuring the server. Moreover, whith IPv4 depletion, it'd be nice to have the next stable Debian to properly support IPv6, which is almost done since most of softwares do support IPv6, and only some Debian wrappers are missing.</my 2 cents>

--
Rémy Sanchez
#!/bin/sh 
#
#

### BEGIN INIT INFO
# Provides:          isc-dhcp6-server
# Required-Start:    $remote_fs $network $syslog
# Required-Stop:     $remote_fs $network $syslog
# Should-Start:      $local_fs slapd $named
# Should-Stop:       $local_fs slapd
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: DHCPv6 server
# Description:       Dynamic Host Configuration Protocol for IPv6 Server
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin

test -f /usr/sbin/dhcpd || exit 0

# It is not safe to start if we don't have a default configuration...
if [ ! -f /etc/default/isc-dhcp6-server ]; then
        echo "/etc/default/isc-dhcp6-server does not exist! - Aborting..."
        echo "Run 'dpkg-reconfigure isc-dhcp-server' to fix the problem."
        exit 0
fi

. /lib/lsb/init-functions

# Read init script configuration (so far only interfaces the daemon
# should listen on.)
[ -f /etc/default/isc-dhcp6-server ] && . /etc/default/isc-dhcp6-server

NAME=dhcpd
DESC="ISC DHCPv6 server"
DHCPDPID=/var/run/dhcpd6.pid
CONFFILE=/etc/dhcp/dhcpd6.conf

test_config()
{
        if ! /usr/sbin/dhcpd -t -6 -cf "$CONFFILE" -q > /dev/null 2>&1; then
                echo "dhcpd self-test failed. Please fix the config file."
                echo "The error was: "
                /usr/sbin/dhcpd -t -6 -cf "$CONFFILE"
                exit 1
        fi
}

# single arg is -v for messages, -q for none
check_status()
{
    if [ ! -r "$DHCPDPID" ]; then
        test "$1" != -v || echo "$NAME is not running."
        return 3
    fi
    if read pid < "$DHCPDPID" && ps -p "$pid" > /dev/null 2>&1; then
        test "$1" != -v || echo "$NAME is running."
        return 0
    else
        test "$1" != -v || echo "$NAME is not running but $DHCPDPID exists."
        return 1
    fi
}

case "$1" in
        start)
                test_config
                log_daemon_msg "Starting $DESC" "$NAME"
                start-stop-daemon --start --quiet --pidfile $DHCPDPID \
                        --exec /usr/sbin/dhcpd -- -6 -q $INTERFACES
                sleep 2

                if check_status -q; then
                        log_end_msg 0
                else
                        log_failure_msg "check syslog for diagnostics."
                        log_end_msg 1
                        exit 1
                fi
                ;;
        stop)
                log_daemon_msg "Stopping $DESC" "$NAME"
                start-stop-daemon --stop --quiet --pidfile $DHCPDPID
                log_end_msg $?
                rm -f "$DHCPDPID"
                ;;
        restart | force-reload)
                test_config
                $0 stop
                sleep 2
                $0 start
                if [ "$?" != "0" ]; then
                        exit 1
                fi
                ;;
        status)
                echo -n "Status of $DESC: "
                check_status -v
                exit "$?"
                ;;
        *)
                echo "Usage: $0 {start|stop|restart|force-reload|status}"
                exit 1 
esac

exit 0

Reply via email to