Advertisement
s243a

buildScanWindow() - /usr/sbin/wag-profiles.sh - puppylinux

Oct 16th, 2016
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.27 KB | None | 0 0
  1. # lines 1805 to 1867 of wag-profiles.sh
  2. # http://www.pearltrees.com/s243a/buildscanwindow-puppylinux/id16473165
  3. # $1 might be "retry", to let us know we've already tried once...
  4. buildScanWindow()
  5. {
  6.     SCANWINDOW_BUTTONS=""
  7.     (
  8.         #ifconfig "$INTERFACE" up
  9.         #cleanUpInterface "$INTERFACE" >> $DEBUG_OUTPUT 2>&1
  10.         #  Dougal: use files for the scan results, so we can try a few times
  11.         #+ and see which is biggest (sometimes not all networks show)
  12.         rm /tmp/net-setup_scan*.tmp >/dev/null 2>&1
  13.         iwlist "$INTERFACE" scan >/tmp/net-setup_scan1.tmp 2>>$DEBUG_OUTPUT
  14.         echo "X"
  15.        
  16.         #SCANALL=$(iwlist "$INTERFACE" scan 2>>$DEBUG_OUTPUT)
  17.         sleep 1
  18.         iwlist "$INTERFACE" scan >/tmp/net-setup_scan2.tmp 2>>$DEBUG_OUTPUT
  19.         echo "X"
  20.         ScanListFile=$(du -b /tmp/net-setup_scan*.tmp |sort -n | tail -n1 |cut -f2)
  21.         # Dougal: if nothing found, try again!
  22.         # (put the retry here, so progress is more even in bar...)
  23.         #case "$SCANALL" in *'No scan results'*)
  24.         #if grep -Fq 'No scan results' $ScanListFile ; then
  25.         #  sleep 1
  26.           #SCANALL=$(iwlist "$INTERFACE" scan 2>>$DEBUG_OUTPUT)
  27.         #  iwlist "$INTERFACE" scan >/tmp/net-setup_scan3.tmp 2>>$DEBUG_OUTPUT
  28.         #  ScanListFile="/tmp/net-setup_scan3.tmp"
  29.           #;;
  30.         #esac
  31.         #fi
  32.         #SCAN_LIST=$(echo "$SCANALL" | grep 'Cell\|ESSID\|Mode\|Frequency\|Quality\|Encryption\|Channel\|IE:\|Extra:')
  33.         #echo "$SCAN_LIST" > /tmp/net-setup_scanlist
  34.         echo "$ScanListFile" > /tmp/net-setup_scanlistfile
  35.         CELL_LIST=$(grep -Eo "Cell [0-9]+" $ScanListFile | cut -f2 -d " ")
  36.         #if [ -z "$SCAN_LIST" ]; then
  37.         if [ -z "$CELL_LIST" ]; then
  38.             # Dougal: a little awkward... want to give an option to reset pcmcia card
  39.             FI_DRIVER=$(readlink /sys/class/net/$INTERFACE/device/driver)
  40.             if [ "$1" = "retry" ] ; then # we're on the second try already
  41.                 createNoNetworksDialog
  42.                 #echo "Xdialog --left --title \"Puppy Network Wizard:\" --msgbox \"No networks detected\" 0 0 " > /tmp/net-setup_scanwindow
  43.             elif [ -n "$IsPCMCIA" ] ; then
  44.                 createRetryPCMCIAScanDialog
  45.             else
  46.                 createRetryScanDialog
  47.             fi
  48.         else
  49.             # give each Cell its own button
  50.             #CELL_LIST=$(echo "$SCAN_LIST" | grep -Eo "Cell [0-9]+" | cut -f2 -d " ")
  51.             for CELL in $CELL_LIST ; do
  52.                 #getCellParameters $CELL
  53.                 Get_Cell_Parameters $CELL
  54.                 [ -z "$CELL_ESSID" ] && CELL_ESSID="(hidden ESSID)"
  55.                 SCANWINDOW_BUTTONS="$SCANWINDOW_BUTTONS \"$CELL\" \"$CELL_ESSID (${CELL_MODE}; ${L_SCANWINDOW_Encryption}$CELL_ENC_TYPE)\" off \"${L_SCANWINDOW_Channel}${CELL_CHANNEL}; ${L_SCANWINDOW_Frequency}${CELL_FREQ}; ${L_SCANWINDOW_AP_MAC}${CELL_AP_MAC};
  56. ${L_SCANWINDOW_Strength}${CELL_QUALITY}\""
  57.             done
  58.             echo "Xdialog --left --item-help --stdout --title \"$L_TITLE_Puppy_Network_Wizard\" --radiolist \"$L_TEXT_Scanwindow\"  20 60 4  \
  59.     ${SCANWINDOW_BUTTONS} 2> /dev/null" > /tmp/net-setup_scanwindow
  60.         fi
  61.         echo "X"
  62.     )  | gtkdialog3 --program=NETWIZ_Scan_Progress_Dialog >/dev/null
  63.     clean_up_gtkdialog NETWIZ_Scan_Progress_Dialog
  64.    
  65.     #Xdialog --title "Puppy Ethernet Wizard" --progress "Scanning wireless networks" 0 0 3
  66.    
  67.     #SCAN_LIST="$(cat /tmp/net-setup_scanlist)"
  68.     read ScanListFile < /tmp/net-setup_scanlistfile
  69.     # run ifconfig down/up, as apparently it is needed for actually configuring to work properly...
  70.     ifconfig "$INTERFACE" down
  71.     ifconfig "$INTERFACE" up
  72. } #end of buildScanWindow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement