diff -ur network-scripts-0.1.99/usr/bin/netcfg network-scripts-0.1.99-modified/usr/bin/netcfg --- network-scripts-0.1.99/usr/bin/netcfg 2006-09-15 15:31:30.000000000 -0700 +++ network-scripts-0.1.99-modified/usr/bin/netcfg 2006-10-11 21:38:21.000000000 -0700 @@ -20,6 +20,7 @@ echo "usage: netcfg [options] " echo " netcfg --stop " echo " netcfg --menu [--timeout ]" + echo " netcfg --auto" echo " netcfg --stopall" echo echo "options:" @@ -184,6 +185,46 @@ } +start_auto() +{ + success=0 + AVAIL_PROFILES=`/bin/ls $PROFILE_DIR | /bin/grep -v "template"` + PROFILE_ESSIDS="" + AVAIL_DEVICES="" + + #load each profile, bring up the device, iwlist, take down the device, search for the proper essid n the list, repeat + stat_busy "Scanning for a configured network, please wait.." + for prof in ${AVAIL_PROFILES}; do + #clean out old data + unset CONNECTION INTERFACE ESSID + AVAIL_ESSIDS="" + + #read our profile + . $PROFILE_DIR/$prof + + #move on if it's not wireless + [ "${CONNECTION}" -ne "wireless" ] && continue + + #list all ESSIDs on the specified device + if [ "`/sbin/ifconfig ${INTERFACE} | /bin/grep UP`" = "" ]; then + /sbin/ifconfig $INTERFACE up + /bin/sleep 1 + AVAIL_ESSIDS=`/usr/sbin/iwlist $INTERFACE scanning | /bin/grep \"ESSID:\"` + /sbin/ifconfig $INTERFACE down + else + AVAIL_ESSIDS=`/usr/sbin/iwlist $INTERFACE scanning | /bin/grep \"ESSID:\"` + fi + + #is our profile's essid available in the region? + if [ "`/bin/echo $AVAIL_ESSIDS | /bin/grep $prof`" != "" ] then + stat_done + success=1 + start_profile $prof + fi + done + [ $success -eq 0 ] && stat_fail +} + MODE="profile" CHECK=0 PROFILE= @@ -194,6 +235,7 @@ --version) MODE="ver" ;; --help) MODE="usage" ;; --menu) MODE="menu" ;; + --auto) MODE="auto" ;; --stopall) MODE="stopall" ;; --stop) MODE="stop" shift @@ -213,12 +255,13 @@ fi # Figure out what we're doing... -[ "$MODE" = "ver" ] && version -[ "$MODE" = "usage" ] && usage -[ "$MODE" = "profile" ] && start_profile $PROFILE +[ "$MODE" = "ver" ] && version +[ "$MODE" = "usage" ] && usage +[ "$MODE" = "profile" ] && start_profile $PROFILE [ "$MODE" = "stop" ] && stop_interface $IFACE -[ "$MODE" = "stopall" ] && stop_all +[ "$MODE" = "stopall" ] && stop_all [ "$MODE" = "menu" ] && start_menu +[ "$MODE" = "auto" ] && start_auto exit 0