3 # $Id: rc.eciadsl,v 1.4.2.14 2005/07/28 16:47:43 gespinasse Exp $
6 eval $
(/usr
/local
/bin
/readhash CONFIG_ROOT
/ppp
/settings
)
8 # Debugging. Comment it out to stop logging
11 if [ "z$DEBUG" != "z" ] ; then
12 /usr
/bin
/logger
-t red
"ECI USB: $*"
17 # Function to wait for interface to become ready
18 # Borrowed from eciadsl startmodem script
19 function wait_for_iface
()
21 msg
"Waiting for interface: $1"
25 while [ $TIMES -le $COUNTER ]; do
26 /sbin
/ifconfig
$1> /dev
/null
2>&1
32 TIMES
=$
(expr $TIMES + 1)
34 if [ "$FLREADY" -eq 0 ]; then
35 msg
"Interface not found: $1"
40 # See how we were called.
43 if [ ! -f "CONFIG_ROOT/eciadsl/synch.bin" ]; then
44 msg
"Synch.bin not uploaded"
48 if [ ! -f "/proc/bus/usb/devices" ]; then
53 VID1
="$(/bin/grep "$MODEM " "/etc
/eciadsl
/modems.db
" | /usr/bin/tr -s "\t" "|
" | /usr/bin/cut -d '|' -f 2)"
54 PID1
="$(/bin/grep "$MODEM " "/etc
/eciadsl
/modems.db
" | /usr/bin/tr -s "\t" "|
" | /usr/bin/cut -d '|' -f 3)"
55 VID2
="$(/bin/grep "$MODEM " "/etc
/eciadsl
/modems.db
" | /usr/bin/tr -s "\t" "|
" | /usr/bin/cut -d '|' -f 4)"
56 PID2
="$(/bin/grep "$MODEM " "/etc
/eciadsl
/modems.db
" | /usr/bin/tr -s "\t" "|
" | /usr/bin/cut -d '|' -f 5)"
57 CHIP
="$(/bin/grep "$MODEM " "/etc
/eciadsl
/modems.db
" | /usr/bin/tr -s "\t" "|
" | /usr/bin/cut -d '|' -f 6)"
58 ALTS
="$(/bin/grep "$MODEM " "/etc
/eciadsl
/modems.db
" | /usr/bin/tr -s "\t" "|
" | /usr/bin/cut -d '|' -f 7)"
59 ALTP
="$(/bin/grep "$MODEM " "/etc
/eciadsl
/modems.db
" | /usr/bin/tr -s "\t" "|
" | /usr/bin/cut -d '|' -f 8)"
61 if [ "$CHIP" = '' ]; then
62 msg
"error in modems.db reading for $MODEM no CHIP found"
67 if [ "$CHIP" = 'GS7070' ]; then
68 if ( /bin
/grep -q "^P: Vendor=$VID1 ProdID=$PID1" /proc
/bus
/usb
/devices
); then
69 /bin
/rm -f /var
/ipcop
/red
/eciadsl-synch-done
71 msg
"Loading Firmware for $MODEM"
72 /usr
/sbin
/eciadsl-firmware
0x
$VID1 0x
$PID1 0x
$VID2 0x
$PID2 /etc
/eciadsl
/firmware00.bin
74 if [ "$RET" -ne "0" ]; then
75 msg
"$MODEM failed to load firmware, reason: $RET"
82 if ( ! /bin
/grep -q "^P: Vendor=$VID2 ProdID=$PID2" /proc
/bus
/usb
/devices
); then
83 msg
"$MODEM modem not found ready"
88 if [ ! -e "CONFIG_ROOT/red/eciadsl-synch-done" ]; then
89 /usr
/sbin
/eciadsl-synch
-alt $ALTS -mc $CHIP 0x
$VID2 0x
$PID2 CONFIG_ROOT
/eciadsl
/synch.bin
91 if [ "$RET" -ne "0" ]; then
92 msg
"$MODEM failed to get synchronization, reason:$RET"
95 /bin
/touch CONFIG_ROOT
/red
/eciadsl-synch-done
99 if [ "$PROTOCOL" = "RFC1483" ]; then
101 0) ECIMODE
="LLC_SNAP_RFC1483_BRIDGED_ETH_NO_FCS"
103 1) ECIMODE
="VCM_RFC_1483_BRIDGED_ETH"
105 2) ECIMODE
="LLC_RFC1483_ROUTED_IP"
107 3) ECIMODE
="VCM_RFC1483_ROUTED_IP"
109 *) msg
"Unknown encapsulation: $ENCAP"
115 if [ "$ENCAP" = "0" -o "$ENCAP" = "1" ]; then
121 /usr
/sbin
/eciadsl-pppoeci
-alt $ALTP -vpi $VPI -vci $VCI -vendor 0x
$VID2 -product 0x
$PID2 -mode $ECIMODE
122 wait_for_iface
$ECIIF
123 /sbin
/ifconfig
$ECIIF up
130 # Avoid possibility of multiple 'rc.eciadsl start' as only one prog can claim interface at a time
131 # and time for the full eci-load2 loop may be too long for the user to wait until to try once again
132 RCECIADSLSTART
=`/bin/ps ax | /bin/grep '[r]c.eciadsl start' | /usr/bin/cut -f1 -d ' '`
133 [ "$RCECIADSLSTART" != '' ] && /bin
/kill "$RCECIADSLSTART"
135 # -KILL is necessary because pppoeci ignores sigint
136 /bin
/killall
-KILL eciadsl-pppoeci eciadsl-firmware eciadsl-synch
2> /dev
/null
138 /sbin
/modprobe
-r tun
141 msg
"driver cleanup and USB Bus reset"
142 /usr
/local
/bin
/resetusb
143 /bin
/rm -f CONFIG_ROOT
/red
/eciadsl-synch-done
146 /bin
/echo "Usage: $0 {start|stop|cleanup}"