#!/bin/bash
#
#	/etc/rc.d/init.d/pppoed
#
# Starts the pppoed daemon
#
# chkconfig: 345 11 89
# description: Runs commands scheduled by the at command at the time \
#    specified when at was run, and runs batch commands when the load \
#    average is low enough. ethx _HAVE_ to be already configured: 
#    ifconfig eth0 up
# processname: pppd
# 

# Source function library.
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network-scripts/network-functions

test -x /usr/sbin/pppoed || exit 0


# Get config.
. /etc/sysconfig/network

# Check that networking is up. 
if [ ${NETWORKING} = "no" ]
then
	exit 0
fi

if check_device_down ; then
        exit 0
fi        

#
#	See how we were called.
#
case "$1" in
  start)
	# Check if pppoed is already running
	if [ ! -f /var/lock/subsys/pppoed ]; then
	    echo -n 'Starting pppoed daemon: '
	    daemon /usr/sbin/pppoed $( echo -R 1 )
	    echo
	    touch /var/lock/subsys/pppoed
	fi
	;;
  stop)
	echo -n 'Stopping pppoed daemon: '
	killproc /usr/sbin/pppoed
	killproc /usr/sbin/pppd
	echo
	rm -f /var/lock/subsys/pppoed
	;;
  reload|restart)
	$0 stop
	$0 start
	;;
  status)
	status /usr/sbin/pppd
	;;
  *)
	echo "Usage: /etc/rc.d/init.d/pppoed {start|stop|restart|reload|status}"
	exit 1
esac

exit 0
