[Lunar-commits] r23733 - moonbase/trunk/net/net-tools/init.d

Auke Kok sofar at lunar-linux.org
Mon Mar 19 04:30:47 CET 2007


Author: sofar
Date: 2007-03-19 04:30:46 +0100 (Mon, 19 Mar 2007)
New Revision: 23733

Modified:
   moonbase/trunk/net/net-tools/init.d/network
Log:
Fixed some kinks: static IP, iwconfig static config were both broken.


Modified: moonbase/trunk/net/net-tools/init.d/network
===================================================================
--- moonbase/trunk/net/net-tools/init.d/network	2007-03-19 01:24:15 UTC (rev 23732)
+++ moonbase/trunk/net/net-tools/init.d/network	2007-03-19 03:30:46 UTC (rev 23733)
@@ -44,41 +44,41 @@
 		modprobe $MODULE $MODULE_OPTIONS
 	fi
 
-	ifconfig $1 up $IFCONF_OPTS
-
 	if [ "$2" == "auto" ]; then
 		case $MANAGER in
 		    ifplugd)
+			ifconfig $1 up
 			ifplugd -I -i $1 -f &
 			sleep 1
 			return
 		    ;;
 		    wpa_supplicant)
-			wpa_supplicant -B -Dwext -i$1 -c/etc/wpa_supplicant.conf &
+			ifconfig $1 up
+			wpa_supplicant -B -u -Dwext -i$1 -c/etc/wpa_supplicant.conf -g/var/run/wpa_supplicant-global
 			ifplugd -I -i $1 -f &
 			sleep 1
 			return
 		    ;;
 		esac
-	else
-		if ( [ -n "$WIRELESS_MODE" ] || [ -n "$WIRELESS_KEY" ] || [ -n "$WIRELESS_RATE" ] || [ -n "$WIRELESS_ESSID" ] ); then
-			if [ ! -x /usr/sbin/iwconfig ]; then
-				echo "Wireless tools not installed"
-				return -1
-			fi
-			if [ -n "$WIRELESS_MODE" ]; then
-				/usr/sbin/iwconfig $1 mode $WIRELESS_MODE
-			fi
-			if [ -n "$WIRELESS_KEY" ]; then
-				/usr/sbin/iwconfig $1 key $WIRELESS_KEY
-			fi
-			if [ -n "$WIRELESS_RATE" ]; then
-				/usr/sbin/iwconfig $1 rate $WIRELESS_RATE
-			fi
-			if [ -n "$WIRELESS_ESSID" ]; then
-				/usr/sbin/iwconfig $1 essid $WIRELESS_ESSID
-			fi
+	fi
+
+	if ( [ -n "$WIRELESS_MODE" ] || [ -n "$WIRELESS_KEY" ] || [ -n "$WIRELESS_RATE" ] || [ -n "$WIRELESS_ESSID" ] ); then
+		if [ ! -x /usr/sbin/iwconfig ]; then
+			echo "Wireless tools not installed"
+			return -1
 		fi
+		if [ -n "$WIRELESS_MODE" ]; then
+			/usr/sbin/iwconfig $1 mode $WIRELESS_MODE
+		fi
+		if [ -n "$WIRELESS_KEY" ]; then
+			/usr/sbin/iwconfig $1 key $WIRELESS_KEY
+		fi
+		if [ -n "$WIRELESS_RATE" ]; then
+			/usr/sbin/iwconfig $1 rate $WIRELESS_RATE
+		fi
+		if [ -n "$WIRELESS_ESSID" ]; then
+			/usr/sbin/iwconfig $1 essid $WIRELESS_ESSID
+		fi
 	fi
 
 	if [ "$ADDRESS" != "dhcp" ]; then
@@ -92,14 +92,13 @@
 			echo -n "already started"
 			return -3
 		fi
-		IFCONFIG="$1 $ADDRESS"
 		if [ -n "$NETMASK" ]; then
-			IFCONFIG="$IFCONFIG netmask $NETMASK"
+			NETMASK="netmask $NETMASK"
 		fi
 		if [ -n "$BROADCAST" ]; then
-			IFCONFIG="$IFCONFIG broadcast $BROADCAST"
+			BROADCAST="broadcast $BROADCAST"
 		fi
-		/sbin/ifconfig $IFCONFIG >/dev/null 2>&1
+		/sbin/ifconfig $1 $ADDRESS $IFCONFIG $NETMASK $BROADCAST >/dev/null 2>&1
 		if [ `/sbin/ifconfig | grep $ADDRESS | wc -l` -ne 1 ]; then
 			echo -n "failed to set address"
 			return -1
@@ -192,13 +191,7 @@
 			fi
 		done
 
-		if [ `ifconfig | grep $1 | wc -l` -eq 1 ]; then
-			if [ ! -x /sbin/ifconfig ]; then
-				echo -n "ifconfig not installed"
-				return -1
-			fi
-			/sbin/ifconfig $1 down
-		else
+		if [ `ifconfig | grep $1 | wc -l` -ne 1 ]; then
 			case $AUTO in
 			    [!yY])
 				echo -n "not started"
@@ -222,7 +215,6 @@
 					sleep 1
 				    ;;
 				esac
-				return 0
 			fi
 		fi
 
@@ -238,6 +230,7 @@
 			PIDFILE=/var/run/udhcpc-$1.pid
 		    ;;
 		esac
+
 		if [ -e $PIDFILE ]; then
 			if [ -z "$KILLCMD" ]; then
 				kill `cat $PIDFILE`
@@ -256,13 +249,13 @@
 			    ;;
 			esac
 		fi
+	fi
 	
-		/sbin/ifconfig $1 down
-		if [ -n "$MODULE" ]; then
-			modprobe -r $MODULE
-		fi
+	/sbin/ifconfig $1 down
+
+	if [ -n "$MODULE" ]; then
+		modprobe -r $MODULE
 	fi
-	return 0
 }
 
 export -f device_start device_stop



More information about the Lunar-commits mailing list