#!/bin/sh

if [ "$1" = "" ]; then
	DEVICE=ppp0
else
	DEVICE=$1
fi

#Add for RHEL9.0 RQ3203 202207 start
if [ -r /run/$DEVICE.pid ]; then
        kill -INT `cat /run/$DEVICE.pid`
        if [ ! "$?" = "0" ]; then
                rm -f /run/$DEVICE.pid
                echo "ERROR: Removed stale pid file"
                exit 1
        fi

        echo "PPP link to $DEVICE terminated."
        exit 0
#Add for RHEL9.0 RQ3203 202207 end
elif [ -r /var/run/$DEVICE.pid ]; then
        kill -INT `cat /var/run/$DEVICE.pid`
        if [ ! "$?" = "0" ]; then
                rm -f /var/run/$DEVICE.pid
                echo "ERROR: Removed stale pid file"
                exit 1
        fi

        echo "PPP link to $DEVICE terminated."
        exit 0
fi

echo "ERROR: PPP link is not active on $DEVICE"
exit 1
