#***********************************************************************
#
# adsl-connect
#
# Shell script to connect to an ADSL provider using PPPoE
#
# Copyright (C) 1999 Roaring Penguin Software Inc.
#
# $Id: adsl-connect,v 1.5 2000/01/10 22:50:26 dfs Exp $
#
# This file may be distributed under the terms of the GNU General
# Public License.
#
#***********************************************************************


### CONFIGURATION SETTINGS START HERE ###
#
# When you configure a variable, DO NOT leave spaces around the "=" sign.
#

# Ethernet card connected to ADSL modem
ETH=eth1

# Do you want to use synchronous PPP?  "yes" or "no".  "yes" is much
# easier on CPU usage, but may not work for you.  It is safer to use
# "no", but you may want to experiment with "yes".
SYNCHRONOUS=no

# ADSL user name.  You may have to supply "@provider.com"  Sympatico
# users in Canada do need to include "@sympatico.ca"
# Sympatico uses PAP authentication.  Make sure /etc/ppp/pap-secrets
# contains the right username/password combination.
# For Magma, use xxyyzz@magma.ca
USER=bxxxnxnx@sympatico.ca

### ONLY TOUCH THE FOLLOWING SETTINGS IF YOU'RE AN EXPERT
# LCP echo interval and failure count.
LCP_INTERVAL=20
LCP_FAILURE=3

# PPPOE_TIMEOUT should be about 4*LCP_INTERVAL
PPPOE_TIMEOUT=80

### DON'T TOUCH ANYTHING BELOW HERE UNLESS YOU INSTALLED pppoe SOMEWHERE OTHER
### THAN /usr/local/bin

# Paths to programs
IFCONFIG=/sbin/ifconfig
PPPD=/usr/sbin/pppd
PPPOE=/usr/local/bin/pppoe
LOGGER=/usr/bin/logger

# MTU of Ethernet card attached to modem MUST be 1500.

$IFCONFIG $ETH up mtu 1500

if test "$SYNCHRONOUS" = "yes" ; then
	PPPOE_SYNC=-s
	PPPD_SYNC=sync
else
	PPPOE_SYNC=""
	PPPD_SYNC=""
fi

while [ true ] ; do
    $PPPD pty "$PPPOE -I $ETH -T $PPPOE_TIMEOUT $PPPOE_SYNC" \
        noipdefault \
	noauth \
	defaultroute \
	hide-password \
        user $USER \
        nodetach \
	lcp-echo-interval $LCP_INTERVAL \
	lcp-echo-failure $LCP_FAILURE \
        local \
	$PPPD_SYNC \
	mtu 1492 \
	mru 1492

    $LOGGER -p daemon.notice \
        "ADSL connection lost; attempting re-connection."
done
