Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # lines 501 to 645 of /etc/rc.d/rc.network
- # http://www.pearltrees.com/s243a/lines-408-650-rc-network/id16447168
- else #################### use the usual iwconfig ####################
- # scan for available networks
- run_iw_scan
- #if [ -n "$SCAN_LIST" ]; then
- if [ -n "$CELL_LIST" ]; then
- # Dougal: something odd. seems like (at least with some drivers), we
- #+ need to "refresh" after scanning...
- ifconfig "$INTERFACE" down
- ifconfig "$INTERFACE" up
- #CELL_LIST=$(echo "$SCAN_LIST" | grep -Eo "Cell [0-9]+" | cut -f2 -d " ")
- # let the user create a priority list of which networks to use first
- # (will be included in wireless config file, contains mac addresses)
- if [ "$PRIORITY_LIST" ] ; then
- PRIOR_CELLS=""
- for ONE in $PRIORITY_LIST ; do
- # see if it was found, then move cell number to start...
- #ACELL=$(echo "$SCAN_LIST" | grep -F "Address: $ONE" | awk '{print $2}')
- ACELL=$(grep -F "Address: $ONE" $ScanListFile | awk '{print $2}')
- if [ "$ACELL" ] ; then
- PRIOR_CELLS="$PRIOR_CELLS $ACELL"
- # remove from cell list (BASHISM!)
- #CELL_LIST=${CELL_LIST/$ACELL/}
- CELL_LIST=$(echo "$CELL_LIST" | sed "s/$ACELL//")
- fi
- done
- CELL_LIST="$PRIOR_CELLS $CELL_LIST"
- fi
- for CELL in $CELL_LIST ; do
- Get_Cell_Parameters $CELL
- # we should have at least some of:
- # CELL_ESSID, CELL_FREQ, CELL_CHANNEL, CELL_QUALITY,
- # CELL_AP_MAC, CELL_MODE, CELL_ENCRYPTION
- # see if it's open or not
- if [ "$CELL_ENCRYPTION" = "on" ] ; then
- # get only encrypted profiles (might have problems with globbing?)
- for PROF in $(ls ${PROFILES_DIR}/${CELL_AP_MAC}.W[EP][PA]*.conf 2>/dev/null) ; do
- SUCCESS=""
- # unset static ip variables
- unset STATIC_IP IP_ADDRESS NETMASK DNS_SERVER1 DNS_SERVER2 GATEWAY
- # source it
- . "$PROF"
- # assign to PROFILE_ names...
- assignProfileData
- case $PROFILE_ENCRYPTION in
- WPA|WPA2)
- WPA_CONF="${WPA_SUPP_DIR}/${PROFILE_AP_MAC}.${PROFILE_ENCRYPTION}.conf"
- useWpaSupplicant "$WPA_CONF" && SUCCESS="yes"
- ;;
- WEP)
- useIwconfig && SUCCESS="yes"
- ;;
- esac
- if [ "$SUCCESS" = "yes" ] && sleep 1 && testInterface ; then
- # sleep a bit, just in case (net-setup.sh has 5 seconds!)
- #sleep 1
- # try and get ip address
- if try_and_connect ; then
- # done! stop everything.
- success_message
- # clean scan files
- rm /tmp/iwscan*.tmp 2>/dev/null
- #exit
- # move to next interface (to allow more than one)
- GOT_ONE="yes"
- continue 3
- else
- failure_message
- fi
- else # iwconfig/wpa_supp failed
- failure_message
- fi
- done # for PROF in
- else # encryption off
- # see if it was configured
- if [ -f "${PROFILES_DIR}/${CELL_AP_MAC}.Open.conf" ] ; then
- # unset static ip variables
- unset STATIC_IP IP_ADDRESS NETMASK DNS_SERVER1 DNS_SERVER2 GATEWAY
- # source it
- . "${PROFILES_DIR}/${CELL_AP_MAC}.Open.conf"
- # assign to PROFILE_ names...
- assignProfileData
- # try connection
- if useIwconfig && sleep 1 && testInterface ; then
- # sleep a bit, just in case (net-setup.sh has 5 seconds!)
- #sleep 1
- # try and get ip address
- if try_and_connect ; then
- # done! stop everything.
- success_message
- # clean scan files
- rm /tmp/iwscan*.tmp 2>/dev/null
- #exit
- # move to next interface (to allow more than one)
- GOT_ONE="yes"
- continue 2
- else
- failure_message
- fi
- else
- failure_message
- fi
- else # add to list of open networks
- OPEN_NETWORKS="$OPEN_NETWORKS $CELL"
- fi
- fi # if [ "$CELL_ENCRYPTION" = "on" ] ; then
- done # for CELL in
- # if we got here, we are not connected yet, look at open networks
- if [ "$OPEN_NETWORKS" ] ; then
- # unset static ip variables
- unset STATIC_IP IP_ADDRESS NETMASK DNS_SERVER1 DNS_SERVER2 GATEWAY
- for CELL in $OPEN_NETWORKS ; do
- Get_Cell_Parameters $CELL
- # need to convert to PROFILE_...
- cellToProfile
- if useIwconfig && sleep 1 && testInterface ; then
- # sleep a bit, just in case (net-setup.sh has 5 seconds!)
- #sleep 1
- # try and get ip address
- if try_and_connect ; then
- success_message
- # clean scan files
- rm /tmp/iwscan*.tmp 2>/dev/null
- #exit
- # move to next interface (to allow more than one)
- GOT_ONE="yes"
- continue 2
- else
- failure_message
- fi
- else
- failure_message
- fi
- done #for CELL in $OPEN_NETWORKS
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement