Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Line 1523 of /usr/sbin/wag-profiles.sh
- # http://www.pearltrees.com/s243a/usewpasupplicant-puppylinux/id16403191
- useWpaSupplicant ()
- {
- # add an option for running some parts only from the wizard
- if [ "$1" = "wizard" ] ; then
- # Dougal: moved all below code to a function
- getWpaPSK || return 1
- # Dougal: make wpa_supplicant config file match mac address
- WPA_CONF="${WPA_SUPP_DIR}/${PROFILE_AP_MAC}.${PROFILE_ENCRYPTION}.conf"
- if [ ! -e "$WPA_CONF" ] ; then
- # copy template
- #cp -a "${WPA_SUPP_DIR}/wpa_supplicant$PROFILE_WPA_TYPE.conf" "$WPA_CONF"
- # no, now this is done while saving, give message if failed
- giveErrorDialog "$L_MESSAGE_No_Wpaconfig_p1
- $WPA_CONF
- $L_MESSAGE_No_Wpaconfig_p2"
- return 1
- fi
- #TMPLOG="/tmp/wag-profiles_tmp.log"
- #rm "$TMPLOG" >> $DEBUG_OUTPUT 2>&1
- cleanUpInterface "$INTERFACE" >> $DEBUG_OUTPUT 2>&1
- else # running from rc.network
- WPA_CONF="$1"
- fi #if [ "$1" = "wizard" ] ; then
- # Dougal: give the text message even when using dialog (for debugging)
- echo "Configuring interface $INTERFACE to network $PROFILE_ESSID with wpa_supplicant..." >> $DEBUG_OUTPUT
- ###### run dialog
- if [ "$HAVEX" = "yes" ]; then
- # Create a temporary fifo to pass messages to progressbar (can't just pipe to it)
- PROGRESS_OUTPUT=/tmp/progress-fifo$$
- mkfifo $PROGRESS_OUTPUT
- # The progressbar dialog
- # It contains a loop that starts from 1 and increments by 3, so 1+33*3=100%
- # (33= first three messages + 30 iterations of loop in validate...)
- # If it recieves "end" it will skip to 100.
- export NETWIZ_Scan_Progress_Dialog="<window title=\"$L_TITLE_Network_Wizard\" icon-name=\"gtk-network\" window-position=\"1\">
- <vbox>
- <text><label>\"${L_TEXT_WPA_Progress_p1}${PROFILE_ENCRYPTION}${L_TEXT_WPA_Progress_p2}${PROFILE_ESSID}${L_TEXT_WPA_Progress_p3}\"</label></text>
- <frame $L_FRAME_Progress>
- <progressbar>
- <label>Connecting</label>
- <input>i=1 ; while read bla ; do i=\$((i+3)) ; case \$bla in end) i=100 ;; esac ; echo \$i ;echo \"\$bla\" ; done</input>
- <action type=\"exit\">Ready</action>
- </progressbar>
- </frame>
- <hbox>
- <button>
- <label>$L_BUTTON_Abort</label>
- <input file stock=\"gtk-stop\"></input>
- <action>EXIT:Abort</action>
- </button>
- </hbox>
- </vbox>
- </window>"
- gtkdialog3 --program=NETWIZ_Scan_Progress_Dialog <$PROGRESS_OUTPUT &
- local XPID=$!
- else
- PROGRESS_OUTPUT=$DEBUG_OUTPUT
- fi
- # Use a subshell to redirect echoes to fifo
- # (need one subshell, since redirecting something like a function will
- #+ freeze the progress bar when it ends)
- ####################################################################
- (
- echo "$L_ECHO_Starting"
- # Dougal: add increasing of rate for ath5k
- case $INTMODULE in ath5k*) iwconfig "$INTERFACE" rate 11M >> $DEBUG_OUTPUT 2>&1;; esac
- echo "$L_ECHO_Initializing_Wpa"
- wpa_supplicant -i "$INTERFACE" -D "$PROFILE_WPA_DRV" -c "$WPA_CONF" -B >> $DEBUG_OUTPUT 2>&1
- echo "Waiting for connection... " >> $DEBUG_OUTPUT 2>&1
- echo "trying to connect"
- # Dougal: use function based on wicd code
- # (note that it echoes the X's for the progress dialog)
- # have different return values:
- validateWpaAuthentication "$INTERFACE" "$XPID"
- case $? in
- 0) # success
- #WPA_STATUS="COMPLETED"
- echo "COMPLETED" >/tmp/wpa_status.txt
- echo "completed" >> $DEBUG_OUTPUT
- # end the progress bar
- echo end
- ;;
- 1) # timeout
- echo "timeout" >> $DEBUG_OUTPUT
- # end the progress bar
- echo end
- ;;
- 2) # user aborted
- echo aborted >>$DEBUG_OUTPUT
- ;;
- 3) # error
- echo "error while running:" >>$DEBUG_OUTPUT
- echo "wpa_cli -i $INTERFACE status | grep 'wpa_state=' " >>$DEBUG_OUTPUT
- # end the progress bar
- echo end
- ;;
- esac
- # Dougal: close the -n above
- echo >> $DEBUG_OUTPUT 2>&1
- #echo -n "$WPA_STATUS" > /tmp/wpa_status.txt
- #echo "---" >> ${TMPLOG} 2>&1
- ) >>$PROGRESS_OUTPUT
- ####################################################################
- #| Xdialog --title "Puppy Ethernet Wizard" --progress "Acquiring WPA connection\n\nThere may be a delay up to 60 seconds." 0 0 20
- if [ "$XPID" ] ;then
- kill $XPID >/dev/null 2>&1
- clean_up_gtkdialog NETWIZ_Scan_Progress_Dialog
- fi
- unset NETWIZ_Scan_Progress_Dialog
- ###########
- if [ "$HAVEX" = "yes" ]; then # it's a pipe
- rm $PROGRESS_OUTPUT
- fi
- #cat $TMPLOG >> $DEBUG_OUTPUT
- WPA_STATUS="$(cat /tmp/wpa_status.txt)"
- rm /tmp/wpa_status.txt
- if [ "$WPA_STATUS" = "COMPLETED" ] ; then
- return 0
- fi
- # if we're here, it failed
- if [ "$1" = "wizard" ] && [ "$HAVEX" = "yes" ] ; then
- export NETWIZ_No_WPA_Connection_Dialog="<window title=\"$L_TITLE_Puppy_Network_Wizard\" icon-name=\"gtk-dialog-error\" window-position=\"1\">
- <vbox>
- <pixmap icon_size=\"6\"><input file stock=\"gtk-dialog-error\"></input></pixmap>
- <text>
- <label>\"$L_MESSAGE_WPA_Failed\"</label>
- </text>
- <hbox>
- <button ok></button>
- <button>
- <label>$L_BUTTON_Details</label>
- <input file stock=\"gtk-info\"></input>
- <action>EXIT:Details</action>
- </button>
- </hbox>
- </vbox>
- </window>"
- I=$IFS; IFS=""
- for STATEMENT in $(gtkdialog3 --program NETWIZ_No_WPA_Connection_Dialog); do
- eval $STATEMENT
- done
- IFS=$I
- clean_up_gtkdialog NETWIZ_No_WPA_Connection_Dialog
- unset NETWIZ_No_WPA_Connection_Dialog
- if [ "$EXIT" = "Details" ] ; then
- EXIT="Refresh"
- while [ "$EXIT" = "Refresh" ] ; do
- # iwconfig info
- IW_INFO="$(iwconfig $INTERFACE |grep -o 'Access Point: .*\|Link Quality:[0-9]* ' )"
- export NETWIZ_WPA_Status_Dialog="<window title=\"$L_TITLE_Puppy_Network_Wizard\" icon-name=\"gtk-network\" window-position=\"1\">
- <vbox>
- <frame $L_FRAME_Connection_Info >
- <text>
- <label>\"$IW_INFO\"</label>
- </text>
- </frame>
- <frame ${L_FRAME_wpa_cli_Outeput}'wpa_cli -i $INTERFACE status' >
- <edit cursor-visible=\"false\" accepts-tab=\"false\">
- <variable>EDITOR</variable>
- <width>300</width><height>150</height>
- <default>\"$(wpa_cli -i $INTERFACE status 2>&1)\"</default>
- </edit>
- </frame>
- <hbox>
- <button>
- <label>$L_BUTTON_Refresh</label>
- <input file stock=\"gtk-refresh\"></input>
- <action>EXIT:Refresh</action>
- </button>
- <button ok></button>
- </hbox>
- </vbox>
- </window>"
- I=$IFS; IFS=""
- for STATEMENT in $(gtkdialog3 --program NETWIZ_WPA_Status_Dialog); do
- eval $STATEMENT
- done
- IFS=$I
- done # while [ "$EXIT" = "Refresh" ]
- clean_up_gtkdialog NETWIZ_WPA_Status_Dialog
- unset NETWIZ_WPA_Status_Dialog
- fi #if [ "$EXIT" = "Details" ] ; then
- fi #if [ "$1" = "wizard" ] && [ "$HAVEX" = "yes" ] ; then
- # if we're here, connection failed -- kill wpa_supplicant!
- wpa_cli -i "$INTERFACE" terminate >>$DEBUG_OUTPUT
- return 1
- } # end useWpaSupplicant
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement