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

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

# 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 # contains KQD6_3.012 and ZZZL_3.012, only the latter is needed / supported
	/usr/share/adsl-manager-daemon/speedtouch/firmware-extractor ZZZL_3.012
popd
cp -f /usr/share/adsl-manager-daemon/speedtouch/ifcfg-ppp0.speedtouch /etc/sysconfig/network-scripts/ifcfg-ppp0

#supply username
sed -e "s/@@USERNAME@@/$username/" -i /etc/sysconfig/network-scripts/ifcfg-ppp0
# supply VPI and VCI
sed -e "s/@@VPI@@/$vpi/" -i /etc/sysconfig/network-scripts/ifcfg-ppp0
sed -e "s/@@VCI@@/$vci/" -i /etc/sysconfig/network-scripts/ifcfg-ppp0
ln -sf /var/run/ppp/resolv.conf /etc/resolv.conf

# done
touch /etc/sysconfig/speedtouch
