#!/bin/sh cat - </dev/null fi if [ ! -f $MICROCODE ]; then echo "Cannot find microcode $MICROCODE" exit 1 fi if [ ! -f $TARBALL ]; then echo "Cannot find tarball $TARBALL" exit 1 fi error=0 PPP_VERSION=`$PPPD --version 2>&1 | awk '{ print $3 }'` KERNEL=`$UNAME -r` KERNEL_MAJOR=`echo $KERNEL | cut -d"." -f1,2` KERNEL_MINOR=`echo $KERNEL | cut -d"." -f3` USB_TYPE=`$LSPCI -v |grep -i usb|grep HCI` if [ "${PPP_VERSION}" == "2.4.0" ] || [ "${PPP_VERSION}" == "2.4.1" ]; then echo "PPP version $PPP_VERSION okay." else if [ "$KERNEL_MAJOR" == "2.4" ]; then echo "PPP Version ${PPP_VERSION} should be 2.4.0 or 2.4.1" error=`expr $error + 1` else echo "With the 2.2.18 kernel you should get away with $PPP_VERSION" echo "... maybe." fi fi if [ -z "${USB_TYPE}" ]; then echo "No USB Bus found!" error=`expr $error + 2` fi echo ${USB_TYPE} | grep -q UHCI if [ "$?" -eq "0" ]; then USB_TYPE=UHCI else USB_TYPE=OHCI fi echo $KERNEL|grep -q "2.4" if [ "$?" -ne "0" ]; then echo $KERNEL | grep -q "2.2.18" if [ "$?" -ne "0" ]; then echo "Sorry, only 2.4 and 2.2.18 kernels have been made to work with the $PRODNAME" error=`expr $error + 4` fi else echo $KERNEL | egrep -q "2.4.1(8|9)" if [ "$?" -ne "0" ]; then echo "You probably need the HDLC kernel patch n_hdlc.c.diff" error=`expr $error + 8` fi fi ls -l /dev/ppp|grep -wq 108 if [ "$?" -ne "0" ]; then cd /dev ./MAKEDEV ppp if [ "$?" -ne "0" ]; then echo "MAKEDEV failed" error=`expr $error + 16` fi fi if [ "`id -u`" != "0" ]; then echo "You must be logged in as root to use this script" exit 1 fi } get_tarball() { mkdir /tmp/speedtouch.$$ cd /tmp/speedtouch.$$ echo "$TARBALL" |grep -q "gz$" if [ "$?" -eq "0" ]; then tar xzf $TARBALL cd `basename $TARBALL .tar.gz` else bzcat $TARBALL | tar xf - cd `basename $TARBALL .tar.bz2` fi if [ "$PREFIX" != "/" ]; then config="./configure --prefix $PREFIX/usr" else config="./configure" fi echo "Configururing SpeedTouch Driver..." if [ "$QUIET" == "YES" ]; then $config > /dev/null 2>&1 res=$? else $config res=$? fi check_err $res "Software Configuration" echo "Building SpeedTouch Driver..." if [ "$QUIET" == "YES" ]; then make > /dev/null 2>&1 res=$? else make res=$? fi check_err $res "Software Build" echo "Installing SpeedTouch Driver..." if [ "$QUIET" == "YES" ]; then make install > /dev/null res=$? else make install res=$? fi check_err $res "Software Installation" } create_ppp_files() { cd $PREFIX/etc/ppp cat - > options << EOF #------------------ /etc/ppp/options Beginning ------------- noauth usepeerdns lock noipdefault #------------------ /etc/ppp/options End ------------------ EOF mkdir peers 2>/dev/null cat - > peers/adsl <> peers/adsl echo "sync" >> peers/adsl echo "user \"$ISP_LOGIN\"" >> peers/adsl cat - >> peers/adsl << EOF noauth noaccomp nopcomp noccp novj holdoff 4 persist maxfail 25 usepeerdns #------------------/etc/ppp/peers/adsl EOF------------------ EOF echo "\"$ISP_LOGIN\" \"*\" \"$ISP_PASSWORD\" \"*\"" >> chap-secrets echo "\"$ISP_LOGIN\" \"*\" \"$ISP_PASSWORD\" \"*\"" >> pap-secrets chmod 600 pap-secrets chap-secrets } add_line() { grep -q "$1" $3 || echo "$2" >> $3 } modify_modules_conf() { if [ -f /etc/modules.conf ]; then MODCONF=$PREFIX/etc/modules.conf else MODCONF=$PREFIX/etc/conf.modules fi add_line "ppp_generic" "alias char-major-108 ppp_generic" $MODCONF add_line "dev/ppp" "alias /dev/ppp ppp_generic" $MODCONF add_line "ppp_async" "alias tty-ldisc-3 ppp_async" $MODCONF add_line "n_hdlc" "alias tty-ldisc-13 n_hdlc" $MODCONF add_line "ppp_synctty" "alias tty-ldisc-14 ppp_synctty" $MODCONF add_line "bsd_comp" "alias ppp-compress-21 bsd_comp" $MODCONF add_line "ppp-compress-24" "alias ppp-compress-24 ppp_deflate" $MODCONF add_line "ppp-compress-26" "alias ppp-compress-26 ppp_deflate" $MODCONF } do_modprobe() { modprobe ppp_generic modprobe ppp_synctty modprobe n_hdlc modprobe usbcore mount none /proc/bus/usb -t usbdevfs > /dev/null 2>&1 if [ "$USB_TYPE" == "UHCI" ]; then modprobe usb-uhci if [ "$?" -ne "0" ]; then modprobe uhci fi else modprobe usb-ohci fi } select_options() { ans="N" while [ "$ans" != "Y" ]; do cat - << EOF Country/ISP VPI VCI Belgium, ? 8 35 Denmark, Orang 8 35 France, wanado 8 35 France, ? 8 67 Italy, ? 8 35 Netherlands, ? 8 48 UK, BTopenworld 0 38 US, BellSouth 8 35 EOF echo "Please select your VPI VCI numbers (eg, 0 38) for UK" read VPI VCI echo "Please enter your ISP Login ID (eg another@hg1.btinternet.com)" read ISP_LOGIN echo "Please enter your ISP Password" read ISP_PASSWORD echo "Settings: " echo " VPI / VCI : $VPI / $VCI" echo " Login : $ISP_LOGIN" echo " Password : $ISP_PASSWORD" echo "Are these correct? (Y/N)" read ans ans=`echo ${ans}N|tr '[a-z]' '[A-Z]'|cut -c1` done } setup_etc_conf() { CONF=$PREFIX/etc/speedtouch.conf echo "# SpeedTouch Config File" > $CONF echo "# The speedtouch rc script assumes /usr/local/sbin is in the path..." >> $CONF echo "PATH=\$PATH:/usr/local/sbin" >> $CONF echo "# LOAD_ directives should be 1 for modules, 0 if built into the kernel" >> $CONF echo "LOAD_USBCORE=1" >> $CONF echo "LOAD_USBINTERFACE=1" >> $CONF echo "LOAD_NHDLC=1" >> $CONF echo "# USB Interface - UHCI or OHCI" >> $CONF USB=`echo $USB_TYPE | tr '[:upper:]' '[:lower:]'` echo "DEFAULT_USBINTERFACE=\"$USB\"" >> $CONF echo "# Path to microcode (mgmt.o or alcudsl.sys from the official Alcatel drivers" >> $CONF echo "MICROCODE=\"$MICROCODE\"" >> $CONF echo "# Set this to 1 if you have configured the script" >> $CONF echo "CONFIGURED=1" >> $CONF cp /usr/local/etc/init.d/speedtouch /etc/rc.d/init.d/ } check_router() { route=`netstat -rn|grep "^0\.0\.0\.0"|awk '{ print $2 }'` if [ ! -z "${route}" ]; then echo "You have a default router : $route" route delete default gw $route fi } # main script starts here check_config if [ "$error" -ne "0" ]; then echo "Not ready to install the software at this time. - code $error" exit 1 fi select_options echo "No further user interaction is required." get_tarball create_ppp_files modify_modules_conf do_modprobe check_router setup_etc_conf echo echo echo echo "The modem lights should start flashing for 20 seconds..." $MODEM_RUN -m -f $MICROCODE res=$? if [ "$res" -eq "0" ]; then echo "Phew! That was the hard part! Should be plain sailing now..." else echo "The modem_run command failed (code $res)- check your kernel config" exit 1 fi sleep 10 echo "Running : $PPPD call adsl" $PPPD call adsl sleep 10 ifconfig ppp0 | grep "inet addr:" if [ "$?" -eq "0" ]; then echo "Looks like we're online... " ping -c1 www.google.com > /dev/null if [ "$?" -eq "0" ]; then echo "Hey look, I can see the Net from here!" fi else echo "Oops - don't seem to have connected. " echo "Are you sure your password and login are correct?" fi echo "All done. Run :" echo "chkconfig --add speedtouch" echo "as root to automatically dial-in when the PC boots up" if [ ! -z "${route}" ]; then echo echo "You have a default route configured." grep -q "GATEWAY=" /etc/sysconfig/network 2>/dev/null if [ "$?" -eq "0" ]; then echo "You need to remove the GATEWAY= line from /etc/sysconfig/network." else echo "You need to disable this, as there can only be one default route." fi echo fi exit 0