updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / acpi-eee / wlan.sh
blob490f846fce5aaf7347548959026cc584e24ddf0b
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 # Loop to the eternity!!! bawwaawawa, well once should be enough. >)
35 if ifconfig ath0 > /dev/null
36 then
37 echo "Running network up command!"
38 if [ -e /tmp/eeewlanfailcounter ]; then rm /tmp/eeewlanfailcounter;fi
39 (sleep 1; $NETWORK_UP_COMMAND) &
40 else
41 FAILC=$(</tmp/eeewlanfailcounter) || FAILC=0
42 echo "Current fail count is $FAILC"
43 if [ $FAILC -gt 2 ];
44 then
45 logger "Could not bring up WLAN."
46 echo "Could not bring up WLAN, sorry. See dmesg for more information!"
47 exit 1
49 echo $(expr $FAILC + 1) > /tmp/eeewlanfailcounter
50 /etc/acpi/wlan.sh poweroff
51 /etc/acpi/wlan.sh poweron
52 exit 1
58 poweroff)
59 if [ "$PWR" = "1" ]; then
60 logger "remove wlan interface"
61 echo "Removing wlan interface and unloading modules"
62 ifconfig ath0 down
63 sleep 1
64 wlanconfig ath0 destroy
65 unload_modules
66 echo "Turning wlan device power off"
67 echo 0 > /proc/acpi/asus/wlan
68 echo 0 > /sys/devices/platform/eeepc/wlan
69 sleep 1
70 rmmod pciehp
71 rmmod pci_hotplug
72 echo "Running network down command"
73 (sleep 1; $NETWORK_DOWN_COMMAND) &
76 esac