#!/bin/sh
######################################################################
#
# This script is part of the PPP System designed and used by
# Preston A. Elder of Shadow Realm.  If you have any problems
# with this system please email prez@antisocial.com.
#
# This system is publically distributable via. the GNU license.
#
######################################################################
#
# This will activate a PPP connection on an already-connected
# modem (eg. connected manually with minicom)
#
. /etc/ppp-settings

if [ -z "$1" -o "$1" = "-" ]; then
	TTY=${baseTTY}		# The device of the modem to dial with
else
	TTY="$1"
fi
if [ -z "$2" -o "$2" = "-" ]; then
	REMOTE_IP=0.0.0.0	# Remote IP address if desired. Normally 0.0.0.0
else
	REMOTE_IP="$2"
fi
if [ -z "$3" -o "$3" = "-" ]; then
	LOCAL_IP=0.0.0.0	# Local IP address if known. Dynamic = 0.0.0.0
else
	LOCAL_IP="$3"
fi
if [ -z "$4" -o "$4" = "-" ]; then
	NETMASK=255.255.255.0	# The proper netmask if needed
else
	NETMASK="$4"
fi

if [ -z "$5" -o "$5" = "-" ]; then
	LINESPEED=${baseSPEED}	# The default speed of the connection
else
	LINESPEED="$5"
fi

#
# Initiate the connection
# 
# I put most of the common options on this command. Please, don't
# forget the 'lock' option or some programs such as mgetty will not
# work. The asyncmap and escape will permit the PPP link to work with
# a telnet or rlogin connection. You are welcome to make any changes
# as desired. Don't use the 'defaultroute' option if you currently
# have a default route to an ethernet gateway.
#

if [ "$TTY" = "$baseTTY" ]; then
	if [ -n "`${basePPP}/curdef`" ]; then
		route del default
	fi
fi
if [ -z "`${basePPP}/curdef`" ]; then
	exec /usr/sbin/pppd $DEBUG /dev/$TTY $LINESPEED $PPPOPT \
	     $LOCAL_IP:$REMOTE_IP netmask $NETMASK defaultroute &
else
	exec /usr/sbin/pppd $DEBUG /dev/$TTY $LINESPEED $PPPOPT \
	     $LOCAL_IP:$REMOTE_IP netmask $NETMASK &
fi
