#!/bin/sh

dev=$1
file=$2

function usage {
	echo
	echo "$0 w1g1 <reg-config-file.cfg>"
	echo 
	exit 1
}

if [ -z $dev ]; then
	echo "Error: No device specififed"
	usage
fi

eval "ifconfig | grep $dev > /dev/null"
if [ $? -ne 0 ]; then
	echo "Error: $dev does not exist"
	usage
fi

if [ ! -e $file ]; then
	echo "Error: File $file does not exist"
	usage
fi

vals=`cat $file`

for val in $vals
do

	reg=`echo $val | cut -d'=' -f1`
	data=`echo $val | cut -d'=' -f2`
	echo "$reg = $data"
	wanpipemon -i $dev -c dreg $reg $data > /dev/null
done
