#!/bin/sh
#
# pptpd         This shell script takes care of starting and stopping
#               pptp daemon.
#
# chkconfig: 2345 80 30
#
# description: PPTP is a Point-To-Point Tunnelling Protocol

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
# Check that networking is up.
SourceIfNotEmpty /etc/sysconfig/network &&
	[ "$NETWORKING" != no ] ||
	exit

SourceIfNotEmpty /etc/sysconfig/pptpd

EXE=/usr/sbin/pptpd
LOCKFILE=/var/lock/subsys/pptpd
RETVAL=0

start()
{
	echo -n "Starting pptp daemon: "
	daemon "$EXE"
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
	return $RETVAL
}

stop()
{
	echo -n "Stopping pptp daemon: "
	killproc "$EXE"
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
	return $RETVAL
}

restart()
{
	stop
	start
}


# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart|reload)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	status)
		status "$EXE"
		RETVAL=$?
		;;
	*)
		echo "Usage: ${0##*/} {start|stop|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
