#!/bin/bash # # $Id: rc.alcatelusbk,v 1.6.2.11 2005/07/07 20:11:57 franck78 Exp $ # eval $(/usr/local/bin/readhash CONFIG_ROOT/ppp/settings) # Debugging. Comment it out to stop logging DEBUG="yes" msg() { if [ "z$DEBUG" != "z" ] ; then /usr/bin/logger -t red "Speedtouch USB K: $*" fi /bin/echo "$*" } # See how we were called. case "$1" in start) if [ ! -f "/proc/bus/usb/devices" ]; then msg "No USB enabled" exit 1 fi speedtouch=`/bin/cat /proc/bus/usb/devices | /bin/grep 'Vendor=06b9 ProdID=4061' | /usr/bin/cut -d ' ' -f6` case "$speedtouch" in '') msg "No Speedtouch found" exit 1 ;; '0.00' | '0.01' | '2.00') modem='v0123' # Speedtouch 530 aka Rev 3.00 does not work actually ;; '4.00') modem='v4_b' ;; *) msg "Unknown version or unsupported model Rev $speedtouch" exit 1 ;; esac if ( ! /bin/ps -ef | /bin/grep -q '[m]odem_run -k'); then # modem_run was killed by "hub.c: already running port x disabled by hub (EMI?), re-enabling..." /sbin/modprobe -r speedtch fi if ( ! /sbin/lsmod | /bin/grep -q [s]peedtch ); then if ( /bin/ps -ef | /bin/grep -q [m]odem_run ); then # switching from user to kernel mode msg "need to kill previous modem_run" /bin/killall /usr/sbin/modem_run /usr/local/bin/resetusb fi /sbin/modprobe speedtch /usr/sbin/modem_run -k -v 1 -t 90 -n 4 -f CONFIG_ROOT/alcatelusb/firmware.$modem.bin if [ $? -ne 0 ]; then msg "firmware download failed : will reset USB and try again" /sbin/modprobe -r speedtch /usr/local/bin/resetusb /sbin/modprobe speedtch /usr/sbin/modem_run -k -v 1 -t 90 -n 4 -f CONFIG_ROOT/alcatelusb/firmware.$modem.bin if [ $? -ne 0 ]; then exit 1 fi fi # time to avoid "Ressource temporary unavailable" /bin/sleep 5 fi exit 0 ;; stop) msg "stop" ;; cleanup) msg "driver cleanup and USB Bus reset" /sbin/modprobe -r speedtch /usr/local/bin/resetusb ;; *) /bin/echo "Usage: $0 {start|stop|cleanup}" exit 1 ;; esac exit 0