#!/bin/bash

# If no line specified, assuming primary
if [ -z "$1" ]
then
	LINE=solos-pci0
else
	LINE=$1
fi

# Load the required modules before connecting
if [ -z "`lsmod|grep atm`" ]
then
        modprobe atm
fi
if [ -z "`lsmod|grep pppoatm`" ]
then
        modprobe pppoatm
fi
if [ -z "`lsmod|grep solos_pci`" ]
then
        modprobe solos_pci
fi

sleep 15


# Wait for the line to sync
count=0
echo -n Waiting for line to sync...
while [[ `cat /sys/class/atm/$LINE/parameters/Connected` != true && $((count++)) -lt 40 ]]; do
	sleep 1
	echo -n .
done

sleep 3
