#!/bin/sh
#
# pppoe                     This script starts or stops a PPPoE connection
#
# chkconfig: 2345 99 01
# description: Connects to PPPoE provider
#
# LIC: GPL
#
# 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.
# Modifed to work with SuSE 6.4 linux by Gary Cameron.
#
# Modifed and fixed to work with SuSE linux by Anas Nashif <nashif@suse.de>

### BEGIN INIT INFO
# Provides:          rp-pppoe
# Required-Start:    $syslog $network $named
# Required-Stop:     $syslog $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Start Roaring Penguin ADSL
# Description:       Start Roaring Penguin ADSL
### END INIT INFO

. /etc/rc.status

#Tweak this
restart_time=120

# From AUTOCONF
prefix=/usr
exec_prefix=${prefix}

# Paths to programs
START=${exec_prefix}/sbin/pppoe-start
STOP=${exec_prefix}/sbin/pppoe-stop
STATUS=${exec_prefix}/sbin/pppoe-status

# The echo return value for success (defined in /etc/rc.config).
case "$1" in
    start)
        echo -n "Bringing up PPPoE link"
        $START  > /dev/null 2>&1
    rc_status -v
        ;;

    stop)
        echo -n "Shutting down PPPoE link"
        $STOP > /dev/null 2>&1
    rc_status -v
        ;;

    try-restart)
        ## Stop the service and if this succeeds (i.e. the
        ## service was running before), start it again.
        $0 stop  &&  $0 start

        # Remember status and be quiet
        rc_status
        ;;

    restart)
        $0 stop
        echo "Waiting" $restart_time "seconds for the host to reset itself"
        sleep $restart_time  #Note: Need time for host to reset itself
        $0 start
    rc_status
        ;;

    status)
        checkproc /usr/sbin/pppoe; rc=$?
        if test $rc = 0; then echo "OK"
        else echo "No process"
                if test -e /var/run/pppoe.conf-adsl.pid.pppoe;
                then exit 1
                else exit 3
                fi
        fi
        ;;

    *)
        echo "Usage: pppoe {start|stop|restart|status|try-restart}"
        exit 1
esac
rc_exit

