#!/bin/bash

# delay for pppd to stop properly. After that, killall -9 is invoqued.
DELAY_KILL_PPPD=3

# Paths
INSTALL_DIR=/usr/local/sbin
EAGLE_DIR=/etc/eagle-usb
EAGLESCRIPT_DIR=$EAGLE_DIR/scripts
PPP_DIR=/etc/ppp
PPP_OPTIONS_DIR=/etc/ppp/peers
PPP_OPTIONS_ADSL=$PPP_OPTIONS_DIR/adsl
PPP_OPTIONS_MIRE=$PPP_OPTIONS_DIR/mire
HOTPLUG_SCRIPT_DIR=/etc/hotplug/usb
HOTPLUG_USERMAP_DIR=/usr/lib/hotplug/eagle-usb
HOTPLUG_USERMAP_DIR_NOUPD=/etc/hotplug/usb.usermap
INIT_DIR=/etc/init.d
NET_SCRIPTS_DIR=/etc/sysconfig/network-scripts

# Commands
EAGLE_CTRL=eaglectrl
EAGLE_STAT=eaglestat

# Strings used to determine modem state
SEND_DSP="Please send DSP (eaglectrl -d)"
MODULE="eagle-usb"
OPER_STR="Modem is operational"

# Environment path
#PATH="./:/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:${INSTALL_DIR}"
PATH="/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:${INSTALL_DIR}"
export PATH

# Degroup or ppp?
if [ -e $EAGLESCRIPT_DIR/script.conf ] ; then
	DEGROUPE=`grep DEGROUPE $EAGLESCRIPT_DIR/script.conf | cut -d '=' -f2`
else
	# can't determine if degroupe or not => default=not
	DEGROUPE=0
fi

# Language detection
# to prevent problems, french is loaded first (it is usually the most up-to-date file)
. ./lang/fr
LANG2="${LANG:0:2}"
if [ -e ./lang/$LANG2 ] ; then
	. ./lang/$LANG2
else
	. ./lang/en
fi

# Distrib detection
DISTRIB="other"
SIMPLE=1
if [ -e /etc/mandrake-release ] ; then
	if grep -q "Mandrake Linux release 9.1" /etc/mandrake-release ; then
		DISTRIB="Mandrake"
		DISTVER=9.1
		SIMPLE=0
	elif grep -q "Mandrake Linux release 9.2" /etc/mandrake-release ; then
		DISTRIB="Mandrake"
		DISTVER=9.2
		SIMPLE=0
	fi
elif [ -e /etc/fedora-release ] ; then
	if grep -q "Fedora Core release 1" /etc/fedora-release ; then
		DISTRIB="Fedora"
		DISTVER=1
		SIMPLE=0
	fi
fi

# Genetic confirm function
confirm() {
	echo -en $1
	read REP
	if [ -z "$REP" ] ; then return `expr 1 - $2` ; fi
	if echo "$REP" | grep -qiE "o|y|t|s" ; then return 0 ; fi
	if [ "$REP" = "n" ] ; then return 1 ; fi
	return $2
}

#if [ `expr $DISTVER \<= 9.1` == 1 ] ; then
#	echo "ok"
#fi

# used later to extract params
i=1
PARAMS=""
