#!/bin/sh

# Bring up/down PPTP/L2TP daemon

. /etc/sysconfig/rc.conf
. /bin/network-functions

SETSID=/usr/bin/setsid
PIDFILE=/var/run/vpn-handler.pid
LOGGER="/bin/logger -t $0"

SERVICE=vpnd
PROCESS_NAME=vpn-handler

do_start ()
{
	if ! ServiceCheckRunning1 ; then
		return $?
	fi

	$LOGGER "Starting PPTP/L2TP Daemon"
	$SETSID /bin/$PROCESS_NAME

	ServiceCheckRunning2

	return $?
}

do_stop ()
{
	ServiceStop

	return $?
}

do_stop_wait ()
{
	ServiceStopWaitable

	return $?
}

do_status ()
{
	ServiceStatus
	
	return $?
}

case "$1" in
	start)
		do_start
		;;
	stop)
		do_stop
		;;
	status)
		do_status
		;;
	restart)
		do_stop_wait
		do_start
		;;
	*)
		echo "Usage: $0 {start|stop|restart|status}"
		exit 1
esac

exit $?
