#!/bin/sh
#
# pppoe                     This script starts or stops an ADSL connection
#
# chkconfig: - 99 01
# description: Connects to ADSL provider
#
# Copyright (C) 2000 Roaring Penguin Software Inc.  This software may
# be distributed under the terms of the GNU General Public License, version
# 2 or any later version.

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

[ -x /usr/sbin/pppd ] || exit 0
[ -f /etc/ppp/pppoe.conf ] || exit 0


RETVAL=0
 
start() {
	if [ ! -f /var/lock/subsys/pppoe ]; then
	    echo -n "Bringing up ADSL link"
	    /usr/sbin/adsl-start >& /dev/null
	    RETVAL=$?
            [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pppoe
	    echo
	fi
	return $RETVAL
}

stop() {
        echo -n "Shutting down ADSL link"
        /usr/sbin/adsl-stop >& /dev/null
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pppoe
        echo
        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: pppoe {start|stop|restart|status|condrestart}"
        exit 1
esac
 
exit $RETVAL                                                                      
