LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 12-28-2008, 07:47 PM   #1
jdruin
Member
 
Registered: Jul 2003
Location: Louisville aka Derby City
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313

Rep: Reputation: 30
Is there a better way to auto-start ath5k wireless driver?


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?
 
Old 12-29-2008, 03:26 AM   #2
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
Quote:
Can someone explain what this code is doing?
Code:
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"
^ This bit makes a long list of modules
Code:
for i in $MODULES; do
echo Loading $i...
modprobe $i
done
^ This bit loads them all, one at a time.
But you don't need any of them, because you have an Atheros 5007EG
Code:
# For ath5k we must be sure to unload MadWifi first
athload ath5k
^ This bit loads the ath5k module, which, it seems, you do need.
look at the script athload to see what it does.

Try booting, then just try running (as root) /path/to/athload ath5k
Does your wireless work now?
 
Old 12-30-2008, 06:30 PM   #3
jdruin
Member
 
Registered: Jul 2003
Location: Louisville aka Derby City
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313

Original Poster
Rep: Reputation: 30
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?
 
Old 12-31-2008, 04:03 AM   #4
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
Quote:
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

Reboot, and your wireless should be working.
 
Old 12-31-2008, 08:06 PM   #5
jdruin
Member
 
Registered: Jul 2003
Location: Louisville aka Derby City
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313

Original Poster
Rep: Reputation: 30
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.
 
Old 12-31-2008, 08:07 PM   #6
jdruin
Member
 
Registered: Jul 2003
Location: Louisville aka Derby City
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313

Original Poster
Rep: Reputation: 30
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.
 
Old 01-01-2009, 03:41 AM   #7
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
Quote:
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:

Code:
mv /home/ubuntu/programs/athload/athload  /sbin
chown root:root /sbin/athload
chmod 755 /sbin/athload
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.
 
Old 01-01-2009, 04:19 PM   #8
jdruin
Member
 
Registered: Jul 2003
Location: Louisville aka Derby City
Distribution: WinXP SP2 and SP3, W2K Server, Ubuntu
Posts: 313

Original Poster
Rep: Reputation: 30
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.

Thanks for the help.
 
Old 06-30-2009, 12:48 PM   #9
everweb
LQ Newbie
 
Registered: Nov 2007
Posts: 3

Rep: Reputation: 0
Thumbs up Using runlevels to start ath5k

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
I then set up the symbolic links as follows:
-rwxr-xr-x 1 root root 281 2009-06-30 10:58 /etc/init.d/ath5k
lrwxrwxrwx 1 root root 17 2009-06-30 11:00 /etc/rc0.d/K20ath5k -> /etc/init.d/ath5k
lrwxrwxrwx 1 root root 17 2009-06-30 11:01 /etc/rc1.d/K20ath5k -> /etc/init.d/ath5k
lrwxrwxrwx 1 root root 17 2009-06-30 11:02 /etc/rc2.d/S20ath5k -> /etc/init.d/ath5k
lrwxrwxrwx 1 root root 17 2009-06-30 11:03 /etc/rc3.d/S20ath5k -> /etc/init.d/ath5k
lrwxrwxrwx 1 root root 17 2009-06-30 11:03 /etc/rc4.d/S20ath5k -> /etc/init.d/ath5k
lrwxrwxrwx 1 root root 17 2009-06-30 11:03 /etc/rc5.d/S20ath5k -> /etc/init.d/ath5k
lrwxrwxrwx 1 root root 17 2009-06-30 11:04 /etc/rc6.d/K20ath5k -> /etc/init.d/ath5k
 
Old 06-30-2009, 01:31 PM   #10
farslayer
Guru
 
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: linuxdebian
Posts: 7,231
Blog Entries: 5

Rep: Reputation: 189Reputation: 189
per the Debian wiki on the ath5k driver you just need to modify /etc/modprobe.d/madwifi to configure the module to load at startup..

http://wiki.debian.org/ath5k

Can't imagine Ubuntu is very different..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wireless installation problem (ath5k); can't set WEP key (madwifi) jdtiede Linux - Wireless Networking 0 12-11-2008 04:09 PM
Trying to get ATH5k to work C-Sniper Slackware 2 07-02-2008 09:56 AM
How to auto start my RT2600 wireless kseinchin Linux - Wireless Networking 0 03-23-2007 04:32 PM
How do I auto start modules that aren't auto loaded on boot? darkbluedrew Debian 2 09-18-2005 09:10 AM
eth0 Auto Connect, How to auto start on logon cornish Linux - Networking 2 05-09-2005 12:02 PM


All times are GMT -5. The time now is 09:29 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration