From c8a4f09b7943a7fe9a875d9fc7af7decd29db6a2 Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Sat, 22 Oct 2005 21:23:47 +0000 Subject: added patch for wpa_supplicant support --- netcfg | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/netcfg b/netcfg index bfc2532..4ede296 100755 --- a/netcfg +++ b/netcfg @@ -40,7 +40,7 @@ stop_profile() INTERFACE=$1 [ -f $STATE_DIR/$INTERFACE ] || return - unset GATEWAY + unset GATEWAY IFOPTS . $STATE_DIR/$INTERFACE stat_busy "Shutting down interface: $INTERFACE" @@ -48,7 +48,13 @@ stop_profile() # bring down the default route (gateway) [ "$GATEWAY" ] && route del default gw $GATEWAY - # bring down the interface + # shutdown wpa_supplicant if it's running + [ "$WPAOPTS" ] && wpa_cli terminate >/dev/null 2>&1 + + # bring down dhcpcd if we're using it + [ "$IFOPTS" = "dhcp" -o "$IFOPTS" = "DHCP" ] && dhcpcd -k + + # bring down the interface itself ifconfig $INTERFACE down rm -f $STATE_DIR/$INTERFACE @@ -88,7 +94,7 @@ start_profile() stat_busy "Starting network profile: $1" # Re-read the profile (stop_profile might have overwritten our settings) - unset DESCRIPTION INTERFACE IFOPTS IWOPTS WIFI_INTERFACE WIFI_WAIT + unset DESCRIPTION INTERFACE IFOPTS IWOPTS WIFI_INTERFACE WIFI_WAIT WPAOPTS unset GATEWAY HOSTNAME DOMAIN DNS1 DNS2 . $PROFILE_DIR/$1 @@ -100,6 +106,24 @@ start_profile() [ "$WIFI_WAIT" ] && sleep $WIFI_WAIT fi + # Start wpa_supplicant, if necessary + if [ "$WPAOPTS" ]; then + ifconfig $WIFI_INTERFACE up + wpa_supplicant -wB -i $WIFI_INTERFACE -c /etc/wpa_supplicant.conf $WPAOPTS + # I donīt know how we could determine if wpa_supplicant is ready... + sleep 2 + let i=0 + while ! /usr/bin/wpa_cli status | grep "wpa_state=COMPLETED" >/dev/null 2>&1; do + if [ $i -gt 10 ]; then + wpa_cli terminate >/dev/null 2>&1 + ifconfig $WIFI_INTERFACE down + stat_fail && return + fi + sleep 2 + let i++ + done + fi + if [ "$IFOPTS" = "dhcp" -o "$IFOPTS" = "DHCP" ]; then # remove the .pid file if it exists rm -f /etc/dhcpc/dhcpcd-${INTERFACE}.{pid,cache} >/dev/null 2>&1 -- cgit v1.2.3