#!/bin/bash
# Name: eu_dsp
# Goal: This script handles the ADI ADSL Modem USB driver after firmware
#       uploading. It loads the DSP code as needed by the modem.
#		It create a script /var/run/usb/%proc%bus%usb%002%005 in order
#		for the ADSL connexion to be stopped and module to be unloaded.
#       It should only be run by hotplug.
# Author: Tux
# Version: 1.9.4
# Params (given by hotplug):
#	$DEVICE (ex: /proc/bus/usb/002/005)

exit 123

# this script can only be called by hotplug (giving the $DEVICE param)
if [ -z $DEVICE ] ; then
	echo -e "$NOPARAMMSG"
	exit
fi

# script called when the modem will be unplugged
mkdir -p /var/run/usb
UNPLUGSCRIPT="/var/run/usb/`echo $DEVICE | sed 's/\//%/g'`"
echo "#!/bin/bash" > $UNPLUGSCRIPT
echo "${SBIN_DIR}/fctStopAdsl" >> $UNPLUGSCRIPT
echo "rmmod eagle-usb" >> $UNPLUGSCRIPT
echo "rm -f ${UNPLUGSCRIPT}" >> $UNPLUGSCRIPT
chmod u+x $UNPLUGSCRIPT

# load DSP & options
eaglectrl -d 0>&1 1>&1 2>&1 | logger
