wpa_supplicant support for ifup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What do you think about the attached patch to ifup-wireless? Works for me :)
Index: ifup-wireless
===================================================================
RCS file: /usr/local/CVS/initscripts/sysconfig/network-scripts/ifup-wireless,v
retrieving revision 1.12
diff -u -r1.12 ifup-wireless
--- ifup-wireless	30 Sep 2005 18:51:15 -0000	1.12
+++ ifup-wireless	14 Mar 2006 10:36:36 -0000
@@ -30,70 +30,101 @@
 
 # Only meant to be called from ifup.
 
+if wpa_cli -i $DEVICE status >/dev/null 2>&1; then
+    eval $(wpa_cli -i${DEVICE} status 2>/dev/null) 
+    if [ "$wpa_state" != "COMPLETED" ]; then
+	/sbin/ip link set $DEVICE down
+	/sbin/ip link set $DEVICE up
+	wpa_cli scan >/dev/null 2>&1
+    fi
+    old_state=""
+    cnt=0
+    while true; do
+	eval $(wpa_cli -i${DEVICE} status 2>/dev/null) 
+	if [ "$wpa_state" = "COMPLETED" ]; then
+	    echo $"Connected to $ssid"
+	    break
+	fi
+	if [ "$old_state" != "$wpa_state" ]; then
+	    echo -n "$wpa_state "
+	    old_state=$wpa_state
+	fi
+
+	sleep 1
+	cnt=$[$cnt + 1]
+	if [ $cnt -gt 60 ]; then
+	    echo -n $"Timeout "
+	    exit 10
+	fi
+    done 
+else
+
 # Mode need to be first : some settings apply only in a specific mode !
-if [ -n "$MODE" ] ; then
-    iwconfig $DEVICE mode $MODE
-fi
+    if [ -n "$MODE" ] ; then
+	iwconfig $DEVICE mode $MODE
+    fi
 # This is a bit hackish, but should do the job right...
-if [ -n "$ESSID" -o -n "$MODE" ] ; then
-    NICKNAME=`/bin/hostname`
-    iwconfig $DEVICE nick "$NICKNAME" >/dev/null 2>&1
-fi
+    if [ -n "$ESSID" -o -n "$MODE" ] ; then
+	NICKNAME=`/bin/hostname`
+	iwconfig $DEVICE nick "$NICKNAME" >/dev/null 2>&1
+    fi
 # Regular stuff...
-if [ -n "$NWID" ] ; then
-    iwconfig $DEVICE nwid $NWID
-fi
-if [ -n "$FREQ" -a "$MODE" != "Managed" ] ; then
-    iwconfig $DEVICE freq $FREQ
-elif [ -n "$CHANNEL" -a "$MODE" != "Managed" ] ; then
-    iwconfig $DEVICE channel $CHANNEL
-fi
-if [ -n "$SENS" ] ; then
-    iwconfig $DEVICE sens $SENS
-fi
-if [ -n "$RATE" ] ; then
-    iwconfig $DEVICE rate "$RATE"
-fi
-if [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then
-    [ -n "$KEY1" ] && iwconfig $DEVICE key [1] $KEY1
-    [ -n "$KEY2" ] && iwconfig $DEVICE key [2] $KEY2
-    [ -n "$KEY3" ] && iwconfig $DEVICE key [3] $KEY3
-    [ -n "$KEY4" ] && iwconfig $DEVICE key [4] $KEY4
-    [ -n "$DEFAULTKEY" ] && iwconfig $DEVICE key [${DEFAULTKEY}]
-    [ -n "$KEY" ] && iwconfig $DEVICE key $KEY
-else
-    iwconfig $DEVICE key off
-fi
-if [ -n "$SECURITYMODE" ]; then
-    iwconfig $DEVICE enc $SECURITYMODE
-fi
-if [ -n "$RTS" ] ; then
-    iwconfig $DEVICE rts $RTS
-fi
-if [ -n "$FRAG" ] ; then
-    iwconfig $DEVICE frag $FRAG
-fi
+    if [ -n "$NWID" ] ; then
+	iwconfig $DEVICE nwid $NWID
+    fi
+    if [ -n "$FREQ" -a "$MODE" != "Managed" ] ; then
+	iwconfig $DEVICE freq $FREQ
+    elif [ -n "$CHANNEL" -a "$MODE" != "Managed" ] ; then
+	iwconfig $DEVICE channel $CHANNEL
+    fi
+    if [ -n "$SENS" ] ; then
+	iwconfig $DEVICE sens $SENS
+    fi
+    if [ -n "$RATE" ] ; then
+	iwconfig $DEVICE rate "$RATE"
+    fi
+    if [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then
+	[ -n "$KEY1" ] && iwconfig $DEVICE key [1] $KEY1
+	[ -n "$KEY2" ] && iwconfig $DEVICE key [2] $KEY2
+	[ -n "$KEY3" ] && iwconfig $DEVICE key [3] $KEY3
+	[ -n "$KEY4" ] && iwconfig $DEVICE key [4] $KEY4
+	[ -n "$DEFAULTKEY" ] && iwconfig $DEVICE key [${DEFAULTKEY}]
+	[ -n "$KEY" ] && iwconfig $DEVICE key $KEY
+    else
+	iwconfig $DEVICE key off
+    fi
+    if [ -n "$SECURITYMODE" ]; then
+	iwconfig $DEVICE enc $SECURITYMODE
+    fi
+    if [ -n "$RTS" ] ; then
+	iwconfig $DEVICE rts $RTS
+    fi
+    if [ -n "$FRAG" ] ; then
+	iwconfig $DEVICE frag $FRAG
+    fi
 
 # More specific parameters passed directly to IWCONFIG
-if [ -n "$IWCONFIG" ] ; then
-    iwconfig $DEVICE $IWCONFIG
-fi
-
-if [ -n "$SPYIPS" ] ; then
-    for IP in $SPYIPS; do
-	iwspy $DEVICE + $IP
-    done
-fi
-if [ -n "$IWPRIV" ] ; then
-    iwpriv $DEVICE $IWPRIV
-fi
+    if [ -n "$IWCONFIG" ] ; then
+	iwconfig $DEVICE $IWCONFIG
+    fi
+
+    if [ -n "$SPYIPS" ] ; then
+	for IP in $SPYIPS; do
+	    iwspy $DEVICE + $IP
+	done
+    fi
+    if [ -n "$IWPRIV" ] ; then
+	iwpriv $DEVICE $IWPRIV
+    fi
 
 # ESSID need to be last : most device re-perform the scanning/discovery
 # when this is set, and things like encryption keys are better be
 # defined if we want to discover the right set of APs/nodes.
-if [ -n "$ESSID" ] ; then
-    iwconfig $DEVICE essid "$ESSID"
-else
+    if [ -n "$ESSID" ] ; then
+	iwconfig $DEVICE essid "$ESSID"
+    else
     # use any essid
-    iwconfig $DEVICE essid any >/dev/null 2>&1
+	iwconfig $DEVICE essid any >/dev/null 2>&1
+    fi
+
 fi
-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux