#!/bin/sh
# chkconfig: - 80 30
# description: PPTP is a Point-To-Point Tunnelling Protocol
# processname: pptpd
# config: /etc/pptpd.conf
# pidfile: /run/pptpd.pid

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

# Source networking configuration.
SourceIfNotEmpty /etc/sysconfig/network
SourceIfNotEmpty /etc/sysconfig/pptpd

NAME=pptpd

# Config is a must to run
[ -f /etc/$NAME.conf ] || exit 0

RETVAL=0
PIDFILE=/run/$NAME.pid
LOCKFILE=/run/lock/subsys/$NAME

start()
{
	is_yes "$NETWORKING" || return 0
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $NAME $ARGS
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $NAME
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  reload|restart)
	restart
	;;
  condstop)
	# Stop the servce if it is already running
	if [ -e "$LOCKFILE" ]; then
	 stop
	fi
	;;
  condrestart|condreload)
	# Restart the servce if it is already running
	if [ -e "$LOCKFILE" ]; then
 	 restart
	fi
	;;
  status)
	# report the status of the daemons in free-form format
	status --pidfile "$PIDFILE" --expect-user root -- $NAME
	RETVAL=$?
	;;
  *)
	msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
	RETVAL=1
esac

exit $RETVAL
