#!/bin/sh
# This script receives the arguments passed to /etc/ppp/ip-up by pppd
# $6 is (not all the time "pppdialin userid")
# $6 is passed by the pppd ipparam parameter when called by ppplogin
PPPPARMS=/usr/lib/linuxconf/lib/pppparms
read TOKEN USER <<-EOF
	$6
EOF
if [ "$TOKEN" = "pppdialin" ] ; then
	[ -z "$USER" ] || PEERNAME=$USER
	# Check out the routing
	$PPPPARMS routing $PEERNAME | \
		while read net mask
		do
			/sbin/route add -net $net netmask $mask dev $1
		done
	# check out for a postconnect command
	eval `$PPPPARMS pppdopt $PEERNAME defppp`
	if [ "$PPP_POSTCONCMD" != "" ] ; then
		eval $PPP_POSTCONCMD
	fi
	if [ "$PPP_DELIVERMAIL" != "" ] ; then
		/usr/sbin/sendmail -qR$PPP_DELIVERMAIL
	fi
	echo $1 >/var/run/pppdialin.$PEERNAME
	if [ "$PPP_FIREWALL" = "yes" ] ; then
		/bin/linuxconf --modulemain firewall --update
	fi
elif [ -n "$6" -a -d /etc/sysconfig/network-scripts ] ; then
	cd /etc/sysconfig/network-scripts
	. network-functions
	CONFIG=$6
	[ -f "$CONFIG" ] || CONFIG=ifcfg-$6
	source_config
	if [ "$PPP_FIREWALL" = "yes" ] ; then
		/bin/linuxconf --modulemain firewall --update
	fi
fi

