#!/bin/bash
# Name: startadsl
# Goal: start ADSL connexion
# Author: Tux
# Version: 1.9.5
# Params:
#	h = display help
#	m = start mire
#	s = simple mode (don't use ifup & ifdown scripts => do not requiere ifcfg-ethX)
#	t = set timeout delay (default=60s)
#	a = use ip adress (use -a xx.xx.xx.xx), imply simple mode
#	d = launch pppd in debug mode

. /etc/eagle-usb/scripts/setvars

for param in $*; do
	PARAMS="$PARAMS $param"
done;

# startadsl is lauched manually. If the modem is not operational,
# the script is immediately stopped
if ! $EAGLESTAT | grep -q "$OPER_STR" ; then
	echo -e "$NOT_OPER_MSG"
	exit 1
fi

fctStartAdsl $PARAMS
RES=$?

if [ $RES == 1 ] ; then
	echo -e $ALREADY_MSG
	exit 1
fi
if [ $RES == 2 ] ; then
	echo -e $CANT_SYNC_MSG
	exit 1
fi
if [ $RES == 3 ] ; then
	echo -e $PPPD_ERR_MSG
	exit 1
fi
if [ $RES == 4 ] ; then
	echo -e $IFUP_ERR_MSG
	exit 1
fi
if [ $RES == 5 ] ; then
	echo -e $LOCK_MSG
	exit 1
fi
