Advertisement
s243a

lines 501 to 645 of rc.network (puppylinux)

Oct 12th, 2016
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.58 KB | None | 0 0
  1. # lines 501 to 645 of /etc/rc.d/rc.network
  2. # http://www.pearltrees.com/s243a/lines-408-650-rc-network/id16447168
  3.     else #################### use the usual iwconfig ####################
  4.       # scan for available networks
  5.       run_iw_scan
  6.       #if [ -n "$SCAN_LIST" ]; then
  7.       if [ -n "$CELL_LIST" ]; then
  8.         #  Dougal: something odd. seems like (at least with some drivers), we
  9.         #+ need to "refresh" after scanning...
  10.         ifconfig "$INTERFACE" down
  11.         ifconfig "$INTERFACE" up
  12.         #CELL_LIST=$(echo "$SCAN_LIST" | grep -Eo "Cell [0-9]+" | cut -f2 -d " ")
  13.         # let the user create a priority list of which networks to use first
  14.         # (will be included in wireless config file, contains mac addresses)
  15.         if [ "$PRIORITY_LIST" ] ; then
  16.           PRIOR_CELLS=""
  17.           for ONE in $PRIORITY_LIST ; do
  18.             # see if it was found, then move cell number to start...
  19.             #ACELL=$(echo "$SCAN_LIST" | grep -F "Address: $ONE" | awk '{print $2}')
  20.             ACELL=$(grep -F "Address: $ONE" $ScanListFile | awk '{print $2}')
  21.             if [ "$ACELL" ] ; then
  22.               PRIOR_CELLS="$PRIOR_CELLS $ACELL"
  23.               # remove from cell list (BASHISM!)
  24.               #CELL_LIST=${CELL_LIST/$ACELL/}
  25.               CELL_LIST=$(echo "$CELL_LIST" | sed "s/$ACELL//")
  26.             fi
  27.           done
  28.           CELL_LIST="$PRIOR_CELLS $CELL_LIST"
  29.         fi
  30.         for CELL in $CELL_LIST ; do
  31.           Get_Cell_Parameters $CELL
  32.           # we should have at least some of:
  33.           # CELL_ESSID, CELL_FREQ, CELL_CHANNEL, CELL_QUALITY,
  34.           # CELL_AP_MAC, CELL_MODE, CELL_ENCRYPTION
  35.           # see if it's open or not
  36.           if [ "$CELL_ENCRYPTION" = "on" ] ; then
  37.             # get only encrypted profiles (might have problems with globbing?)
  38.             for PROF in $(ls ${PROFILES_DIR}/${CELL_AP_MAC}.W[EP][PA]*.conf 2>/dev/null) ; do
  39.               SUCCESS=""
  40.               # unset static ip variables
  41.               unset STATIC_IP IP_ADDRESS NETMASK DNS_SERVER1 DNS_SERVER2 GATEWAY
  42.               # source it
  43.               . "$PROF"
  44.               # assign to PROFILE_ names...
  45.               assignProfileData
  46.               case $PROFILE_ENCRYPTION in
  47.                 WPA|WPA2)
  48.                   WPA_CONF="${WPA_SUPP_DIR}/${PROFILE_AP_MAC}.${PROFILE_ENCRYPTION}.conf"
  49.                   useWpaSupplicant "$WPA_CONF" && SUCCESS="yes"
  50.                   ;;
  51.                 WEP)
  52.                   useIwconfig && SUCCESS="yes"
  53.                   ;;
  54.               esac
  55.               if [ "$SUCCESS" = "yes" ] && sleep 1 && testInterface ; then
  56.                 # sleep a bit, just in case (net-setup.sh has 5 seconds!)
  57.                 #sleep 1
  58.                 # try and get ip address
  59.                 if try_and_connect ; then
  60.                   # done! stop everything.
  61.                   success_message
  62.                   # clean scan files
  63.                   rm /tmp/iwscan*.tmp 2>/dev/null
  64.                   #exit
  65.                   # move to next interface (to allow more than one)
  66.                   GOT_ONE="yes"
  67.                   continue 3
  68.                 else
  69.                   failure_message
  70.                 fi
  71.               else # iwconfig/wpa_supp failed
  72.                 failure_message
  73.               fi
  74.             done # for PROF in
  75.           else # encryption off
  76.             # see if it was configured
  77.             if [ -f "${PROFILES_DIR}/${CELL_AP_MAC}.Open.conf" ] ; then
  78.               # unset static ip variables
  79.               unset STATIC_IP IP_ADDRESS NETMASK DNS_SERVER1 DNS_SERVER2 GATEWAY
  80.               # source it
  81.               . "${PROFILES_DIR}/${CELL_AP_MAC}.Open.conf"
  82.               # assign to PROFILE_ names...
  83.               assignProfileData
  84.               # try connection
  85.               if useIwconfig && sleep 1 && testInterface ; then
  86.                 # sleep a bit, just in case (net-setup.sh has 5 seconds!)
  87.                 #sleep 1
  88.                 # try and get ip address
  89.                 if try_and_connect ; then
  90.                   # done! stop everything.
  91.                   success_message
  92.                   # clean scan files
  93.                   rm /tmp/iwscan*.tmp 2>/dev/null
  94.                   #exit
  95.                   # move to next interface (to allow more than one)
  96.                   GOT_ONE="yes"
  97.                   continue 2
  98.                 else
  99.                   failure_message
  100.                 fi
  101.               else
  102.                 failure_message
  103.               fi
  104.             else # add to list of open networks
  105.               OPEN_NETWORKS="$OPEN_NETWORKS $CELL"
  106.             fi
  107.           fi # if [ "$CELL_ENCRYPTION" = "on" ] ; then  
  108.         done # for CELL in
  109.         # if we got here, we are not connected yet, look at open networks
  110.         if [ "$OPEN_NETWORKS" ] ; then
  111.           # unset static ip variables
  112.           unset STATIC_IP IP_ADDRESS NETMASK DNS_SERVER1 DNS_SERVER2 GATEWAY
  113.           for CELL in $OPEN_NETWORKS ; do
  114.             Get_Cell_Parameters $CELL
  115.             # need to convert to PROFILE_...
  116.             cellToProfile
  117.             if useIwconfig && sleep 1 && testInterface ; then
  118.               # sleep a bit, just in case (net-setup.sh has 5 seconds!)
  119.               #sleep 1
  120.               # try and get ip address
  121.               if try_and_connect ; then
  122.                 success_message
  123.                 # clean scan files
  124.                 rm /tmp/iwscan*.tmp 2>/dev/null
  125.                 #exit
  126.                 # move to next interface (to allow more than one)
  127.                 GOT_ONE="yes"
  128.                 continue 2
  129.               else
  130.                 failure_message
  131.               fi
  132.             else
  133.               failure_message
  134.             fi
  135.           done #for CELL in $OPEN_NETWORKS
  136. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement