]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/rc.d/rc.alcatelusbk
Ein NTFS-Update fuer den Heiner :D
[people/pmueller/ipfire-2.x.git] / src / rc.d / rc.alcatelusbk
CommitLineData
cd1a2927
MT
1#!/bin/bash
2#
3# $Id: rc.alcatelusbk,v 1.6.2.11 2005/07/07 20:11:57 franck78 Exp $
4#
5
6eval $(/usr/local/bin/readhash CONFIG_ROOT/ppp/settings)
7
8# Debugging. Comment it out to stop logging
9DEBUG="yes"
10msg() {
11 if [ "z$DEBUG" != "z" ] ; then
12 /usr/bin/logger -t red "Speedtouch USB K: $*"
13 fi
14 /bin/echo "$*"
15}
16
17
18# See how we were called.
19case "$1" in
20 start)
21 if [ ! -f "/proc/bus/usb/devices" ]; then
22 msg "No USB enabled"
23 exit 1
24 fi
25 speedtouch=`/bin/cat /proc/bus/usb/devices | /bin/grep 'Vendor=06b9 ProdID=4061' | /usr/bin/cut -d ' ' -f6`
26 case "$speedtouch" in
27 '')
28 msg "No Speedtouch found"
29 exit 1
30 ;;
31 '0.00' | '0.01' | '2.00')
32 modem='v0123'
33 # Speedtouch 530 aka Rev 3.00 does not work actually
34 ;;
35 '4.00')
36 modem='v4_b'
37 ;;
38 *)
39 msg "Unknown version or unsupported model Rev $speedtouch"
40 exit 1
41 ;;
42 esac
43 if ( ! /bin/ps -ef | /bin/grep -q '[m]odem_run -k'); then
44 # modem_run was killed by "hub.c: already running port x disabled by hub (EMI?), re-enabling..."
45 /sbin/modprobe -r speedtch
46 fi
47 if ( ! /sbin/lsmod | /bin/grep -q [s]peedtch ); then
48 if ( /bin/ps -ef | /bin/grep -q [m]odem_run ); then
49 # switching from user to kernel mode
50 msg "need to kill previous modem_run"
51 /bin/killall /usr/sbin/modem_run
52 /usr/local/bin/resetusb
53 fi
54 /sbin/modprobe speedtch
55 /usr/sbin/modem_run -k -v 1 -t 90 -n 4 -f CONFIG_ROOT/alcatelusb/firmware.$modem.bin
56 if [ $? -ne 0 ]; then
57 msg "firmware download failed : will reset USB and try again"
58 /sbin/modprobe -r speedtch
59 /usr/local/bin/resetusb
60 /sbin/modprobe speedtch
61 /usr/sbin/modem_run -k -v 1 -t 90 -n 4 -f CONFIG_ROOT/alcatelusb/firmware.$modem.bin
62 if [ $? -ne 0 ]; then
63 exit 1
64 fi
65 fi
66 # time to avoid "Ressource temporary unavailable"
67 /bin/sleep 5
68 fi
69 exit 0
70 ;;
71 stop)
72 msg "stop"
73 ;;
74 cleanup)
75 msg "driver cleanup and USB Bus reset"
76 /sbin/modprobe -r speedtch
77 /usr/local/bin/resetusb
78 ;;
79 *)
80 /bin/echo "Usage: $0 {start|stop|cleanup}"
81 exit 1
82 ;;
83esac
84
85exit 0
86