#! /bin/sh 

### BEGIN INIT INFO
# Provides:          pppoe-server
# Required-Start:    $network $syslog $remote_fs
# Required-Stop:     $network $syslog $remote_fs
# Default-Start:     
# Default-Stop:      0 1 6
# Short-Description: pppoe-server daemon
# Description:       pppoe-server daemon 
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/pppoe-server
NAME=pppoe-server
DESC=pppoe-server

test -x $DAEMON || exit 0

PIDFILE=/var/run/$NAME.pid

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --oknodo --quiet --pidfile $PIDFILE \
		--make-pidfile --background --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
		--exec $DAEMON
	echo "$NAME."
	;;
  force-reload)
	# check whether $DAEMON is running. If so, restart
	start-stop-daemon --stop --test --quiet --pidfile \
		$PIDFILE --exec $DAEMON \
	&& $0 restart \
	|| exit 0
	;;
  restart)
	if start-stop-daemon --stop --test --quiet --pidfile \
	   $PIDFILE --exec $DAEMON ; then
	       echo -n "Restarting $DESC: "
	       start-stop-daemon --stop --quiet --pidfile \
		   $PIDFILE --exec $DAEMON
	    sleep 1
        else
            echo -n "Starting $DESC: "
        fi
	start-stop-daemon --start --oknodo --quiet --pidfile \
        	$PIDFILE --make-pidfile --background \
                --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
