updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / e3acpi / wlan.sh
blob83045542446695f272452fc3a10ee19a7922aa43
1 #! /bin/sh
3 source /etc/acpi/eee.conf
5 PWR=$(cat /proc/acpi/asus/wlan || cat /sys/devices/platform/eeepc/wlan)
7 load_modules() {
8 modprobe ath_pci
9 modprobe wlan_wep
10 modprobe wlan_tkip
11 modprobe wlan_ccmp
14 unload_modules() {
15 madwifi-unload
18 case $1 in
19 poweron)
20 if [ "$PWR" = "0" ]; then
21 modprobe pciehp pciehp_force=1
22 sleep 1
23 echo 1 > /proc/acpi/asus/wlan
24 echo 1 > /sys/devices/platform/eeepc/wlan
25 sleep 2
26 echo "Loading wlan modules..."
27 load_modules
28 sleep 1
29 echo "Creating wlan interface"
30 logger "create wlan interface"
31 wlanconfig ath0 create wlandev wifi0 wlanmode sta nosbeacon
32 sleep 1
33 ifconfig ath0 up
34 if ifconfig ath0 > /dev/null
35 then
36 echo "Running network up command!"
37 if [ -e /tmp/eeewlanfailcounter ]; then rm /tmp/eeewlanfailcounter;fi
38 (sleep 1; $NETWORK_UP_COMMAND) &
39 else
40 FAILC=$(</tmp/eeewlanfailcounter) || FAILC=0
41 echo "Current fail count is $FAILC"
42 if [ $FAILC -gt 2 ];
43 then
44 logger "Could not bring up WLAN."
45 echo "Could not bring up WLAN, sorry. See dmesg for more information!"
46 exit 1
48 echo $(expr $FAILC + 1) > /tmp/eeewlanfailcounter
49 /etc/acpi/wlan.sh poweroff
50 /etc/acpi/wlan.sh poweron
51 exit 1
57 poweroff)
58 if [ "$PWR" = "1" ]; then
59 logger "remove wlan interface"
60 echo "Removing wlan interface and unloading modules"
61 ifconfig ath0 down
62 sleep 1
63 wlanconfig ath0 destroy
64 unload_modules
65 echo "Turning wlan device power off"
66 echo 0 > /proc/acpi/asus/wlan
67 echo 0 > /sys/devices/platform/eeepc/wlan
68 sleep 1
69 rmmod pciehp
70 rmmod pci_hotplug
71 echo "Running network down command"
72 (sleep 1; $NETWORK_DOWN_COMMAND) &
75 esac