[Gllug] Re: Alcatel SpeedTouch on Slackware 10

Henry Gilbert henry.gilbert at gmail.com
Fri Nov 18 14:24:19 UTC 2005


I can only get only by running speedtouchconf.sh
Which requires me typing VCI / VPI , Login + Password.
I am not expecting anyone to do the dirty work for me BUT ...... :)
for those that love a challenge (and this must be a baby-easy one for
Bash-scripters) ... I am trying to extract all the necessary commands
I need to make the consequent connection upon reboot on Slackware work
always.

Here is a copy of the script. I am not good at scripting I tried
setting values and all but it kept failing. I just need to extract all
is required to dial-up.

And just to prove - I am writing this from the modem connected.

I just don't want to run the script again and again upon reboot
(anyway this computer is not even mine, so reconnection upon reboot
will have to be automatic)

Note. It says to run "speedtouch start" which gets copied to
/etc/init.d (unexistent but I created a link /etc/init.d > /etc/rc.d)
... but when I then run /etc/rc.d/speedtouch start it fails with
/etc/init.d/functions not found. When I further try to force-debug
things - things just gets uglier and uglier.

#!/bin/bash
# (c) Steve Parker, 17 Oct 2002
# steve at steve dash parker dot org
# Released under GPL version 2 (http://www.gnu.org/copyleft/gpl.html)
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of Version 2 of the the GNU General Public License
#    as published by the Free Software Foundation. Any later versions of
#    the GPL will be evaluated as they are released, and this software may
#    or may not be re-released under those terms also.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# See the included file COPYING for more details.
# SpeedTouch Configuration for Alcatel USB Modem

export TEXTDOMAINDIR=`pwd`/po
export TEXTDOMAIN=speedtouchconf.sh

HOMEDIR=`dirname $0`
cd "${HOMEDIR}"
if [ "$?" -ne "0" ]; then
  echo $"Failed to change to $HOMEDIR"
  echo
  exit 1
fi
# Now set up TEXTDOMAINDIR again
export TEXTDOMAINDIR=`pwd`/po

VERSION=06.03.2005
# Location of Log File (send me this file if you need help diagnosing problems)
LOGFILE=/tmp/speedtouch.txt
# Quiet compilation (recommended)
QUIET=YES
# Speedtouch (speedtouch.sf.net) version
SPEEDTOUCH=speedtouch-1.3-sgp

MODEM_RUN=/usr/local/sbin/modem_run
PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH
PPPD=pppd
UNAME=uname
# Only tested with PREFIX=/
# Note: 20 Feb 2005: As it seems pretty useless, the PREFIX code may
be removed at any time;
# please mail me if you actually use this feature.
PREFIX="/"

check_err()
{
  if [ "$1" -ne "0" ]; then
    echo $"$2 - FAILED" | tee -a $LOGFILE
    echo $"Please check $3 for errors" | tee -a $LOGFILE
    echo "--- $3 starts ---" >> $LOGFILE
    cat $3 >> $LOGFILE
    echo "--- $3 ends ---" >> $LOGFILE
    exit 1
  else
    echo $"$2 - SUCCESS" | tee -a $LOGFILE
  fi
}

check_330()
{
  # This function is a placeholder to check for revisions of modem
  # Currently (19th March 2004) the 1.2 driver supports all current modems
  echo $"Using $SPEEDTOUCH" | tee -a $LOGFILE
}

get_microcode()
{
  # Called with various options - hopefully one of them exists.
  if [ -z "$1" ] || [ ! -f $1 ]; then
    echo $"ERROR: Cannot find microcode" | tee -a $LOGFILE
    echo $"Please place a copy of the Microcode in this directory."
    echo $"This could be :"
    echo $"  - the speedmgmt.tar.gz file from
http://www.speedtouchdsl.com/dvrreg_lx.htm"
    echo $"  - mgmt.o from speedmgmt.tar.gz"
    echo $"  - alcaudsl.sys from the Windows software (Eg
C:\\WINDOWS\\SYSTEM\\ALCAUDSL.SYS)"
    echo $"  - a .ZIP file (eg ZZZP1.ZIP) from the Windows software"
    echo $"Due to the license, you must obtain this file for yourself."
    exit 3
  fi

  echo $"microcode is $@"
  case "$1" in
  "speedmgmt.tar.gz")
    echo $"Using $1 for microcode"
    tar xzf speedmgmt.tar.gz
    MICROCODE=/etc/ppp/mgmt.o
    cp mgmt/mgmt.o $MICROCODE
    rm -rf mgmt
  ;;
  "mgmt.o")
    echo $"Using $1 for microcode"
    MICROCODE=/etc/ppp/mgmt.o
    cp mgmt.o $MICROCODE
  ;;
  "ALCAUDSL.SYS")
    echo $"Using $1 for microcode"
    MICROCODE=/etc/ppp/alcaudsl.sys
    cp ALCAUDSL.SYS /etc/ppp/alcaudsl.sys
  ;;
  "alcaudsl.sys")
    echo $"Using $1 for microcode"
    MICROCODE=/etc/ppp/alcaudsl.sys
    cp alcaudsl.sys /etc/ppp/alcaudsl.sys
  ;;
  *)
    # Must be a .ZIP (or .zip) file
    echo $1 | grep ".ZIP$" > /dev/null
    if [ "$?" -eq "0" ]; then
      zip=`basename $1 .ZIP`.zip
    else
      zip=`basename $1 .zip`
    fi
    zipfiles=`unzip -o ${zip}.zip 2>&1|grep "inflating: "| awk '{ print $2}'`
    MICROCODE=/etc/ppp/microcode.dat
    cat ${zipfiles} > /etc/ppp/microcode.dat
    if [ ! -s ${MICROCODE} ]; then
      echo $"Error: No files found in ZIP file $1"
      exit 1
    fi
    echo $"ZIP: Using Zipfile $zip (containing $zipfiles) for
microcode.dat" >> $LOGFILE
  ;;
  esac
}

get_usb()
{
  grep "^S:" /proc/bus/usb/devices | while read f
  do
    bus=`echo $f|grep HCI`
    echo $bus | grep -qi ehci && bus=EHCI
    echo $bus | grep -qi uhci && bus=UHCI
    echo $bus | grep -qi ohci && bus=OHCI
    if [ ! -z "$bus" ]; then
      USB_TYPE=$bus
    fi
    echo $f | grep -q "Product=Speed Touch"
    if [ "$?" -eq "0" ]; then
        echo $USB_TYPE
    fi
  done
}

check_config()
{

  # Check we're on Linux
  $UNAME -a >> $LOGFILE
  $UNAME -a|grep -qi Linux
  if [ "$?" -ne "0" ]; then
    echo $"Sorry, this script only supports the GNU/Linux operating system."
    echo $"FreeBSD support is planned for the distant future."
    echo $"If you want to help support of another OS, please contact me at"
    echo $"steve at steve-parker dot org"
    exit 1
  fi

  missing_binaries=""
  # Check we can find our required binaries
  for required_binary in $PPPD $LSPCI $UNAME tar cp rm gcc make mkdir
ls cat chown chmod read ping ifconfig unzip
  do
    type ${required_binary} > /dev/null 2>&1
    if [ "$?" -ne "0" ]; then
      echo $"Error: Cannot find ${required_binary}."
      echo "Error: Cannot find ${required_binary} in $PATH" >> $LOGFILE
      missing_binaries="$missing_binaries $required_binary"
    fi
  done

  # Flag for speedmgmt or speedtch in use...
  alcatel_inside=0
  for unrequired_files in /usr/sbin/speedmgmt
  do
    if [ -f ${unrequired_files} ]; then
      echo $"You have the Thomson drivers installed."
      echo $"These are not required by this speedtouch usermode driver."
      ps -eaf|grep -w speed[m]gmt > /dev/null 2>&1
      if [ "$?" -eq "0" ]; then
        echo $"The Thomson speedmgmt driver seems to be running."
        echo $"Please \"pkill speedmgmt\" driver before proceeding."
	alcatel_inside=1
      else
	echo $"Fortunately, the Thomson speedmgmt daemon"
        echo $"does not appear to be running."
      fi
    fi
  done

  lsmod | grep -w "^speedtch" > /dev/null 2>&1
  if [ "$?" -eq "0" ]; then
    echo $"The kernel speedtch module is loaded. This is not"
    echo $"compatible with the speedtouch usermode driver."
    #echo "Please \"rmmod speedtch\" before running speedtouchconf.sh."
    echo $"Removing the speedtch module"
    rmmod speedtch
    if [ "$?" -eq "0" ]; then
      alcatel_inside=0
    else
      echo $"Failed to remove the speedtch module - please do this by hand."
    fi
  fi

  if [ "$alcatel_inside" -ne "0" ]; then
    exit 1
  fi

  # Assume /etc/ppp exists
  mkdir -p /etc/ppp > /dev/null 2>&1

  if [ "$PREFIX" != "/" ]; then
    echo $"Using prefix of $PREFIX - note that this is untested!"
    mkdir -p $PREFIX 2>/dev/null
  fi

  get_microcode `ls speedmgmt.tar.gz mgmt.o alcaudsl.sys *zip *ZIP 2>/dev/null`

  # Check for speedtouch.sf.net tarball
  if [ -f ${SPEEDTOUCH}.tar.bz2 ]; then
    TARBALL=${SPEEDTOUCH}.tar.bz2
    type bzcat > /dev/null 2>&1
    if [ "$?" -ne "0" ]; then
      echo $"You have supplied the .tar.bz2 version, but do not have
bzcat installed."
      echo $"Please download the .tar.gz version from http://speedtouch.sf.net/"
      echo $"or install bzcat on your system."
      # Do not exit; fall through to .tar.gz
    fi
  else if [ -f ${SPEEDTOUCH}.tar.gz ]; then
      TARBALL=${SPEEDTOUCH}.tar.gz
  else
      echo $"Cannot find ${SPEEDTOUCH} tarball (tried .tar.gz and
.tar.bz2)" | tee -a $LOGFILE
      exit 1
    fi
  fi
  echo "Using Tarball $TARBALL" >> $LOGFILE

  error=0
  PPP_VERSION=`$PPPD --version 2>&1 | grep "^pppd version" | tr
'[a-z]' ' ' | awk '{ print $1 }'`
  KERNEL=`$UNAME -r`

  KERNEL_MAJOR=`echo $KERNEL | cut -d"." -f1,2`
  KERNEL_MINOR=`echo $KERNEL |sed s/"[a-z]"/"."/g|sed
s/"[A-Z]"/"."/g|tr '-' '.' | cut -d"." -f3`
  # Mandrake have dropped bc, for whatever bizarre reason they may have.
  # So this oneliner becomes two new variables and 9 new lines.
  #TWO_FOUR_OR_NEWER=`echo "$KERNEL_MAJOR >= 2.4" | bc`
  KERNEL_BIGMAJOR=`echo $KERNEL_MAJOR | cut -d"." -f1`
  KERNEL_SMALLMAJOR=`echo $KERNEL_MAJOR | cut -d"." -f2`
  TWO_FOUR_OR_NEWER=1
  if [ "$KERNEL_BIGMAJOR" -lt "2" ]; then TWO_FOUR_OR_NEWER=0
  else
    if [ "$KERNEL_SMALLMAJOR" -lt "4" ]; then
	TWO_FOUR_OR_NEWER=0
    fi
  fi

  echo $PPP_VERSION | grep -q "^2\.4\."
  if [ "$?" -eq "0" ]; then
    echo $"  PPP version $PPP_VERSION okay."
  else
    echo $"  PPP Version ${PPP_VERSION} should be 2.4.0 or later" |
tee -a $LOGFILE
    error=`expr $error + 1`
  fi
  if [ "$TWO_FOUR_OR_NEWER" == "0" ]; then
    if [ "$KERNEL_MAJOR" == "2.2" ] && [ "$KERNEL_MINOR" -ge "18" ]; then
      echo $"With the 2.2.18 kernel you should get away with
$PPP_VERSION" | tee -a $LOGFILE
      echo $"... maybe." | tee -a $LOGFILE
    else
      echo $"You probably need the HDLC kernel patch n_hdlc.c.diff" |
tee -a $LOGFILE
      error=`expr $error + 4`
    fi
  else
    echo $"  Linux kernel version ${KERNEL_MAJOR}.${KERNEL_MINOR} okay."
  fi

  USB_TYPE=`get_usb`

  if [ -z "${USB_TYPE}" ]; then
    echo $"No USB Bus found!" | tee -a $LOGFILE
    error=`expr $error + 2`
  fi

  ls -l /dev/ppp|grep -wq 108
  if [ "$?" -ne "0" ]; then
    cd /dev
    ./MAKEDEV ppp
    if [ "$?" -ne "0" ]; then
      echo $"MAKEDEV failed" | tee -a $LOGFILE
      error=`expr $error + 16`
    fi
  fi
  ls -l /dev/ppp|grep -wq 108
  if [ "$?" -ne "0" ]; then
    echo $"/dev/ppp cannot be created, or is not device 108"
    error=`expr $error + 32`
  fi

  if [ "`id -u`" != "0" ]; then
    echo $"You must be logged in as root to use this script"
    exit 1
  fi

  if [ ! -z "$missing_binaries" ]; then
    echo $"ERROR:"
    echo $"Some required files are not installed: "
    echo $missing_binaries
    echo $"Please install these (from your Linux install media,
or the internet) before you can configure and install
the speedtouch software.
Please check the PATH environment variable, and that you are running
as root. Your PATH variable is currently:"
    echo $PATH
    exit 1
  fi

  echo "--- Environment ---" >> $LOGFILE
  set >> $LOGFILE
  echo "--- End of Environment ---" >> $LOGFILE
}

get_tarball()
{
  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 $"Configuring SpeedTouch Driver..." | tee -a $LOGFILE
  if [ "$QUIET" == "YES" ]; then
    $config > /tmp/speedtouch.config.txt 2>&1
    res=$?
  else
    $config | tee /tmp/speedtouch.config.txt
    res=$?
  fi
  check_err $res "Software Configuration" /tmp/speedtouch.config.txt
  echo $"Building SpeedTouch Driver..." | tee -a $LOGFILE
  if [ "$QUIET" == "YES" ]; then
    make > /tmp/speedtouch.make.txt 2>&1
    res=$?
  else
    make | tee /tmp/speedtouch.make.txt
    res=$?
  fi
  check_err $res "Software Build" /tmp/speedtouch.make.txt
  echo $"Installing SpeedTouch Driver..." | tee -a $LOGFILE
  if [ "$QUIET" == "YES" ]; then
    make install > /tmp/speedtouch.make.install.txt
    res=$?
  else
    make install | tee /tmp/speedtouch.make.install.txt
    res=$?
  fi
  check_err $res "Software Installation" /tmp/speedtouch.make.install.txt
  rm -rf /tmp/speedtouch.$$
}

create_ppp_files()
{
echo $"Creating ppp files in $PREFIX/etc/ppp" | tee -a $LOGFILE
  cd $PREFIX/etc/ppp
  mv options options.bak 2>/dev/null
  cat - > options << EOF
#------------------ /etc/ppp/options Beginning -------------
noauth
usepeerdns
lock
noipdefault
#------------------ /etc/ppp/options End ------------------
EOF
  mkdir peers 2>/dev/null
  cat - > peers/adsl <<EOF
#-------------------/etc/ppp/peers/adsl Beginning------------
debug
kdebug 1
noipdefault
defaultroute
EOF
echo ${KERNEL_VERSION}|grep "^2.6." > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
  echo "pty \"/usr/local/sbin/pppoa3 -e 1 -m -1 -c -vpi $VPI -vci
$VCI\"" >> peers/adsl
else
  echo "pty \"/usr/local/sbin/pppoa3 -m -1 -c -vpi $VPI -vci $VCI\""
>> peers/adsl
fi
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

# Running this script multiple times could add multiple entries
# in these files ... check for "Added by speedtouchconf" to avoid this.
grep -v "Added by speedtouchconf" chap-secrets > chap-secrets.new
grep -v "Added by speedtouchconf" pap-secrets > pap-secrets.new
echo "\"$ISP_LOGIN\" \"*\" \"$ISP_PASSWORD\" \"*\" # Added by
speedtouchconf" >> chap-secrets.new
echo "\"$ISP_LOGIN\" \"*\" \"$ISP_PASSWORD\" \"*\" # Added by
speedtouchconf" >> pap-secrets.new
mv chap-secrets.new chap-secrets
mv pap-secrets.new pap-secrets

# Ensure security - only "root" should be able to read these files
chown root pap-secrets chap-secrets
chmod 600 pap-secrets chap-secrets

# Just do an ls -l of these files; don't want passwords in logfiles.
# This should be enough for basic sanity-checks.
ls -l /etc/ppp/peers/adsl /etc/ppp/*-secrets /etc/ppp/options >> $LOGFILE
}

add_line()
{
  grep -q "$1" $3 || echo "$2" >> $3
}

modify_modules_conf()
{
  if [ -f $PREFIX/etc/modules.conf ]; then
    MODCONF=$PREFIX/etc/modules.conf
  else
    MODCONF=$PREFIX/etc/conf.modules
  fi
  if [ -f $PREFIX/etc/modprobe.conf ]; then
    MODCONF=$PREFIX/etc/modprobe.conf
  fi
  if [ -f $PREFIX/etc/modprobe.conf.local ]; then
    MODCONF=$PREFIX/etc/modprobe.conf.local
  fi
echo "Original modules.conf: " >> $LOGFILE
cat $MODCONF >> $LOGFILE
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
echo "--- New modules.conf: " >> $LOGFILE
cat $MODCONF >> $LOGFILE
echo "--- end of new modules.conf" >> $LOGFILE
}

do_modprobe()
{
echo "Doing modprobes ... ">> $LOGFILE
echo "Please ignore any 'FAILED' messages here..."
modprobe ppp_generic 2>/dev/null | tee -a $LOGFILE
modprobe ppp_synctty 2>/dev/null | tee -a $LOGFILE
modprobe n_hdlc 2>/dev/null | tee -a $LOGFILE
modprobe usbcore 2>/dev/null | tee -a $LOGFILE
lsmod | grep -w usbcore > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
	LOAD_USBCORE=1
else
	LOAD_USBCORE=0
fi
mount none /proc/bus/usb -t usbfs > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
  # 2.4 kernels should also work with the new "usbfs" name, but let's be safe
  mount none /proc/bus/usb -t usbdevfs > /dev/null 2>&1
fi
# Modules could be uhci/usb-uhci/uhci-hdc (and again for ohci, ehci)
if [ "$USB_TYPE" == "UHCI" ]; then
  modprobe usb-uhci 2>/dev/null | tee -a $LOGFILE
  modprobe uhci 2>/dev/null | tee -a $LOGFILE
  modprobe uhci-hdc 2>/dev/null | tee -a $LOGFILE
  USB_INTERFACE=`lsmod | awk '{ print $1 }' | grep uhci | tail -1`
fi
if [ "$USB_TYPE" == "EHCI" ]; then
  modprobe usb-ehci 2>/dev/null | tee -a $LOGFILE
  modprobe ehci 2>/dev/null | tee -a $LOGFILE
  modprobe ehci-hdc 2>/dev/null | tee -a $LOGFILE
  USB_INTERFACE=`lsmod | awk '{ print $1 }' | grep ehci | tail -1`
fi
if [ "$USB_TYPE" == "OHCI" ]; then
  modprobe usb-ohci 2>/dev/null | tee -a $LOGFILE
  modprobe ohci 2>/dev/null | tee -a $LOGFILE
  modprobe ohci-hdc 2>/dev/null | tee -a $LOGFILE
  USB_INTERFACE=`lsmod | awk '{ print $1 }' | grep ohci | tail -1`
fi
if [ -z "${USB_INTERFACE}" ]; then
  LOAD_USBINTERFACE=0
else
  LOAD_USBINTERFACE=1
fi
# Now check for n_hdlc module (Xandros has it built-in)
modprobe n_hdlc 2>/dev/null
lsmod|grep -q n_hdlc
if [ "$?" -eq "0" ]; then
  LOAD_NHDLC=0
else
  LOAD_NHDLC=1
fi
echo "Setting LOAD_NHDLC=${LOAD_NHDLC}" >> $LOGFILE
echo "lsmod output:" >> $LOGFILE
lsmod >> $LOGFILE
echo "df -k : " >> $LOGFILE
df -k >> $LOGFILE
}

select_options()
{
ans="N"
while [ "$ans" != "Y" ]; do
echo "*******************************************"
echo "*                                         *"
echo $"*     Please select your ISP Settings     *"
echo "*                                         *"
echo "*******************************************"
echo
echo $"  Country/ISP	        VPI    VCI"
cat - << EOF
  Belgium, ?	          8     35
  Denmark, Orang          8     35
  France, wanado          8     35
  France, ?	          8     67
  Italy, ?	          8     35
  Netherlands, ?          8     48
  Netherlands	          0     35
  Poland (NeoStrada)      0     35
  UK, Any                 0     38
  Austria (AON)           8     48
  US, BellSouth	          8     35
  Singapore Pacificnet    0    100
EOF
  echo $"Please type your VPI VCI numbers (eg, 0 38 for UK)"
  read VPI VCI
  echo $"Please enter your ISP Login ID (eg another at 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
echo "VPI: $VPI VCI: $VCI" >> $LOGFILE
}

setup_etc_conf()
{
CONF=$PREFIX/etc/speedtouch.conf
echo "# SpeedTouch Config File" > $CONF
echo "# Created by speedtouchconf.sf.net version $VERSION" >> $CONF
echo "# The speedtouch rc script assumes /usr/local/sbin is in the
path..." >> $CONF
echo "# It does a ". /etc/speedtouch.conf", so we can just add it to
the PATH here." >> $CONF
echo "PATH=/usr/local/sbin:\$PATH" >> $CONF
echo "# LOAD_ directives should be 1 for modules, 0 if built into the
kernel" >> $CONF
echo "LOAD_USBCORE=${LOAD_USBCORE}" >> $CONF
echo "LOAD_USBINTERFACE=${LOAD_USBINTERFACE}" >> $CONF
echo "LOAD_NHDLC=${LOAD_NHDLC}" >> $CONF
echo "# USB Interface - UHCI / OHCI / EHCI" >> $CONF
USB=`echo $USB_TYPE | tr '[:upper:]' '[:lower:]'`
echo "DEFAULT_USBINTERFACE=\"${USB_INTERFACE}\"" >> $CONF
echo "# Path to microcode (eg. mgmt.o or alcudsl.sys from the official
Alcatel drivers)" >> $CONF
echo "MICROCODE=\"$MICROCODE\"" >> $CONF
echo "# modem_run verbosity" >> $CONF
echo "VERBOSE=0" >> $CONF
echo "# Set this to 1 if you have configured the script" >> $CONF
echo "CONFIGURED=1" >> $CONF
for rc_dir in /etc/rc.d/init.d /etc/init.d
do
  [ -d "${rc_dir}" ] && break
done
if [ -x /usr/lib/lsb/install_initd ]; then
  # LSB 2.0 expects /etc/init.d to exist, even if it's a symlink
  # http://refspecs.freestandards.org/LSB_2.0.1/LSB-Core/LSB-Core.html#INITSRCINSTRM
  rc_dir=/etc/init.d
fi
#cp /usr/local/etc/init.d/speedtouch ${rc_dir}
cp ${INITSCRIPT} ${rc_dir}/speedtouch
}

check_resolv_conf()
{
  if [ -f /etc/resolv.conf ]; then
    mv /etc/resolv.conf /etc/resolv.conf.orig
  fi
  cd /etc
  ln -sf ppp/resolv.conf resolv.conf

  ping -c1 www.google.com > /dev/null
  if [ "$?" -eq "0" ]; then
    echo "Fixed DNS ... it's working!" | tee -a $LOGFILE
  else
    echo $"Looks like /etc/ppp/resolv.conf is wrong." | tee -a $LOGFILE
    echo $"You need to check the DNS configuration." | tee - a $LOGFILE
    echo $"Look in /var/log/messages to see if DNS was configured." |
tee -a $LOGFILE
    DNS=NOTOK
  fi
}

check_router()
{
  route=`netstat -rn|grep "^0\.0\.0\.0"|awk '{ print $2 }'`
  if [ ! -z "${route}" ]; then
       echo $"You have a default router : $route (removing it for
you!)" | tee -a $LOGFILE
       route delete default gw $route
  fi
}

explain_modem_run()
{
  echo "modem_run results:"
  case $1 in
    255)
	echo $"Must be run with root priveleges"
	;;
    254)
	echo $"Usage error (probably a bug in speedtouchconf.sh)"
	;;
    253)
	echo $"Modem not found where expected"
	;;
    251)
	echo $"pusb_set_configuration error - "
	echo $"  please report error to speedtouch.sourceforge.net"
	;;
    250)
	echo $"Failed to load microcode - this is not a problem if you
have already loaded the microcode.
The microcode can only be loaded once per system boot;
We'll assume that the microcode is already loaded, and
not call this an error.
You may encounter problems, though."
	echo $"If you get a message to check your password, and your
password is definitely correct, switch off the PC, disconnect the
modem for a few seconds, re-connect, switch on, remove the speedtch
module if it is loaded, and try again."
	;;
   243 | 237 | 252 | 248 | 249)
	echo $"Error $1 - It may be that another device/program is"
	echo $"already accessing the modem"
	;;
#   247)
#	echo "Unable to locate the microcode - please ensure that"
#	echo "a valid mgmt.o or alcaudsl.sys file has been supplied."
#	;;
   246)
	echo $"Error initiating modem synchronisation"
	;;
   245)
	echo $"Failed to open EP_CODE endpoint"
	;;
   244)
	echo $"pusb_endpoint_open EP_INT (whatever that means)"
	echo $"  please report error to speedtouch.sourceforge.net"
	;;
   242)
	echo $"Error in fork_interrupt_daemon (handle_endpoint_int) (?) -
Anyone able to explain this to Steve?"
	;;
   241)
	echo $"No SpeedTouch Modem Found"
	;;
   240)
	echo $"Unable to locate firmware"
 	echo $"If you have a silver modem, make sure you're using rev4fw.zip"
        echo "http://speedtouchconf.sourceforge.net/rev4fw.zip"
	;;
   239)
	echo $"Unable to locate bootcode in firmware"
	;;
   238)
	echo $"Unable to locate main firmware code in firmware"
	;;
   *)
	echo $"Unknown error - $1"
	;;
  esac
  return $1
}

# main script starts here

clear
echo
echo "************************************************"
echo "*                                              *"
echo $"*       speedtouchconf.sh by Steve Parker      *"
echo "*                                              *"
echo "*    http://speedtouchconf.sourceforge.net/    *"
echo $"* based on speedtouch.sourceforge.net project  *"
echo "*                                              *"
echo "************************************************"
echo
echo $"If you have any problems with this script, mail me"
echo $"(steve at steve-parker dot org) with the files"
echo $"$LOGFILE and /var/log/messages for diagnosis."

if [ -f $LOGFILE ]; then
  mv $LOGFILE ${LOGFILE}.old
fi

cd `dirname $0`
echo $"Starting speedtouchconf.sh script" > $LOGFILE
echo $"Version ${VERSION}" >> $LOGFILE
date >> $LOGFILE
echo "Called as $0 from `pwd`" >> $LOGFILE
INITSCRIPT=`pwd`/speedtouch-init
check_330
check_config
if [ "$error" -ne "0" ]; then
  echo $"Not ready to install the software at this time. - code
$error" | tee -a $LOGFILE
  exit 1
fi
select_options
echo $"No further user interaction is required." | tee -a $LOGFILE
get_tarball
create_ppp_files
modify_modules_conf
do_modprobe
check_router
setup_etc_conf
echo
echo $"   *** Configuration finished. Starting the connection ***"
echo
date | tee -a $LOGFILE
echo $"The modem lights should start flashing for approx. 60
seconds..." | tee -a $LOGFILE
$MODEM_RUN -m -f $MICROCODE
res=$?
date | tee -a $LOGFILE
if [ "$res" -eq "0" ]; then
  echo $"The lights should both be solid green now." | tee -a $LOGFILE
else
  echo $"The modem_run command failed (code $res)" | tee -a $LOGFILE
  if [ "$res" -ne "0" ]; then
    explain_modem_run $res | tee -a $LOGFILE
    if [ "$res" -ne "250" ] && [ "$res" -ne "242" ]; then
	echo $"FAILED because of modem_run error $res"
	exit $?
    fi
  fi
fi
sleep 10
echo $"Running : $PPPD call adsl" | tee -a $LOGFILE
$PPPD call adsl
echo "pppd return code $?" >> $LOGFILE
sleep 10
echo "--- ifconfig -a output ---" >> $LOGFILE
ifconfig -a >> $LOGFILE
echo "--- netstat -rn output ---" >> $LOGFILE
netstat -rn >> $LOGFILE

DNS=OK
PPP0=NOT_OK
ifconfig ppp0 | grep -w "inet"
if [ "$?" -eq "0" ]; then
  PPP0=OK
  echo $"Looks like we're online... " | tee -a $LOGFILE
  ping -c1 www.google.com > /dev/null
  if [ "$?" -eq "0" ]; then
    echo $"Hey look, I can see the Net from here!" | tee -a $LOGFILE
  else
    echo $"Cannot ping www.google.com - trying steve-parker.org by
numeric IP" | tee -a $LOGFILE
    ping -c1 195.224.68.226 > /dev/null
    if [ "$?" -eq "0" ]; then
      echo $"Looks like DNS might be iffy ... sorting it out" | tee -a $LOGFILE
      check_resolv_conf
    else
      echo $"I can't ping even without DNS" | tee -a $LOGFILE
    fi
  fi
else
  echo "*********************************"
  echo $"* Don't seem to have connected. *" | tee -a $LOGFILE
  echo "*********************************"
  echo $"Please check the username and password in /etc/ppp/*-secrets."
  echo $"Also check the VPI/VCI in /etc/ppp/peers/adsl"
  echo $"Then run ${rc_dir}/speedtouch start"
  echo $"Current settings: ${ISP_LOGIN} / ${ISP_PASSWORD} / ${VPI} / ${VCI}"
  exit 1
fi

echo "--- dns ---" >> $LOGFILE
ls -l /etc/resolv.conf /etc/ppp/resolv.conf >> $LOGFILE 2>&1
echo "--- /etc/resolv.conf ---" >> $LOGFILE
cat /etc/resolv.conf >> $LOGFILE
echo "--- /etc/ppp/resolv.conf ---" >> $LOGFILE
cat /etc/ppp/resolv.conf >> $LOGFILE
echo "--- end of diags ---" >> $LOGFILE


echo $"Configuration finished." | tee -a $LOGFILE
echo $"Any potential problems are listed below:"
if [ "$DNS" != "OK" ]; then
  echo $"The connection is established, but there seems to be some
problem with DNS (looking up the names of internet hosts)"
fi

CHKCONFIG=""
if [ -x /usr/lib/lsb/install_initd ]; then
 CHKCONFIG="/usr/lib/lsb/install_initd speedtouch"
else
  type update-rc.d > /dev/null 2>&1
  if [ "$?" -eq "0" ]; then
    CHKCONFIG="update-rc.d speedtouch start 90 2 3 4 5 . stop 10 0 1 6 ."
  else
    type chkconfig > /dev/null 2>&1
    if [ "$?" -eq "0" ]; then
      CHKCONFIG="chkconfig speedtouch start 90 2 3 4 5 . stop 10 0 1 6 ."
#      chkconfig 2>&1 |grep -qw add
#      if [ "$?" -eq "0" ]; then
#        # It's the more common version of chkconfig (LSB doesn't
specify usage):
#	CHKCONFIG="chkconfig --add speedtouch"
#      fi
    fi
  fi
fi

if [ ! -z "${CHKCONFIG}" ]; then
  echo $"To automatically dial-in when the PC boots up : " | tee -a $LOGFILE
  echo "${CHKCONFIG}" | tee -a $LOGFILE
  echo $"Do you want to set this up now? (Yes / No)"
  read ans
  a=`echo $ans | awk '{ print $1 }' | cut -c1 | tr '[A-Z]' '[a-z]'`
  if [ "$a" == "y" ]; then
    $CHKCONFIG
    if [ "$?" -eq "0" ]; then
      echo $"init command succeeded" | tee -a $LOGFILE
    else
      echo $"init command failed" | tee -a $LOGFILE
      echo $"You can still stop and start the interface with "
      echo "  ${rc_dir}/speedtouch stop"
      echo "  ${rc_dir}/speedtouch start"
    fi
  fi
fi

if [ "$PPP0" == "OK" ]; then
  echo $"You are now connected. There is no need to run this
speedtouchconf.sh script again."
  echo $"Congratulations."
fi

exit 0
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list