wl1251: prevent scan when connected
[pandora-wifi.git] / scripts / athload
1 #!/bin/bash
2 # Copyright 2007        Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
3 #
4 # Loads ath5k or madwifi
5
6 . /usr/lib/compat-wireless/modlib.sh
7
8 if [[ $UID -ne 0 ]]; then
9         echo "Run with root privileges"
10         exit
11 fi
12
13
14 USAGE="Usage: $0 [ ath5k | madwifi ]"
15
16 # Default behavior: unload MadWifi and load ath5k
17 if [ $# -eq 0 ]; then
18         athenable ath5k
19         exit
20 elif [ $# -ne 1 ]; then
21                 echo "$USAGE"
22                 exit
23 fi
24
25 MODULE=$1
26 if [ "$MODULE" == "ath5k" ]; then
27         madwifi-unload
28         athenable ath5k
29         modprobe ath5k
30         CHECK=`modprobe -l ath5k`
31         if [ ! -z $CHECK ]; then
32                 echo "ath5k loaded successfully"
33         fi
34         modprobe ath9k
35         CHECK=`modprobe -l ath9k`
36         if [ ! -z $CHECK ]; then
37                 echo "ath9k loaded successfully"
38         fi
39 elif [ "$MODULE" == "madwifi" ]; then
40         CHECK=`modprobe -l ath5k`
41         if [ ! -z $CHECK ]; then
42                 echo "ath5k currently loaded, going to try to unload the module..."
43                 modprobe -r --ignore-remove ath5k
44         fi
45         athenable madwifi
46         # MadWifi may be loaded, but it doesn't mean devices
47         # currently available were picked up
48         madwifi-unload 2>&1 > /dev/null
49         modprobe ath_pci
50         CHECK=`modprobe -l ath_pci`
51         if [ ! -z $CHECK ]; then
52                 echo "MadWifi loaded successfully!"
53         fi
54 else
55         echo "$USAGE"
56         exit
57 fi