#!/bin/sh
# Thomson / Alcatel SpeedTouch 330 specific install script

username=$1
password=$2
vpi=$3
vci=$4
firmware=$5

# kernel module gets in the way, get rid of it
grep -q speedtch /etc/hotplug/blacklist ||
  echo "speedtch" >> /etc/hotplug/blacklist
modprobe -r -q speedtch
# see if we succeeded, bail out if we didn't
if grep -q speedtch /proc/modules; then
	echo "$0: speedtch kernel module still loaded, please remove it manually or reboot your computer and try again!"
	exit -1
fi
# we need the firmware file to proceed
if [ -z "$5" ]; then
	echo "$0: firmware file not supplied, please provide full path to the .zip file as the last argument!"
	exit -1
fi
# locate and install the firmware
[ -d /lib/firmware ] || exit -1
pushd /lib/firmware
unzip -o $firmware ZZZL_3.012 || exit -1 # contains KQD6_3.012 and ZZZL_3.012, only the latter is needed / supported
popd
# supply VPI and VCI
sed -e "s/@@VPI@@/$vpi/" -i /etc/ppp/peers/adsl
sed -e "s/@@VCI@@/$vci/" -i /etc/ppp/peers/adsl
# done
touch /etc/sysconfig/speedtouch
