diff options
Diffstat (limited to 'source/n/wireless-tools/scripts/rc.wireless')
-rw-r--r-- | source/n/wireless-tools/scripts/rc.wireless | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/source/n/wireless-tools/scripts/rc.wireless b/source/n/wireless-tools/scripts/rc.wireless index 5d5c4be5b..51623d506 100644 --- a/source/n/wireless-tools/scripts/rc.wireless +++ b/source/n/wireless-tools/scripts/rc.wireless @@ -53,6 +53,11 @@ # if a network device is wireless. In newer # kernels devices will not show up in # /proc/net/wireless until active. +# 16/aug/2012 * Pat Volkerding * Use several tests to determine if an interface +# is wireless, as the reliability of any given +# test may depend on the kernel options and the +# wireless driver used. +# Convert the MAC address to uppercase in sed. # ------------------------------------------------------------------------------ LOGGER=${LOGGER:-cat} @@ -83,16 +88,15 @@ IFCOMMAND="/sbin/ifconfig ${INTERFACE}" is_wireless_device () { - #[ -x $IWPATH/iwconfig ] || return 1 - #LC_ALL=C $IWPATH/iwconfig $1 2>&1 | \ - # grep -Eiq "no wireless extensions|no such device" || return 0 - #return 1 - if [ ! -d /sys/class/net/${1}/wireless ]; then - # no wireless interface - return 1 - else - # interface has wireless extensions - return 0 + # Return 0 for a wireless interface, or 1 for a non-wireless interface. + if LC_ALL=C $IWPATH/iwconfig $1 2>&1 | grep -q "IEEE 802.11" ; then + return 0 + elif [ -d /sys/class/net/${1}/wireless ]; then + return 0 + elif [ "$(cat /sys/class/net/${1}/uevent | grep DEVTYPE)" = "DEVTYPE=wlan" ]; then + return 0 + else # all tests failed, assume the device is not wireless (or add a better test :) + return 1 fi } @@ -106,7 +110,7 @@ is_wireless_device ${INTERFACE} || return 0 2> /dev/null || exit 0 # If we stop a wireless interface using wpa_supplicant, # we'll kill its wpa_supplicant daemon too and exit this script: if [ "$2" = "stop" ]; then - WPAPID=`echo \`ps axww|grep wpa_supplicant |grep i${INTERFACE}\` |cut -f1 -d' '` + WPAPID=$(echo $(ps axww | grep wpa_supplicant | grep i${INTERFACE}) | cut -f1 -d' ') [ ${WPAPID} ] && kill ${WPAPID} return 0 fi @@ -120,7 +124,7 @@ $IFCOMMAND up sleep 3 # Get the MAC address for the interface -HWADDR=`/sbin/ifconfig ${INTERFACE} | sed -ne 's/.*\(..:..:..:..:..:..\).*/\1/p' | tr [a-f] [A-F]` +HWADDR=$(/sbin/ifconfig ${INTERFACE} | sed -ne 's/.*\(..:..:..:..:..:..\).*/\U\1/p') # Empty all wireless parameters- some of them could still be set for a previous interface: # when rc.inet1 is sourced from rc.M all scripts are run in the same shell. @@ -193,7 +197,7 @@ if [ -n "$MODE" ] ; then fi # This is a bit hackish, but should do the job right... if [ ! -n "$NICKNAME" ] ; then - NICKNAME=`/bin/hostname` + NICKNAME=$(/bin/hostname) fi if [ -n "$ESSID" -o -n "$MODE" ] ; then echo "$0: $IWCOMMAND nick $NICKNAME" | $LOGGER @@ -290,7 +294,7 @@ if [ "$WPA" = "wpa_supplicant" ] || [ "$WPA" = "wpaxsupplicant" ] && [ -x ${SUPP [ ${WPA} = "wpaxsupplicant" ] && WPA_OPTIONS="${WPA_OPTIONS} -e" # Use external xsupplicant (disables the internal supplicant) # We leave a running wpa_supplicant process in peace: - WPAPID=`echo \`ps axww|grep wpa_supplicant |grep i${INTERFACE}\` |cut -f1 -d' '` + WPAPID=$(echo $(ps axww | grep wpa_supplicant | grep i${INTERFACE}) | cut -f1 -d' ') if [ ${WPAPID} ]; then echo "$0: wpa_supplicant found running already" | $LOGGER else @@ -307,9 +311,9 @@ if [ "$WPA" = "wpa_supplicant" ] || [ "$WPA" = "wpaxsupplicant" ] && [ -x ${SUPP while [ $wi -lt $WPAWAIT ]; do wi=$(($wi+1)); sleep 1 if (grep -q "^ctrl_interface=" ${WPACONF}); then - if (LC_ALL=C ${SUPPATH}/wpa_cli -i$INTERFACE status|grep -q "^wpa_state=COMPLETED"); then break; fi + if (LC_ALL=C ${SUPPATH}/wpa_cli -i$INTERFACE status | grep -q "^wpa_state=COMPLETED"); then break; fi else - if (LC_ALL=C ${IWCOMMAND}|grep -Eq "Encryption key:....-"); then break; fi + if (LC_ALL=C ${IWCOMMAND} | grep -Eq "Encryption key:....-"); then break; fi fi done if [ $wi -eq $WPAWAIT ]; then |