1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#!/bin/bash
#
# $Id: rc.alcatelusb,v 1.7.2.12 2005/07/07 20:11:57 franck78 Exp $
#
eval $(/usr/local/bin/readhash /var/ipcop/ppp/settings)
# Debugging. Comment it out to stop logging
DEBUG="yes"
msg() {
if [ "z$DEBUG" != "z" ] ; then
/usr/bin/logger -t red "Speedtouch USB: $*"
fi
/bin/echo "$*"
}
function wait_for_iface()
{
msg "Waiting for interface: $1"
COUNTER=10
FLREADY=0
TIMES=1
while [ $TIMES -le $COUNTER ]; do
/sbin/ifconfig $1> /dev/null 2>&1
if [ $? -eq 0 ]; then
FLREADY=1
break
fi
/bin/sleep 1
TIMES=$(expr $TIMES + 1)
done
if [ "$FLREADY" -eq 0 ]; then
msg "Interface not found: $1"
exit 1
fi
}
# 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 ); then
rm -f /var/run/pppoa3-modem*.pid
msg "Uploading firmware to modem"
/usr/sbin/modem_run -v 1 -t 90 -n 4 -f /var/ipcop/alcatelusb/firmware.$modem.bin
# Check if Firmware uploaded ok. Reset USB if Failed
if [ $? -ne 0 ]; then
msg "Firmware upload failed: Retrying"
/usr/local/bin/resetusb
/usr/sbin/modem_run -v 1 -t 90 -n 4 -f /var/ipcop/alcatelusb/firmware.$modem.bin
if [ $? -ne 0 ]; then
msg "Firmware upload failed: Exiting"
exit 1
fi
fi
fi
# Alcatel USB PPPoE Mode
if [ "$PROTOCOL" = "RFC1483" ]; then
iface="tap0"
/sbin/modprobe tun
/usr/sbin/pppoa3 -b -c -m 1 -vpi $VPI -vci $VCI
wait_for_iface $iface
/sbin/ifconfig $iface up
exit $?
fi
exit 0
;;
stop)
msg "stop"
/bin/killall pppoa3 2>/dev/null
/bin/sleep 1
/sbin/modprobe -r tun
;;
cleanup)
msg "driver cleanup and USB Bus reset"
/usr/local/bin/resetusb
;;
*)
/bin/echo "Usage: $0 {start|stop|cleanup}"
exit 1
;;
esac
exit 0
|