udev rules to turn networkmanager on and off?



Hi,

I have a tablet (compaq tc1000) with a flaky atmel wireless card that
cuts out about once a day.  When that happens, I can't get the carad to
start back up again without rebooting, and sometimes even that doesn't
work.  

Foretunately I have a prism2_usb wireless device that I can just plug in
to the ocmputer when that happens.  The device works fine but doesn't
play with network-manager proerly -- n-m sees it, but isn't able to
identify networks to which it might connect.

The solution isn't so difficult -- I just stop n0m with (in ubuntu):

sudo /etc/dbus-1/event.d/25NetworkManager stop
ifup wlan0

where wlan0 is configured thus in /etc/network/interfaces:

iface wlan0 inet dhcp
wireless-mode managed

since I have an unsecured network that's enough to get the thing to
connect.

However, this tablet is used mostly by my daughter who uses it largely
to surf the internet.  Itwould be great if she could use it as much as
possible without the usb device connected, and THEN have the device
brought up automatically, and network-manager stopped, when the device
is plugged in.  It would be great if network-manager could be restarted
when the device is pulled out, too.  

I have a dumb little script that does what I want: 

#!/bin/sh

case "$1" in
    start)

	/etc/dbus-1/event.d/25NetworkManager stop
	ifup wlan0
    ;;
    stop)
        ifdown wlan0
	/etc/dbus-1/event.d/25NetworkManager start
    ;;
  force-reload|restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: /usr/local/scripts/usb_wireless {start|stop|restart|
force-reload}"
    exit 1
    ;;
esac

exit 0

----------------



this works fine for me, but I'd like to have this script triggered
automagically by udev or something.  I was just wondering whether there
was an obvious way to do this through udev; or if maybe there's also a
better way to do it.  

anyway htanks,

matt



-- 
Matt Price
History Dept
University of Toronto
matt price utoronto ca

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]