#!/bin/bash

# Copyright (c) 1999,2000 by Network TeleSystems, Inc.
# All rights reserved.
# Internet http://www.nts.com
#
# Please direct all support-related calls to your licensed Internet Service 
# Provider.  NTS does not provide direct support.  NTS works through Internet
# Service Providers that have licensed our software.

unset USERID
unset ACNAME
unset SERVICENAME
unset ETHERNET
unset LINKNAME
unset SYNC
unset PERSIST

#----- Beginning of User Changeable Area ----------------------------------

# Note, when making changes be sure NOT to insert white space (blanks)
# around the "=" symbol.  
# For example:  USERID= "RoadRunner"           
# This will not work.  It should be written as:  USERID="RoadRunner"

# Replace YourUserID with that of the userid supplied by your ISP.
# You will also need to add the user-id and password to the 
# /etc/ppp/chap-secrets and/or /etc/ppp/pap-secrets file.
USERID="YourUserID"

# If you need to connect to a specific service name then uncomment the line 
# below.  Replace YourServiceName with the service name specified by your ISP.
# SERVICENAME="YourServiceName"

# If you need to access a specific Access Concentrator then uncomment the
# line below.  Replace YourAccessConcentratorName with the name specified by 
# your ISP. 
# ACNAME="YourAccessConcentratorName"

# Not all systems can support the sync option.  Uncomment the next line if 
# yours can.  See the README, section IMPROVE PERFORMANCE, for more 
# information on when you can and cannot use this option.
# SYNC=sync

# If you want your PPPoE connection to automatically reconnect if the 
# connection should break, uncomment the next line.
# PERSIST=persist

# If the Ethernet NIC that you will be using is not at eth0 you will need
# to supply that information below by replacing eth0 with that of your
# network card.  ifconfig command will show a list of network interfaces.
INTERFACE="eth0"

# Programs w/path.  If your system has these programs in different locations
# update the paths as appropriate.
PPPD=/usr/sbin/pppd
PPPOED=/usr/local/bin/pppoed
IFCONFIG=/sbin/ifconfig

#----- End User Changeable Area ------------------------------------------------

if [ "$USERID" = "YourUserID" ]; then
    echo 'Are you sure your correct login user ID is "YourUserID".'
fi

$IFCONFIG $INTERFACE 0.0.0.0 -broadcast up -arp

if [ -n "$1" ]; then
    SERVICENAME="$1"
fi

if [ -n "$SERVICENAME" ]; then
	SERVICENAME="-S $SERVICENAME"
fi
if [ -n "$ACNAME" ]; then
	ACNAME="-A $ACNAME"
fi
if [ -n "$INTERFACE" ]; then
	INTERFACE="-I $INTERFACE"
fi
if [ -n "$USERID" ]; then
	USERID="name $USERID"
fi
if [ -n "$PERSIST" ]; then
	PERSIST="persist"
fi
if [ -n "$SYNC" ]; then
	SYNC="sync"
fi


$PPPD \
    pty "$PPPOED $INTERFACE $SERVICENAME $ACNAME" \
    $USERID \
    file /etc/ppp/options.pppoe \
    defaultroute \
    $SYNC \
    $PERSIST
