Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # lines 408 to 650 of /etc/rc.d/rc.network -- puppylinux
- # http://www.pearltrees.com/s243a/lines-408-650-rc-network/id16447168
- # see if it's wireless
- if [ -f "${WLAN_INTERFACES_DIR}/$HWADDRESS.conf" ] ; then
- OPEN_NETWORKS=""
- USE_WLAN_NG=""
- # we need the driver name, in case it's ath5k
- INTMODULE=$(readlink /sys/class/net/$INTERFACE/device/driver)
- INTMODULE=${INTMODULE##*/}
- . "${WLAN_INTERFACES_DIR}/$HWADDRESS.conf"
- # this should tell us if to use wlan_ng etc.
- if [ "$USE_WLAN_NG" = "yes" ] ; then ####### use wlanctl-ng ########
- if runPrismScan "$INTERFACE" ; then #>/dev/null
- # go over access points (POINTNUM set in function)
- for P in $(seq 0 $POINTNUM) ; do
- grep -Fq 'resultcode=success' /tmp/prism-scan$P || continue
- getPrismCellParameters $P
- # we should have CELL_ESSID, CELL_CHANNEL,
- # CELL_AP_MAC, CELL_MODE, CELL_ENCRYPTION
- # see if access point configured
- #### need to see about the ecryption part: gives "true" or "no_value"
- case $CELL_ENCRYPTION in
- true) CELL_ENCRYPTION=WEP ;;
- *) CELL_ENCRYPTION=Open ;;
- esac
- if [ -f "${PROFILES_DIR}/${CELL_AP_MAC}.${CELL_ENCRYPTION}.conf" ] ; then
- # unset static ip variables
- unset STATIC_IP IP_ADDRESS NETMASK DNS_SERVER1 DNS_SERVER2 GATEWAY
- # source it
- . "${PROFILES_DIR}/${CELL_AP_MAC}.${CELL_ENCRYPTION}.conf"
- assignProfileData
- # try connection
- if useWlanctl && 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.
- rm /tmp/wlan-up /tmp/prism-* >/dev/null 2>&1
- success_message
- #exit
- # move to next interface (to allow more than one)
- GOT_ONE="yes"
- continue 2
- else
- failure_message
- fi
- elif [ "$CELL_ENCRYPTION" = "Open" ] ; then # add to list of open networks
- OPEN_NETWORKS="$OPEN_NETWORKS $P"
- else # failure of useWlanctl
- failure_message
- fi #if useWlanctl &&
- fi #if [ -f "${PROFILES_DIR}/${CELL_AP_MAC}.${CELL_ENCRYPTION}.conf" ] ; then
- done # for P in
- # if we got here, we are not connected yet, look at open networks
- if [ -n "$OPEN_NETWORKS" ] ; then
- WLAN_SECURE="opensystem"
- PROFILE_KEY=""
- # unset static ip variables
- unset STATIC_IP IP_ADDRESS NETMASK DNS_SERVER1 DNS_SERVER2 GATEWAY
- for P in $OPEN_NETWORKS ; do
- grep -Fq 'resultcode=success' /tmp/prism-scan$P || continue
- getPrismCellParameters $P
- # set the PROFILE_ variables
- PROFILE_ESSID="$CELL_ESSID"
- if useWlanctl && 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.
- rm /tmp/wlan-up /tmp/prism-* >/dev/null 2>&1
- success_message
- #exit
- # move to next interface (to allow more than one)
- GOT_ONE="yes"
- continue 2
- else
- failure_message
- fi
- else # failure of useWlanctl
- failure_message
- fi
- done
- fi
- rm /tmp/wlan-up /tmp/prism-* >/dev/null 2>&1
- else
- echo "wireless scan with wlanctl-ng failed... skipping interface"
- # clean up (kills dhcpcd etc)
- cleanUpInterface "$INTERFACE"
- ifconfig "$INTERFACE" down
- # go to next interface
- continue
- fi # if runPrismScan
- 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
- else # if [ -n "$CELL_LIST" ]; then
- echo "wireless scan with iwlist failed (no networks found)... skipping interface"
- # clean up (kills dhcpcd etc)
- cleanUpInterface "$INTERFACE"
- ifconfig "$INTERFACE" down
- # clean scan files
- rm /tmp/iwscan*.tmp 2>/dev/null
- # go to next interface
- continue
- fi
- fi
- # if we got here, config file exists, but nothing worked
- echo "failed to configure wireless interface $INTERFACE... skipping"
- ifconfig "$INTERFACE" down
- continue
- fi # if [ -f "${WLAN_INTERFACES_DIR}/$HWADDRESS.conf" ] ; then
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement