#!/bin/bash

# If no pid file, just exit
[ ! -e "/var/run/ppp-gatekeeper/ppp-gatekeeper.pid" ] && exit 0

PPPGK=$(cat /var/run/ppp-gatekeeper/ppp-gatekeeper.pid)

if [ -e "/proc/$PPPGK/cmdline" ]
then
		rm -f "/var/run/ppp-gatekeeper/ppp-gatekeeper.ipt"
		kill -USR2 "$PPPGK"

		i=1
		while [ "$i" -lt 10 ]
		do
				if [ -e "/var/run/ppp-gatekeeper/ppp-gatekeeper.ipt" ]
				then
						. "/var/run/ppp-gatekeeper/ppp-gatekeeper.ipt"
						exit 0;
				fi

				sleep .5;
				i=$((i+1))
		done
fi

# vim: ts=4
