LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Is there a better way to auto-start ath5k wireless driver? (https://www.linuxquestions.org/questions/linux-networking-3/is-there-a-better-way-to-auto-start-ath5k-wireless-driver-693534/)

jdruin 12-28-2008 07:47 PM

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?

tredegar 12-29-2008 03:26 AM

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?

jdruin 12-30-2008 06:30 PM

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?

tredegar 12-31-2008 04:03 AM

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.

jdruin 12-31-2008 08:06 PM

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.

jdruin 12-31-2008 08:07 PM

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.

tredegar 01-01-2009 03:41 AM

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.

jdruin 01-01-2009 04:19 PM

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.

everweb 06-30-2009 12:48 PM

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

farslayer 06-30-2009 01:31 PM

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..


All times are GMT -5. The time now is 04:17 PM.