#!/bin/sh
#
# This script does the real work of the ip-down processing. It will
# cause the system to terminate just to make sure that everything is
# dead; restart the ppp-on script processing to re-dial the sequence.
#
NETDEVICE=$1
TTYDEVICE=`basename $2`
SPEED=$3
LOCAL_IP=$4
REMOTE_IP=$5

#
# If the process is still running, then try to terminate the process
# 
if [ -r /var/run/$NETDEVICE.pid ]; then
	echo '' >>/var/run/$NETDEVICE.pid
	pid = `head -1 /var/run/$NETDEVICE.pid`

	if [! "$pid" = "" ]; then
		sleep 5s
		kill -HUP $pid
		if [ "$?" = "0" ]; then
			sleep 5s
			KILL -TERM $pid
			if [ "$?" = "0" ]; then
				sleep 5s
			fi
		fi
	fi
#
# Ensure that there is no junk left in the system
#
	rm -f /var/run/$NETDEVICE.pid
	rm -f /var/lock/LCK..$TTYDEVICE
fi

#
# Since the defaultroute will not be added if there is an existing default
# route, remove it now. Do not do this if the defaultroute route was not
# added by the ppp script.
#
# route del default

#
# Finally, restart the connection sequence.
#
exec /etc/ppp/ppp-on
