#! /bin/bash
#
# pppoe                     This script starts or stops an ADSL connection
#
# chkconfig: 2345 80 20
# description: Connects to ADSL provider
#

# Source function library if it exists
test -r /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions

CONFIG=/etc/ppp/pppoe.conf
CONFIG_OLD=/etc/sysconfig/pppoe

[ -x /usr/sbin/pppd ] || exit 0
[ -f $CONFIG ] || exit 0
[ -f $CONFIG_OLD ] && . $CONFIG_OLD
. $CONFIG

[ "$BOOT" = "yes" ] || exit 0

RETVAL=0
 
start() {
	[ ! -f /var/lock/subsys/pppoe ] || exit 0
	/sbin/ifdown $ETH &>/dev/null
	action $"Bringing up ADSL link: " /usr/sbin/adsl-start
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pppoe
	return $RETVAL
}

stop() {
	[ -f /var/lock/subsys/pppoe ] || exit 0
	action $"Shutting down ADSL link: " /usr/sbin/adsl-stop
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pppoe
	return $RETVAL
}

status() {
	/usr/sbin/adsl-status
	RETVAL=$?
	return $RETVAL
}

restart() {
	stop
	start
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		restart
		;;
	condrestart)
		[ -f /var/lock/subsys/pppoe ] && restart || :
		;;
	status)
		status
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|status|condrestart}"
		exit 1
esac
 
exit $RETVAL
