# HG changeset patch # User Christophe Lincoln # Date 1330794858 -3600 # Node ID befbf0dc7341225f3fd4020877da167cfc861325 # Parent 7cb24a5569e45a9b9f7ddb366dcbf6811f4aa01b network.sh: Use wpa_supplicante for WEP connection and speed up using fgrep diff -r 7cb24a5569e4 -r befbf0dc7341 etc/init.d/network.sh --- a/etc/init.d/network.sh Sat Feb 18 21:55:47 2012 +0100 +++ b/etc/init.d/network.sh Sat Mar 03 18:14:18 2012 +0100 @@ -31,22 +31,24 @@ # For wifi. Users just have to enable it through yes and usually # essid any will work and the interface is autodetected. wifi() { - if [ "$WIFI" = "yes" ] || grep -q "wifi" /proc/cmdline; then + if [ "$WIFI" = "yes" ] || fgrep -q "wifi" /proc/cmdline; then ifconfig $INTERFACE down # Confirm if $WIFI_INTERFACE is the wifi interface if [ ! -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then echo "$WIFI_INTERFACE is not a wifi interface, changing it." - WIFI_INTERFACE=$(grep : /proc/net/dev | cut -d: -f1 | \ + WIFI_INTERFACE=$(fgrep : /proc/net/dev | cut -d: -f1 | \ while read dev; do iwconfig $dev 2>&1 | \ - grep -iq "essid" && { echo $dev ; break; }; \ + fgrep -iq "essid" && { echo $dev ; break; }; \ done) - [ -n "$WIFI_INTERFACE" ] && sed -i "s/^WIFI_INTERFACE=.*/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" /etc/network.conf + [ -n "$WIFI_INTERFACE" ] && sed -i \ + "s/^WIFI_INTERFACE=.*/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" \ + /etc/network.conf fi echo -n "Configuring $WIFI_INTERFACE..." - ifconfig $WIFI_INTERFACE up - if iwconfig $WIFI_INTERFACE | grep -q "Tx-Power"; then + ifconfig $WIFI_INTERFACE up 2>/dev/null + if iwconfig $WIFI_INTERFACE | fgrep -q "Tx-Power"; then iwconfig $WIFI_INTERFACE txpower on fi status @@ -62,27 +64,34 @@ # encrypted network [ -n "$WIFI_KEY" ] && case "$WIFI_KEY_TYPE" in wep|WEP) - IWCONFIG_ARGS="$IWCONFIG_ARGS key $WIFI_KEY" - iwconfig $WIFI_INTERFACE essid "$WIFI_ESSID" $IWCONFIG_ARGS -# wpa_supplicant can also deal with wep encryption but iwconfig is preferred -# Tip: Use unquoted strings for hexadecimal key in wep_key0 -# cat /etc/wpa_supplicant.conf > /tmp/wpa.conf -# cat >> /tmp/wpa.conf < /tmp/wpa.conf + cat >> /tmp/wpa.conf < /tmp/wpa.conf @@ -176,7 +185,7 @@ killall udhcpc killall wpa_supplicant 2>/dev/null - if iwconfig $WIFI_INTERFACE | grep -q "Tx-Power"; then + if iwconfig $WIFI_INTERFACE | fgrep -q "Tx-Power"; then echo "Shutting down wifi card" iwconfig $WIFI_INTERFACE txpower off fi