#! /bin/sh
### BEGIN INIT INFO
# Provides:          npd6
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog	$network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description: Provides the npd6 daemon.
# Short-Description: Provides the npd6 daemon.
### END INIT INFO

# Author: Sean Groarke, sgroarke@gmail.com>
# $HeadURL$
# $Id$

# Do NOT "set -e"

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="npd6 - Neighbor proxy Daemon IPv6"
NAME=npd6
DAEMON=/usr/bin/$NAME
# Check man page or --help to get more optional arguments
#DAEMON_ARGS="--debug -l /var/log/npd6.log"
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

do_reload() {
	#
	# If the daemon can reload its configuration without
	# restarting (for example, when it is sent a SIGHUP),
	# then implement that here.
	#
	log_daemon_msg "Doing a daemon reload - USR1"
	start-stop-daemon --stop --signal USR1 --quiet --pidfile $PIDFILE --name $NAME
	return 0
}

case "$1" in
  start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
	#do_start
	start-stop-daemon --start --exec $DAEMON -- $DAEMON_ARGS
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
	#do_stop
	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  status)
       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
       ;;
  restart|force-reload)
	log_daemon_msg "Restarting $DESC" "$NAME"
        start-stop-daemon --stop --retry=TERM/30/KILL/5 --exec $DAEMON
        start-stop-daemon --start --exec $DAEMON -- $DAEMON_ARGS 
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
	exit 3
	;;
esac

:
