Please note: This project is no longer active. The website is kept online for historic purposes only.
If you´re looking for a Linux driver for your Atheros WLAN device, you should continue here .

Ticket #182: wifi-up.2

File wifi-up.2, 2.0 kB (added by anonymous, 14 years ago)
Line 
1 #! /bin/bash
2
3 ## typical usages:
4 ##      IFACE=ath0 ./wifi-up
5 ##      IFACE=ath0 key=none ./wifi-up
6
7   echo ... start of wifi-up $IFACE
8   sync                  ## beware of experimental drivers
9
10   mydir=$(dirname $0);    : ${mydir:=.}
11
12   def_essid=(snark MacNaughton)
13   def_wlanmode=(ap sta monitor monitor)
14   def_speedmode=(3 2   3       2)
15
16   : ${IFACE:=ath0}
17    
18   num=$( echo $IFACE | sed 's/[a-zA-Z]*//;s/:.*//' )
19   xnum=$((num % 2))
20   : ${essid:=${def_essid[$xnum]}}
21   : ${wlanmode:=${def_wlanmode[$num]}}
22   : ${speedmode:=${def_speedmode[$num]}}
23  
24   if test -z "$key" ; then
25     key=$( cat $mydir/$essid.key )
26   fi
27   echo "wifi-up: $essid $wlanmode $key $speedmode"
28
29   for var in IFACE essid key wlanmode ; do
30     if test -z "${!var}" ; then
31            1>&2 echo  "wifi-up: missing arg '$var'"
32            exit 1
33     fi
34   done
35
36
37   modprobe ath_pci              ## may or may not be necessary
38  ## ifconfig $IFACE down        ## not necessary; dhclient3 will down the device
39
40  #!!! The following line is a disaster:
41  #!!!   wlanconfig $IFACE destroy || true
42  #!!! apparently it does something like "dhclient3 -r"
43  #!!! and does it asynchronously, creating a race. 
44    #!!! The weirdest part is that I see a "RELEASE" message
45    #!!! in /var/log/daemon.log
46    #!!! but I don't see debug-printouts from dhclient-script.
47  #!!! In any case, the result is that the dhcp lease is released
48  #!!! within milliseconds of being acquired.
49  #!!!
50  #!!! The following is no better, although (sometimes?) harmless if the device has
51  #!!! already been destroyed.
52  #!!!   if wlanconfig $IFACE destroy ; then
53  #!!!     echo '(needed destroying)'
54  #!!!     sleep 30
55  #!!!   else
56  #!!!     echo '(fresh)'
57  #!!!   fi
58
59   if wlanconfig $IFACE list > /dev/null 2>/dev/null ; then
60     echo "(Didn't need creating)"
61   else
62     wlanconfig $IFACE create wlandev wifi0 wlanmode $wlanmode
63   fi
64   iwpriv $IFACE mode $speedmode         ## 801.11b
65   iwconfig $IFACE essid $essid
66   if test -z "${key##[Nn]*}" ; then
67     iwconfig $IFACE key off
68   else
69     iwconfig $IFACE key $key [1]
70     iwconfig $IFACE key [1] restricted
71   fi
72   echo ... end of wifi-up