[pkg-wpa-devel] r1009 - /wpasupplicant/trunk/debian/ifupdown/ifupdown.sh

kelmo-guest at users.alioth.debian.org kelmo-guest at users.alioth.debian.org
Sun Jan 6 16:21:17 UTC 2008


Author: kelmo-guest
Date: Sun Jan  6 16:21:17 2008
New Revision: 1009

URL: http://svn.debian.org/wsvn/pkg-wpa/?sc=1&rev=1009
Log:
slight refactor of ifupdown.sh to allow sendsigs stuff to work properly, and generally become a bit easier to read again

Modified:
    wpasupplicant/trunk/debian/ifupdown/ifupdown.sh

Modified: wpasupplicant/trunk/debian/ifupdown/ifupdown.sh
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/ifupdown/ifupdown.sh?rev=1009&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/ifupdown/ifupdown.sh (original)
+++ wpasupplicant/trunk/debian/ifupdown/ifupdown.sh Sun Jan  6 16:21:17 2008
@@ -57,9 +57,61 @@
 	exit 0
 fi
 
-if test_wpa_cli; then
-	# wpa-roam/wpa_action mode is active
-	if [ "$MODE" = stop ]; then
+do_start () {
+	if test_wpa_cli; then
+		# wpa-roam is active for this IFACE, do nothing
+		exit 0
+	elif ! set | grep --quiet "^IF_WPA"; then
+		# no wpa- option defined for IFACE, do nothing
+		exit 0
+	fi
+
+	# preliminary sanity checks for roaming daemon
+	if [ -n "$IF_WPA_ROAM" ]; then
+		if [ "$METHOD" != "manual" ]; then
+			wpa_msg stderr "wpa-roam can only be used with the \"manual\" inet METHOD"
+			exit 1
+		fi
+		if [ -n "$IF_WPA_MAPPING_SCRIPT" ]; then
+			if ! type "$IF_WPA_MAPPING_SCRIPT" >/dev/null; then
+				wpa_msg stderr "wpa-mapping-script \"$IF_WPA_MAPPING_SCRIPT\" is not valid"
+				exit 1
+			fi
+		fi
+		if [ -n "$IF_WPA_MAPPING_SCRIPT_PRIORITY" ] && [ -z "$IF_WPA_MAPPING_SCRIPT" ]; then
+			wpa_msg stderr "\"wpa-mapping-script-priority 1\" is invalid without a wpa-mapping-script"
+			exit 1
+		fi
+		IF_WPA_CONF="$IF_WPA_ROAM"
+		WPA_ACTION_SCRIPT="/sbin/wpa_action"
+	fi
+
+	# master function; determines if ifupdown.sh should do something or not
+	if [ -n "$IF_WPA_CONF" ] && [ "$IF_WPA_CONF" != "managed" ]; then
+		if [ ! -s "$IF_WPA_CONF" ]; then
+			wpa_msg stderr "cannot read contents of $IF_WPA_CONF"
+			exit 1
+		fi	
+		WPA_SUP_CONF_CTRL_DIR=$(sed --quiet -e 's/[[:space:]]*#.*//g' -e 's/[[:space:]]\+.*$//g' \
+			-e 's/^ctrl_interface=\(DIR=\)\?\(.*\)/\2/p' "$IF_WPA_CONF")
+		if [ -n "$WPA_SUP_CONF_CTRL_DIR" ]; then
+			WPA_CTRL_DIR="$WPA_SUP_CONF_CTRL_DIR"
+			WPA_SUP_CONF="-c $IF_WPA_CONF"
+		else
+			# specify the default ctrl_interface since none was defined in
+			# the given IF_WPA_CONF
+			WPA_SUP_CONF="-c $IF_WPA_CONF -C $WPA_CTRL_DIR"
+		fi
+	else
+		# specify the default ctrl_interface
+		WPA_SUP_CONF="-C $WPA_CTRL_DIR"
+	fi
+}
+
+do_stop () {
+	if test_wpa_cli; then
+		# wpa-roam/wpa_action mode is active, we always want to keep
+		# this process alive, unless shutting down or rebooting system
 		RUNLEVEL=$(/sbin/runlevel)
 		RUNLEVEL="${RUNLEVEL#*\ }"
 		case "$RUNLEVEL" in
@@ -74,56 +126,18 @@
 				exit 0
 				;;
 		esac
+	elif test_wpa_supplicant; then
+		# wpa_supplicant process exists for this IFACE, but wpa_cli
+		# process does not. Allow stop mode to kill this process.
+		:
 	else
-		# allow wpa_cli daemon (wpa-roam/wpa_action) to continue
 		exit 0
 	fi
-fi
-
-# preliminary sanity checks for roaming daemon
-if [ -n "$IF_WPA_ROAM" ]; then
-	if [ "$METHOD" != "manual" ]; then
-		wpa_msg stderr "wpa-roam can only be used with the \"manual\" inet METHOD"
-		exit 1
-	fi
-	if [ -n "$IF_WPA_MAPPING_SCRIPT" ]; then
-		if ! type "$IF_WPA_MAPPING_SCRIPT" >/dev/null; then
-			wpa_msg stderr "wpa-mapping-script \"$IF_WPA_MAPPING_SCRIPT\" is not valid"
-			exit 1
-		fi
-	fi
-	if [ -n "$IF_WPA_MAPPING_SCRIPT_PRIORITY" ] && [ -z "$IF_WPA_MAPPING_SCRIPT" ]; then
-		wpa_msg stderr "\"wpa-mapping-script-priority 1\" is invalid without a wpa-mapping-script"
-		exit 1
-	fi
-	IF_WPA_CONF="$IF_WPA_ROAM"
-	WPA_ACTION_SCRIPT="/sbin/wpa_action"
-fi
-
-# master function; determines if ifupdown.sh should do something or not
-if [ -n "$IF_WPA_CONF" ] && [ "$IF_WPA_CONF" != "managed" ]; then
-	if [ ! -s "$IF_WPA_CONF" ]; then
-		wpa_msg stderr "cannot read contents of $IF_WPA_CONF"
-		exit 1
-	fi	
-	WPA_SUP_CONF_CTRL_DIR=$(sed --quiet -e 's/[[:space:]]*#.*//g' -e 's/[[:space:]]\+.*$//g' \
-		-e 's/^ctrl_interface=\(DIR=\)\?\(.*\)/\2/p' "$IF_WPA_CONF")
-	if [ -n "$WPA_SUP_CONF_CTRL_DIR" ]; then
-		WPA_CTRL_DIR="$WPA_SUP_CONF_CTRL_DIR"
-		WPA_SUP_CONF="-c $IF_WPA_CONF"
-	else
-		# specify the default ctrl_interface since none was defined in
-		# the given IF_WPA_CONF
-		WPA_SUP_CONF="-c $IF_WPA_CONF -C $WPA_CTRL_DIR"
-	fi
-elif set | grep --quiet "^IF_WPA"; then
-	WPA_SUP_CONF="-C $WPA_CTRL_DIR"
-else
-	exit 0
-fi
+}
 
 case "$MODE" in 
 	start)
+		do_start
 		case "$PHASE" in
 			pre-up)
 				kill_wpa_supplicant
@@ -137,6 +151,7 @@
 		;;
 
 	stop)
+		do_stop
 		case "$PHASE" in
 			pre-down)
 				kill_wpa_cli




More information about the Pkg-wpa-devel mailing list