Public domain
#!/bin/bash
# Syntax check
if [ "$#" = "0" ]; then
echo "Usage: $0 <ppp-device>"
exit
fi
# First parameter should be device name
DEVICE="$1"
# Check pid file existance
if [ ! -r /var/run/$DEVICE.pid ]; then
echo "ERROR: /var/run/$DEVICE.pid not found !!!"
exit 1
fi
# Disconnecting
kill -INT $(cat /var/run/$DEVICE.pid) &> /dev/null
# Check return code
if [ ! "$?" = "0" ]; then
echo "ERROR: PPP link is not active on: [$DEVICE]"
rm /var/run/$DEVICE.pid
exit 1
fi
echo "$DEVICE disconnected successfully."
BY: Pejman Moghadam
TAG: ppp
DATE: 2012-06-06 14:24:38