#!/bin/sh

LINKNAME=eagle-adsl
PIDFILE=/var/run/ppp-eagle-adsl.pid

if [ -e $PIDFILE ] ; then
    PPPD_PID=$(head -1 $PIDFILE)
    if pidof pppd | grep -q $PPPD_PID ; then
	logger "Connection seems to be up already!"
	exit
    fi
fi

# Wait for modem "operational" state:
/usr/sbin/adictrl -s

# Get the ADI network interface name:
INTERFACE=`/usr/sbin/adictrl -i`

# Configure the ADI network interface:
/sbin/ifconfig $INTERFACE up

# Start pppd:
/usr/sbin/pppd call eagle-provider pty "/usr/sbin/pppoa -I $INTERFACE" linkname $LINKNAME

echo "STARTED" > /var/run/adiusbadsl

