#!/bin/sh

# This script will install the madwifi drivers for Atheros cards.
# The script must be run in a root terminal with 755 permission
# This script differs from the madwifi.sh script as it does not install network manager
#
# Authored by Bob Nelson  admin@stchman.com
#

script_name="madwifi_feisty.sh"

# Script must run as root 
if [ $USER != "root" ]; then
	echo "You need to run this script as root."
	echo "Use 'sudo ./$script_name' then enter your password when prompted."
	exit 1
fi

# Install essential tools
sudo apt-get -y install build-essential bin86

# Install the sharutils package
sudo apt-get -y install sharutils

# Change to the /usr/src folder
cd /usr/src

# Get the necessary drivers from www.stchman.com
sudo wget http://www.stchman.com/tools/madwifi/madwifi-0.9.3.3.tar.gz

# unpack the tarball
sudo tar -xzf /usr/src/madwifi-0.9.3.3.tar.gz

# Change to the folder that the tarball created
cd /usr/src/madwifi-0.9.3.3

# Make the drivers
sudo make clean
sudo make
sudo make install

# Make backup of /etc/modules file
sudo cp /etc/modules /etc/modules.bak

# Append to the end of the /etc/modules file by using >>
# First insert a carriage return in to the /etc/modules file
sudo echo -e '\n' >> /etc/modules
sudo echo "ath_pci" >> /etc/modules

# Reboot the machine, wireless should now be enabled!!!!
sudo reboot
