#!/bin/sh
cnt=0
max_delay=30
i=0
#for ((i=0;i<$max_delay;i++))
while [ $i != $max_delay ]
do
	if [ -e /dev/wanpipe ]; then
        	break;
	fi

	echo "Waiting for TDM iAPI device /dev/wanpipe ($i/$max_delay)..."
	i=$((i+1));
  	sleep 2
done

if [ ! -e /dev/wanpipe ]; then
	echo
	echo "Error: Sangoma TDM API device failed to come up";
        echo "Possible Cause: UDEV not installed!";
	echo
	exit 1
fi 

sleep 1

smg_ctrl start 
