#!/bin/bash

B1=B
B2=("HANGUP")

function ppp_off {
    clear
    netstat -rn > $TXTTMP
    textbox $TXTTMP
    inputbox  "Specify Interface to be terminated"
    DEVICE=$INPUT

    if [ "$RETVAL" = "0" ]; then
	# If the ppp0 pid file is present then the program is running. Stop it.
	if [ -r /var/run/$DEVICE.pid ]; then
    	    kill -INT `cat /var/run/$DEVICE.pid`
	# If the kill did not work then there is no process running for this
	# pid. It may also mean that the lock file will be left. You may wish
	# to delete the lock file at the same time.
        if [ ! "$?" = "0" ]; then
                rm -f /var/run/$DEVICE.pid
                msgbox "ERROR: Removed stale pid file"
		return
        fi
	# Success. Let pppd clean up its own junk.
    	    msgbox "PPP link to $DEVICE terminated."
    	    return
	fi
	# The ppp process is not running for ppp0
	    msgbox "ERROR: PPP link is not active on $DEVICE"
	    return
    fi
}
