--- /home/archie/init/usr/bin/netcfg	2005-07-01 12:22:32.000000000 +1000
+++ /usr/bin/netcfg	2005-07-28 11:33:39.000000000 +1000
@@ -77,6 +77,10 @@
 	# Read the profile
 	. $PROFILE_DIR/$1
 
+	if [[ `ifconfig $INTERFACE|grep -c 'inet addr'` -ne 0 ]]; then     
+		return
+	fi
+
 	# Shut down any profiles tied to this interface
 	stop_profile $INTERFACE
 
@@ -90,13 +94,18 @@
 	# Configure wireless settings, if necessary
 	[ "$WIFI_INTERFACE" ] || WIFI_INTERFACE=$INTERFACE
 	if [ "$IWOPTS" ]; then
-		iwconfig $WIFI_INTERFACE $IWOPTS
+    iwconfig $WIFI_INTERFACE $IWOPTS
+		sleep $WIFI_WAIT
 		[ $? -ne 0 ] && stat_fail && return
 	fi
 
 	if [ "$IFOPTS" = "dhcp" -o "$IFOPTS" = "DHCP" ]; then
-		dhcpcd $DHCPCD_ARGS $INTERFACE
-		[ $? -ne 0 ] && stat_fail && return
+		if [[ `iwconfig $WIFI_INTERFACE 2> /dev/null |grep "Mode"|grep "00:00:00:00:00:00" -c` = 0 ]]; then
+			dhcpcd $DHCPCD_ARGS $INTERFACE
+			[ $? -ne 0 ] && stat_fail && return
+		else
+			stat_fail && return
+		fi
 	else
 		# bring up the interface
 		ifconfig $INTERFACE $IFOPTS up
--- /etc/network-profiles/template	2005-07-28 10:40:29.000000000 +1000
+++ /home/archie/init/etc/network-profiles/template	2005-07-28 10:40:43.000000000 +1000
@@ -22,6 +22,10 @@
 #KEY=
 #IWOPTS="mode managed essid $ESSID channel 6 key restricted $KEY"
 
+#Time to wait between running iwconfig, and attempting to get IP to give wireless card a chance to associate. 
+#5 is a reasonable default.
+#WIFI_WAIT=5
+
 #WIFI_INTERFACE=wlan0      # use this if you have a special wireless interface
                            # that is linked to the real $INTERFACE
 
