don't try to set up wpa if hostapd is not installed
[openwrt/svn-archive/archive.git] / package / madwifi / files / lib / wifi / madwifi.sh
index 1cd727ade711e8c4b301653a3a980d6c4666f05e..69874b5c1873a70c2851c6a321d5aa9b7276feb3 100755 (executable)
@@ -99,12 +99,13 @@ enable_atheros() {
                                *bg) agmode=11g;;
                                *g) agmode=11g; pureg=1;;
                                *a) agmode=11a;;
-                               *) agmode=11g;;
+                               *) agmode=auto;;
                        esac
-                       iwconfig "$ifname" channel 0 
+                       iwconfig "$ifname" channel 0 >/dev/null 2>/dev/null 
+                       ifconfig "$ifname" up
                        iwpriv "$ifname" mode "$agmode"
                        iwpriv "$ifname" pureg "$pureg"
-                       iwconfig "$ifname" channel "$channel"
+                       iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null 
                }
        
                config_get_bool hidden "$vif" hidden
@@ -181,6 +182,7 @@ enable_atheros() {
                fi
 
                ifconfig "$ifname" up
+               iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null 
 
                local net_cfg bridge
                net_cfg="$(find_net_config "$vif")"
@@ -192,13 +194,15 @@ enable_atheros() {
                iwconfig "$ifname" essid "$ssid"
                case "$mode" in
                        ap)
-                               hostapd_setup_vif "$vif" madwifi || {
-                                       echo "enable_atheros($device): Failed to set up wpa for interface $ifname" >&2
-                                       # make sure this wifi interface won't accidentally stay open without encryption
-                                       ifconfig "$ifname" down
-                                       wlanconfig "$ifname" destroy
-                                       continue
-                               }
+                               if eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then
+                                       hostapd_setup_vif "$vif" madwifi || {
+                                               echo "enable_atheros($device): Failed to set up wpa for interface $ifname" >&2
+                                               # make sure this wifi interface won't accidentally stay open without encryption
+                                               ifconfig "$ifname" down
+                                               wlanconfig "$ifname" destroy
+                                               continue
+                                       }
+                               fi
                        ;;
                        wds|sta)
                                case "$enc" in 
@@ -224,7 +228,7 @@ EOF
                                                #add wpa_supplicant calls here
                                        ;;
                                esac
-                               wpa_supplicant ${bridge:+ -b $bridge} -Bw -D wext -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf
+                               [ -z "$proto" ] || wpa_supplicant ${bridge:+ -b $bridge} -Bw -D wext -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf
                        ;;
                esac
                first=0