#!/bin/sh


IF=$1
PERIOD=$2
URL=$3

if [ $# -ne 3 ]
then
	echo "usage: $0 <if> <period> <url>"
	exit
fi


echo "Fetch '$URL' every $PERIOD seconds as long as interface $IF is up."

while [[ -z `/etc/init.d/net.$IF status | grep stopped` ]]
do
	curl $URL > /dev/null
	sleep $PERIOD
done


