#! /bin/sh
#
#  Copyright (C) 1997  Dimitrios P. Bouras
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#   For author contact information, look in the README file.
 
# First setup all variables passed on from pppd
#-----------------------------------------------
interface=$1
device=$2
speed=$3
localIP=$4
remoteIP=$5
ipparam=$6
 
# Then parse the ipparam argument string passed on from xisp
#------------------------------------------------------------
pipefname=`echo $ipparam | sed -e 's/\:.*$//'`
temp=`echo $ipparam | sed -e 's/^[^:]*\://'`
ISPname=`echo $temp | sed -e 's/\:.*$//'`
temp=`echo $temp | sed -e 's/^[^:]*\://'`
DNS1=`echo $temp | sed -e 's/\:.*$//'`
DNS2=`echo $temp | sed -e 's/^.*\://'`
 
# Remove the lines in /etc/resolv.conf for the DNS entries passed from xisp
#---------------------------------------------------------------------------
umask 022
if [ "$DNS1"x != x ]; then
	grep -v "$DNS1" /etc/resolv.conf > /etc/resolv.conf.new
	mv -f /etc/resolv.conf.new /etc/resolv.conf
	echo "DNS $DNS1 removed" >> $pipefname 2>&1
fi
if [ "$DNS2"x != x ]; then
	grep -v "$DNS2" /etc/resolv.conf > /etc/resolv.conf.new
	mv -f /etc/resolv.conf.new /etc/resolv.conf
	echo "DNS $DNS2 removed" >> $pipefname 2>&1
fi

# The ISPname variable can now be used to carry out global and/or
# ISP-specific tasks like downloading mail and/or news. The folowing
# statements are examples. Modify them to best suit your needs.
# Note that for output to appear in the xisp browser window, all
# commands must end with the '>> $pipefname 2>&1' output redirection.
#---------------------------------------------------------------------

# echo "Interface $interface is now DOWN" >> $pipefname 2>&1
# echo "On $device at $speed Baud" >> $pipefname 2>&1
# echo "Local IP: $localIP" >> $pipefname 2>&1
# echo "Remote IP: $remoteIP" >> $pipefname 2>&1

case $ISPname in

	'My First Provider')
		echo "Provider 1" >> $pipefname 2>&1
		;;

	'My Second Provider')
		echo "Provider 2" >> $pipefname 2>&1
		;;

	*)
		;;
esac

