Is there a better way to auto-start ath5k wireless driver?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I noticed that after I install the ath5k drivers from the latest tarball at wireless.kernel.org for my Atheros 5007EG, I had to go back to the download directory after each reboot and run "make load". I did not know what make load did but after some tracing I noticed it runs a script called load.sh. Here is the contents of load.sh:
#!/bin/bash
MODULES="ipw2100 ipw2200 libertas_cs usb8xxx"
MODULES="$MODULES p54pci p54usb"
MODULES="$MODULES adm8211 zd1211rw"
MODULES="$MODULES rtl8180 rtl8187"
MODULES="$MODULES p54pci p54usb"
MODULES="$MODULES iwl3945 iwl4965"
MODULES="$MODULES rtl8180 rtl8187"
MODULES="$MODULES rtl8180 rtl8187"
MODULES="$MODULES rt2400pci rt2500pci rt61pci"
MODULES="$MODULES rt2500usb rt73usb"
MODULES="$MODULES rndis_wlan at76_usb"
for i in $MODULES; do
echo Loading $i...
modprobe $i
done
# For ath5k we must be sure to unload MadWifi first
athload ath5k
# For b43 we must make sure to unload bcm43xx first
b43load b43
Can someone explain what this code is doing? Also, the bigger question is "What is the best way to autoload the wireless driver at boot?". I did not neccesarily want to put a copy of this script in my startup folder because:
1) That seems kind of hacky
2) I want this to load when any user logs in. Not just me.
3) I think maybe some of the script above is not neccesary, but I do not understand what it is doing.
Can an expert help me find the best way to autoload my wireless at boot?
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313
Thanked: 0
Original Poster
Thanks Tredegar. Running
Quote:
sudo athload ath5k
did the trick. At first, I was only connected to the router with half power, but I switched the router from compatibility mode to performance mode and also set it to "g" mode only (no "b" allowed) and the connection went from 50% to 94%. I think the ducts in my house are responsible for the 6% loss. I would say the driver is working well.
That being said, what is the official Linux-way to auto run this driver load process at login? In Windows I am thinking of the "Startup" folder in the All Users directory. This would be C:\Documents and Settings\All Users\Startup. Is there a Linux equivalent to this?
what is the official Linux-way to auto run this driver load process at login?
Well, this being linux, there are lots of different ways you can do this.
But the quick & easy way is to add your command to the file /etc/rc.local
That file/script is run once, when your PC is booting up, after (almost) everything else has been started.
So just add a couple of lines like this to the file, just before the final exit 0
so it now looks like this:
Code:
# Comment: load the atheros module to enable wireless
/full/path/to/athload ath5k
exit 0
You do not need the sudo in that script as it is run as the root user.
You will need to be root to edit that file
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313
Thanked: 0
Original Poster
Adding this to rc.local worked:
Quote:
#added by JD on 12/31/2008 to load the drivers for the atheros 5007eg wireless card
/home/ubuntu/programs/athload/athload ath5k
So is rc.local run for any user?
Also is rc.local run as part of the boot up process or is it run when a user logs into the machine?
I guess it is for all users since the directory /etc is so generic but I can never be sure with Linux's complexity.
I found bashrc in my home directory and thought this might be the login run script, but upon opening it up, it looks to complicated to serve this function.
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313
Thanked: 0
Original Poster
Adding this to rc.local worked:
Quote:
#added by JD on 12/31/2008 to load the drivers for the atheros 5007eg wireless card
/home/ubuntu/programs/athload/athload ath5k
So is rc.local run for any user?
Also is rc.local run as part of the boot up process or is it run when a user logs into the machine?
I guess it is for all users since the directory /etc is so generic but I can never be sure with Linux's complexity.
I found bashrc in my home directory and thought this might be the user level login script, but upon opening it up, it looks to complicated to serve this function.
Also is rc.local run as part of the boot up process or is it run when a user logs into the machine?
From my post #4:
Quote:
That file/script is run once, when your PC is booting up, after (almost) everything else has been started.
Networking is generally considered to be important enough to be started even before any users have logged in locally (for example, you, or someone else, might want to login remotely, and you can't if the network is down and you have set networking only to start when you have logged in locally).
Having a script in your home directory that is run by root is potentially a big security flaw.
Think about it.
If you wanted to do this properly, you should move (as root) the script athload to the directory /sbin and give it proper permissions and ownership:
Those permissions say "Only root can change this file, others can read and execute it, but not change it"
And then update the path in your rc.local so it reflects where the script is now:
Code:
/sbin/athload ath5k
You should read the script athload to see if it expects to find the module ath5k in its current directory, or this may not work.
If you don't understand, then post the script here and we'll take a look at it for you.
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313
Thanked: 0
Original Poster
Quote:
Having a script in your home directory that is run by root is potentially a big security flaw.
I see. So if someone gained access to my account and modified the script, then they could put adduser in the script to create a root level backdoor account for themselves. I am still getting used to Linux so I did not even think about this.
I read the athload file. It does assume that two other scripts are in the same directory, so I moved the entire athload directory (which contains the athload file plus the others) and set up root as owner and gave those permissions. Upon rebooting it all worked the first try.
If the following works for your WiFi setup, you can use init.d to start it during startup:
$ sudo modprobe ath5k
$ sudo ip link set wlan0 up
$ sudo iwconfig wlan0 essid any
I have created the following file as /etc/init.d/ath5k:
Code:
#!/bin/sh -e
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
case "$1" in
start)
modprobe ath5k
ip link set wlan0 up
iwconfig wlan0 essid any
;;
stop)
;;
force-reload|restart)
;;
*)
;;
esac
exit 0
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.