summaryrefslogtreecommitdiff
path: root/scripts/athload
blob: 96b28c3c98fc5eb19bf27cb9d5fec566112bc8dc (plain)
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
#!/bin/bash
# Copyright 2007	Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
#
# Loads ath5k or madwifi

. /usr/lib/compat-drivers/modlib.sh

if [[ $UID -ne 0 ]]; then
	echo "Run with root privileges"
	exit
fi


USAGE="Usage: $0 [ ath5k | madwifi ]"

# Default behavior: unload MadWifi and load ath5k
if [ $# -eq 0 ]; then
	athenable ath5k
	exit
elif [ $# -ne 1 ]; then
		echo "$USAGE"
		exit
fi

MODULE=$1
if [ "$MODULE" == "ath5k" ]; then
	madwifi-unload
	athenable ath5k
	modprobe ath5k
	CHECK=`modprobe -l ath5k`
	if [ ! -z $CHECK ]; then
		echo "ath5k loaded successfully"
	fi
	modprobe ath9k
	CHECK=`modprobe -l ath9k`
	if [ ! -z $CHECK ]; then
		echo "ath9k loaded successfully"
	fi
elif [ "$MODULE" == "madwifi" ]; then
	CHECK=`modprobe -l ath5k`
	if [ ! -z $CHECK ]; then
		echo "ath5k currently loaded, going to try to unload the module..."
		modprobe -r --ignore-remove ath5k
	fi
	athenable madwifi
	# MadWifi may be loaded, but it doesn't mean devices
	# currently available were picked up
	madwifi-unload 2>&1 > /dev/null
	modprobe ath_pci
	CHECK=`modprobe -l ath_pci`
	if [ ! -z $CHECK ]; then
		echo "MadWifi loaded successfully!"
	fi
else
	echo "$USAGE"
	exit
fi