]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/bin/bash |
2 | # | |
3 | # $Id: rc.bewanadsl,v 1.5.2.6 2005/07/07 20:11:58 franck78 Exp $ | |
4 | # | |
5 | ||
6 | eval $(/usr/local/bin/readhash CONFIG_ROOT/ppp/settings) | |
7 | ||
8 | # Debugging. Comment it out to stop logging | |
9 | DEBUG="yes" | |
10 | msg() { | |
11 | if [ "z$DEBUG" != "z" ] ; then | |
12 | /usr/bin/logger -t red "BEWAN ADSL: $*" | |
13 | fi | |
14 | /bin/echo "$*" | |
15 | } | |
16 | ||
17 | function wait_for_showtime() { | |
18 | count=0 | |
19 | while [ ! $count = 45 ]; do | |
20 | /bin/sleep 2 | |
21 | if ( /bin/cat /proc/net/atm/UNICORN:* | /bin/grep -q "SHOWTIME" ); then | |
22 | return 0 | |
23 | fi | |
24 | ((++count)) | |
25 | done | |
26 | return 1 | |
27 | } | |
28 | ||
29 | if [ "$MODEM" = "PCIST" ]; then | |
30 | UNICORN="unicorn_pci_atm" | |
31 | else | |
32 | UNICORN="unicorn_usb_atm" | |
33 | if [ ! -f "/proc/bus/usb/devices" ]; then | |
34 | msg "No USB enabled" | |
35 | exit 1 | |
36 | fi | |
37 | # commented because actually cat /proc/bus/usb/devices may trigger some verbose error until pppd session start | |
38 | # if ( ! /bin/cat /proc/bus/usb/devices | /bin/grep -q 'Vendor=07fa' ); then | |
39 | # msg "No ST chip : not supported by this driver" | |
40 | # exit 1 | |
41 | # fi | |
42 | fi | |
43 | # See how we were called. | |
44 | case "$1" in | |
45 | start) | |
46 | # ActivationMode : ANSI=1,G.lite=2,MULTI=3,G.dmt=4 | |
47 | case "$MODULATION" in | |
48 | GDMT) ActivationMode=4 ;; | |
49 | ANSI) ActivationMode=1 ;; | |
50 | GLITE) ActivationMode=2 ;; | |
51 | AUTO) ActivationMode=3 ;; | |
52 | esac | |
53 | msg "Loading $UNICORN, Modulation=$MODULATION, may take time to uncompress..." | |
54 | /sbin/modprobe "$UNICORN" ActivationMode="$ActivationMode" | |
55 | if [ ! $? = 0 ]; then | |
56 | msg "Loading fail, is the modem plugged in?" | |
57 | exit 1 | |
58 | fi | |
59 | wait_for_showtime | |
60 | if [ $? = 1 ]; then | |
61 | exit 1 | |
62 | fi | |
63 | ;; | |
64 | stop) | |
65 | msg "stop" | |
66 | ;; | |
67 | cleanup) | |
68 | msg "cleanup" | |
69 | /sbin/modprobe -r "$UNICORN" | |
70 | ;; | |
71 | *) | |
72 | /bin/echo "Usage: $0 {start|stop|cleanup}" | |
73 | exit 1 | |
74 | ;; | |
75 | esac | |
76 | ||
77 | exit 0 |