#!/bin/bash
#
# Copyright 2007	Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
#
# Makes sure either ath5k or MadWifi are ready to be used. This allows
# us to choose any driver without blacklisting each other.

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

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

ATH5K="ath5k"
ATH9K="ath9k"
MADWIFI="ath_pci"
# Appended to module file at the end when we want to ignore one
IGNORE_SUFFIX=".ignore"
USAGE="Usage: $0 [ ath5k | madwifi ]"

# Default behavior: disables any MadWifi driver present and makes sure
# ath5k is enabled
if [ $# -eq 0 ]; then
	module_disable $MADWIFI
	module_enable $ATH5K
	module_enable $ATH9K
	exit
elif [ $# -ne 1 ]; then
	echo "$USAGE"
	exit
fi

MODULE=$1
if [ "$MODULE" == "ath5k" ]; then
	module_disable $MADWIFI
	module_enable $ATH5K
	module_enable $ATH9K
elif [ "$MODULE" == "madwifi" ]; then
	module_disable $ATH5K
	module_disable $ATH9K
	module_enable $MADWIFI
else
	echo "$USAGE"
	exit
fi
