You are not logged in.

#1 2006-01-08 17:33:41

Menzonius
Member
From: Amsterdam, The Netherlands
Registered: 2006-01-07
Posts: 8

madwifi-ng preup/predown script question [solved]

Hi,

I recently installed Arch 0.7.1 on my laptop.
So far I am very impressed with the speed and the simplicity :-)

I just have one small problem: madwifi-ng

Currently, I have to manually create the ath0 interface with wlanconfig, which is annoying. On the Gentoo forum I have found a partial script with preup/predown functions (the thread is located here)

preup() {

        if [ "${IFACE}" == "ath0" ]; then
                /sbin/wlanconfig ath0 create wlandev wifi0 wlanmode sta > /dev/null
                return $?
        fi

        if mii-tool ${IFACE} 2> /dev/null | grep -q 'no link'; then
                ewarn "No link on ${IFACE}, aborting configuration"
                return 1
        fi

        return 0
}

predown() {
        if [ "${IFACE}" == "ath0" ]; then
                killall wpa_supplicant
                /sbin/wlanconfig ath0 destroy
                return $?
        fi

        return 0
}

I am using a Netgear WG511T pcmcia card.
I would really appreciate any suggestions on where to put this code, and how to modify it for use with Arch Linux, or if I should use something else alltogether.

Thanks in advance!

Offline

#2 2006-01-09 00:20:11

Menzonius
Member
From: Amsterdam, The Netherlands
Registered: 2006-01-07
Posts: 8

Re: madwifi-ng preup/predown script question [solved]

While my problem isn't really solved, for the time being I have added the following line to /etc/rc.local

/usr/sbin/wlanconfig ath0 create wlandev wifi0 wlanmode sta > /dev/null

But because the ath0 network interface does not exist untill the very last moment, netcfg tries to configure ath0 during boot before it exists and I have to run "netcfg netgear" again after ath0 is created ("netgear" is the name of my network-profile). So I think I'll just add that to rc.local too. I'm not a scripting expert unfortunately, but I think it'll work. Nonetheless, I would certainly welcome any suggestions for improvement, because I think this essentially breaks the whole idea of selecting network profiles :-)
Should I try modifying sections of /etc/rc.d/network, or should I really leave that alone?

Offline

#3 2006-01-09 17:18:12

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: madwifi-ng preup/predown script question [solved]

I put it in the /etc/conf.d/wireless file.  I create the device and then apply firewall rules.  This file is sourced at the beginning of  /etc/rc.d/network.  To make it not complain, I pass $1 from network and then use a case statement to destroy the device on stop.  I don't do anything for restart.

Offline

#4 2006-01-10 13:09:11

Menzonius
Member
From: Amsterdam, The Netherlands
Registered: 2006-01-07
Posts: 8

Re: madwifi-ng preup/predown script question [solved]

OK, I'll try putting something together in the wireless file. Thanks for your help!

Offline

#5 2006-01-11 19:54:03

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: madwifi-ng preup/predown script question [solved]

there is another thread about using the network profiles to do this in a better way

Offline

#6 2006-01-11 22:39:12

Menzonius
Member
From: Amsterdam, The Netherlands
Registered: 2006-01-07
Posts: 8

Re: madwifi-ng preup/predown script question [solved]

Would you mind posting a link? I searched the forum again, to see if I missed it the first time, but I can't find it.

Offline

#7 2006-01-12 07:51:55

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: madwifi-ng preup/predown script question [solved]

Yeah, here it is:

http://bbs.archlinux.org/viewtopic.php?t=17804

Check out phydeaux's posting.

Offline

#8 2006-01-12 13:25:27

Menzonius
Member
From: Amsterdam, The Netherlands
Registered: 2006-01-07
Posts: 8

Re: madwifi-ng preup/predown script question [solved]

Thanks for the link :-)
I'm not sure if I already read it, but I was already using a network profile to configure ath0. The main question was how to (properly) create and detroy the ath0 interface with the new madwifi-ng code before netcfg tries to configure a non-existing ath0 with wpa_supplicant, because that just results in ioctl errors and longer boot-up time.
I am not yet appending [solved] to the thread title, even though you did answer my question, as I would still welcome any tips/suggestions for better solutions (if possible).

Offline

#9 2006-01-12 17:48:17

Menzonius
Member
From: Amsterdam, The Netherlands
Registered: 2006-01-07
Posts: 8

Re: madwifi-ng preup/predown script question [solved]

Another interesting problem: I recently upgraded to the latest madwifi-ng code with svn update and also started using wpa_supplicant 0.5.0 (upgraded from 0.4.7)
The netcfg script stopped working and after a little tinkering I discovered that  the following section from start_profile() in the netcfg script was killing wpa_supplicant before it could connect:

                while ! wpa_cli status | grep "wpa_state=COMPLETED" >/dev/null 2>&1; do
                       if [ $i -gt 10 ]; then
                               wpa_cli terminate >/dev/null 2>&1
                               ifconfig $WIFI_INTERFACE down
                               stat_fail && return
                       fi
                       sleep 2
                       let i++
                done
        fi

I have now commented out the loop and running the command "netcfg netgear" no longer halts there and so far everything seems to be fine again. I am guessing more than a 20 second timeout is needed, so I'll try having the iterator increment to 30 or something and see if that solves it.

[EDIT]
Now using  [ $i -gt 30 ]; and it works. On second thought, since everything  now really just works and my main question was essentially answered, I am adding [solved] to the title.
Thanks again!
[/EDIT]

Offline

#10 2006-03-02 03:18:14

nogoma
Member
From: Cranston, RI
Registered: 2006-03-01
Posts: 217

Re: madwifi-ng preup/predown script question [solved]

You may already be way past this, and reviving this old thread might be silly, but I came across this thread when addressing this issue myself. The solution I came up with was to create a utility script in /etc/rc.d/ath_dev that does the wlanconfig. I added start/stop/restart commands, as one would expect, and simply added it to the DAEMONS array before 'network'. This creates the ath0 device before netcfg runs, and works for me. I did this because it also helps with suspending with suspend2; I destroy the interface with '/etc/rc.d/ath_dev stop' when suspending, and recreate it on resume with 'etc/rc.d/ath_dev start'. Anyway, hope somebody can use this tip when dealing with madwifi-ng.


-nogoma
---
Code Happy, Code Ruby!
http://www.last.fm/user/nogoma/

Offline

#11 2006-03-04 07:20:26

Clanman
Member
Registered: 2005-02-08
Posts: 35

Re: madwifi-ng preup/predown script question [solved]

Whould you mind posting your Utility scripts.
And how to ad start/stop/restart command

//Claman

Offline

#12 2006-03-04 16:30:41

nogoma
Member
From: Cranston, RI
Registered: 2006-03-01
Posts: 217

Re: madwifi-ng preup/predown script question [solved]

Sure; it's modelled after any of the other scripts in /etc/rc.d

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    stat_busy "Creating ath0 device"
    wlanconfig ath0 create wlandev wifi0 wlanmode sta
    if [ $? -gt 0 ]; then
      stat_fail
    else
      stat_done
    fi
    ;;
  stop)
    stat_busy "Destroying ath0 device"
    wlanconfig ath0 destroy
    if [ $? -gt 0 ]; then
      stat_fail
    else
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac

-nogoma
---
Code Happy, Code Ruby!
http://www.last.fm/user/nogoma/

Offline

#13 2006-03-04 18:05:02

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: madwifi-ng preup/predown script question [solved]

If you are using new madwifi-ng drivers, then you don't need to create or destroy the virtual device any more.  By default, a device is created when you  load the module.  There is a parameter that you can pass if you want to call it something else.

Offline

#14 2006-03-11 18:52:50

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 617
Website

Re: madwifi-ng preup/predown script question [solved]

colnago: i'm using madwifi-ng but it doesn't create ath0 by default for me. I still have to create it manually. i just built madwifi-ng today.

Offline

#15 2006-05-02 01:39:43

enderst
Member
Registered: 2004-06-28
Posts: 69

Re: madwifi-ng preup/predown script question [solved]

why not just add 'wlanconfig ath0 create wlandev wifi0 wlanmode sta' to /etc/rc.d/network

 if [ "$iwcfg" != "" ]; then
    /usr/sbin/iwconfig $iwcfg
    /bin/sleep 2
  fi

change it to

 if [ "$iwcfg" != "" ]; then
    /usr/bin/wlanconfig ath0 create wlandev wifi0 wlanmode sta
    /usr/sbin/iwconfig $iwcfg
    /bin/sleep 2
  fi

works good for me. also don't forget to add wlan-scan-sta after ath-pci in your modules array. then you can scan

wlanconfig ath0 list scan

Offline

Board footer

Powered by FluxBB