summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdinstall
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2017-01-08 18:14:22 +0000
committerdteske <dteske@FreeBSD.org>2017-01-08 18:14:22 +0000
commitc8f8c91c537fcba5ad6c39554edf56591b4b4b41 (patch)
tree4f6d328cabcc4d381f3d1146cbae86ac2e3ce737 /usr.sbin/bsdinstall
parent3417f4f7e562c3d84ef1ec81ea85be32dab40d28 (diff)
downloadFreeBSD-src-c8f8c91c537fcba5ad6c39554edf56591b4b4b41.zip
FreeBSD-src-c8f8c91c537fcba5ad6c39554edf56591b4b4b41.tar.gz
MFC improvements to bsdinstall's wlanconfig module
MFC [85] revisions 309719-309720, 309901-309902, 309904-309911, 309913-309920, 309922-309924, 309926, 309928, 309930, 309932, 309934, 309937-309942, 309944-309952, 309958-309998, and 310038 (described below) r309719: Remove unnecessary trailing backslashes r309720: Functions in their own section r309901: Comments r309902: Use $( ... ) instead of `...` r309904: Change "[ ! -z ... ]" => "[ ... ]" and "[ -z ... ]" => "[ ! ... ]" r309905: Remove unnecessary local initializers r309906: Consolidate locals r309907: Replace funny block with something easy to digest r309908: Collapse tiny if statements r309909: Change "[ ! ... ] && ..." to "[ ... ] || ..." r309910: Remove unnecessary quotes around number in test r309911: Group fallbacks together r309913: Allow $BSDINSTALL_TMPETC to contain whitespace or special chars r309914: Add missing `-e' parameter to sed invocations r309915: "echo | sed | sed | awk" is silly (changed to "echo | awk") r309916: Be internally consistent (": > ..." is used elsewhere in this file) r309917: awk(1) match() takes a regex, use /.../ to remind ourselves of this r309918: Remove unnecessary `-n' parameter to head/tail r309919: Whitespace r309920: Use provided API instead of hard-coded status integers r309922: Centralize backtitle string r309923: There is zero harm in always passing --default-item to dialog r309924: Always pass --default-item parameter to dialog r309926: Change the name of a variable from $def_item_... to $default_... r309928: Use ~ instead of match() r309930: Use ternary operator r309932: Remove an unnecessary "return $?" at end of function r309934: Consolidate redirects into here documents r309937: Whitespace (dialog options separated to minimize diffs) r309938: Use provided API (change "dialog" to "$DIALOG") r309939: Fix incorrect use of provided API r309940: Reorder dialog parameters based on commonality for readability r309941: Use provided API to centralize dialog title strings r309942: Allow the script path to contain whitespace and special characters r309944: Fix invalid parameter expansion (change $@ to "$@") r309945: 1 is the default descriptor for redirects without an fd prefix r309946: Use more succinct awk syntax r309947: Remove unnecessary semi-colons r309948: Remove incomplete and unnecessary creation of fd3 r309949: Utilize provided i18n strings r309950: Whitespace r309951: Remove an unnecessary call to f_dialog_title_restore() r309952: Move the secondary condition into the action clause r309958: Quote WLAN_IFACE (pedantic) r309959: Use oft-neglected syntax "startcondition, stopcondition { ... }" r309960: Add missing backslash r309961: Stop repeating strings (centralize prompt string) r309962: More efficiently make use of the exit status r309963: Avoid non-standard options r309964: Sort the domains r309965: Whitespace alignment r309966: Sanitize dialog output for portability/compatibility requirements r309967: Use more generic f_yesno() from provided API r309968: Properly quote variable r309969: Send stderr to the same place as stdout r309970: Remove completely unnecesary parentheses r309971: Start deconstructing a conveluted hunk of code r309972: If the first ping succeeded, why on Earth should we ping it again? r309973: Why use $? when you can use the command itself r309974: These two error messages have always been backwards since inception r309975: Continued resolution of conveluted statement r309976: You don't need parentheses for awk's printf r309977: Whitespace and alignment r309978: Neither printf nor print need parens in awk r309979: This statement has too many backslashes r309980: Just use print r309981: Add missing quotes r309982: Remove unnecessary quotes r309983: Use the provided API for calculating the appropriate size of menus r309984: Whitespace alignment r309985: Comment r309986: There's an API function for displaying errors r309987: There's an API function for displaying yes/no dialogs r309988: There's an API function for displaying pauses r309989: There's an API function for catching errors r309990: Calculate proper size of menu list dialog r309991: Simplify bringup of interface after changes and catch errors r309992: Restore previous comment r309993: Why test $? when you can test the command r309994: Wordsmithing r309995: Simplify loop by moving predicate to clause r309996: Simplify single-line if statements r309997: The flags of a WLAN need to be quoted r309998: It's completely pointless to replace newlines with space r310038: Revert r309918 -- modern POSIX has deprecated -<#>/+<#> syntax PR: bin/214933
Diffstat (limited to 'usr.sbin/bsdinstall')
-rwxr-xr-xusr.sbin/bsdinstall/scripts/wlanconfig515
1 files changed, 269 insertions, 246 deletions
diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig
index 3200418..130f1e0 100755
--- a/usr.sbin/bsdinstall/scripts/wlanconfig
+++ b/usr.sbin/bsdinstall/scripts/wlanconfig
@@ -1,7 +1,7 @@
#!/bin/sh
#-
# Copyright (c) 2011 Nathan Whitehorn
-# Copyright (c) 2013-2015 Devin Teske
+# Copyright (c) 2013-2016 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,80 +32,48 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
f_include $BSDCFG_SHARE/dialog.subr
+f_dialog_backtitle "FreeBSD Installer"
-############################################################ MAIN
-
-echo -n > $BSDINSTALL_TMPETC/wpa_supplicant.conf
-chmod 0600 $BSDINSTALL_TMPETC/wpa_supplicant.conf
-
-echo "ctrl_interface=/var/run/wpa_supplicant" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo "eapol_version=2" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo "ap_scan=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo "fast_reauth=1" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-
-# Try to reach wpa_supplicant. If it isn't running and we can modify the
-# existing system, start it. Otherwise, fail.
-(wpa_cli ping >/dev/null 2>/dev/null || ([ ! -z $BSDINSTALL_CONFIGCURRENT ] && \
- wpa_supplicant -B -i $1 -c $BSDINSTALL_TMPETC/wpa_supplicant.conf)) || \
- (dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \
- "Could not start wpa_supplicant!" 0 0; exit 1) || exit 1
-
-# See if we succeeded
-wpa_cli ping >/dev/null 2>/dev/null
-if [ $? -ne 0 -a -z $BSDINSTALL_CONFIGCURRENT ]; then
- dialog --backtitle "FreeBSD Installer" --title "Error" --msgbox \
- "Wireless cannot be configured without making changes to the local system!" \ 0 0
- exit 1
-fi
+############################################################ FUNCTIONS
country_set()
{
- local error_str=
- local iface_up=
- local ifconfig_args=
+ local error_str iface_up ifconfig_args=
+ #
# Setup what was selected
- # NB: do not change order of arguments (or regdomain will be ignored)
- if [ ! -z "$2" ]; then
- ifconfig_args="${ifconfig_args}country $2"
- fi
- if [ ! -z "$1" ]; then
- if [ ! -z "$2" ]; then
- ifconfig_args="${ifconfig_args} "
- fi
- ifconfig_args="${ifconfig_args}regdomain $1"
- fi
- if [ -z "$ifconfig_args" ]; then
- # Nothing to do (everything was skipped)
- return $SUCCESS
- fi
+ # NB: Do not change order of arguments (or regdomain will be ignored)
+ #
+ [ "$2" ] && ifconfig_args="$ifconfig_args country $2"
+ [ "$1" ] && ifconfig_args="$ifconfig_args regdomain $1"
+ [ "$ifconfig_args" ] || return $SUCCESS # Nothing to do
+ ifconfig_args="${ifconfig_args# }"
# Regdomain/country cannot be applied while interface is running
- iface_up=`ifconfig -lu | grep -w $WLAN_IFACE`
- if [ ! -z "$iface_up" ]; then
- ifconfig $WLAN_IFACE down
- fi
- error_str=`ifconfig $WLAN_IFACE $ifconfig_args 2>&1 | \
- sed 's/ifconfig: //'`
- if [ ! -z "$iface_up" ]; then
- # Restart wpa_supplicant(8) (should not fail).
- wpa_supplicant -B -i $WLAN_IFACE -c \
- $BSDINSTALL_TMPETC/wpa_supplicant.conf
- fi
- if [ ! -z "$error_str" ]; then
- dialog --backtitle "FreeBSD Installer" --title "Error" \
- --yes-label Change --no-label Ignore --yesno \
- "Error while applying chosen settings ($error_str)" 0 0
- if [ $? -eq $DIALOG_OK ]; then
- return $FAILURE # Restart
- else
- return $SUCCESS # Skip
- fi
+ iface_up=$( ifconfig -lu | grep -w "$WLAN_IFACE" )
+ [ "$iface_up" ] && ifconfig "$WLAN_IFACE" down
+ f_eval_catch -dk error_str wlanconfig ifconfig "ifconfig %s %s" \
+ "$WLAN_IFACE" "$ifconfig_args"
+ error_str="${error_str#ifconfig: }"
+ # Restart wpa_supplicant(8) (should not fail).
+ [ "$iface_up" ] && f_eval_catch -d wlanconfig wpa_supplicant \
+ 'wpa_supplicant -B -i "%s" -c "%s/wpa_supplicant.conf"' \
+ "$WLAN_IFACE" "$BSDINSTALL_TMPETC"
+ if [ "$error_str" ]; then
+ $DIALOG \
+ --title "$msg_error" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --yes-label Change \
+ --no-label Ignore \
+ --yesno \
+ "Error while applying chosen settings ($error_str)" \
+ 0 0 || return $SUCCESS # Skip
+ return $FAILURE # Restart
else
- : > $BSDINSTALL_TMPETC/rc.conf.net.wlan
- echo create_args_$WLAN_IFACE=\"$ifconfig_args\" >> \
- $BSDINSTALL_TMPETC/rc.conf.net.wlan
+ awk 'sub(/^\t\t/,"")||1' \
+ > "$BSDINSTALL_TMPETC/rc.conf.net.wlan" <<-EOF
+ create_args_$WLAN_IFACE="$ifconfig_args"
+ EOF
fi
return $SUCCESS
@@ -113,228 +81,283 @@ country_set()
dialog_country_select()
{
- local input=
- local def_item_regdomain=
- local def_item_country=
- local regdomains=
- local countries=
- local regdomain=
- local country=
+ local input regdomains countries regdomain country prompt
+ local no_default="<not selected>"
+ local default_regdomain="${1:-$no_default}"
+ local default_country="${2:-$no_default}"
+ #
# Parse available countries/regdomains
- input=`ifconfig $WLAN_IFACE list countries | sed 's/DEBUG//gi'`
- regdomains=`echo $input | sed 's/.*domains://' | tr ' ' '\n' | \
- sort | tr '\n' ' '`
- countries=`echo $input | sed 's/Country codes://' | \
- sed 's/Regulatory.*//' | awk '{
- for (i = 1; i <= NF; i++) {
- printf "%s", $i
- if (match($i, "[[:lower:]]"))
- if (match($(i+1), "[[:lower:]]"))
- printf "\\\\\\ "
- else
- printf "\n"
- else
- printf " "
+ #
+ input=$( ifconfig "$WLAN_IFACE" list countries | sed -e 's/DEBUG//gi' )
+ regdomains=$( echo "$input" | awk '
+ sub(/.*domains:/, ""), /[^[:alnum:][[:space:]]/ {
+ n = split($0, domains)
+ for (i = 1; i <= n; i++)
+ printf "'\''%s'\'' '\'\''", domains[i]
}
- }' | sort -k 2 | tr '\n' ' '`
-
- # Change default cursor position (if required).
- if [ "$1" != "<not selected>" ]; then
- def_item_regdomain="--default-item $1"
- fi
- if [ "$2" != "<not selected>" ]; then
- def_item_country="--default-item $2"
- fi
+ ' | sort )
+ countries=$( echo "$input" | awk '
+ sub(/Country codes:/, ""), sub(/Regulatory.*/, "") {
+ while (match($0, /[[:upper:]][[:upper:][:digit:]] /)) {
+ country = substr($0, RSTART)
+ sub(/ [[:upper:]][[:upper:][:digit:]].*/, "", country)
+ code = substr(country, 1, 2)
+ desc = substr(country, 4)
+ sub(/[[:space:]]*$/, "", desc)
+ printf "'\''%s'\'' '\''%s'\''\n", code, desc
+ $0 = substr($0, RSTART + RLENGTH)
+ }
+ }
+ ' | sort )
- f_dialog_menu_size height width rows \"Regdomain selection\" \
- \"FreeBSD Installer\" \"Select your regdomain.\" \
- \"\" $regdomains
- regdomain=`sh -c "dialog \
- --backtitle \"FreeBSD Installer\" \
- --title \"Regdomain selection\" \
- --cancel-label \"Skip\" \
- $def_item_regdomain \
- --no-items \
- --stdout \
- --menu \"Select your regdomain.\" \
- $height $width $rows $regdomains"`
+ f_dialog_title "Regdomain selection"
+ prompt="Select your regdomain."
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \"\" $regdomains
+ regdomain=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --cancel-label \"\$msg_skip\" \
+ --default-item \"\$default_regdomain\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $regdomains \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ f_dialog_data_sanitize regdomain
- f_dialog_menu_size height width rows \"Country selection\" \
- \"FreeBSD Installer\" \"Select your country.\" \
- \"\" $countries
- country=`sh -c "dialog \
- --backtitle \"FreeBSD Installer\" \
- --title \"Country selection\" \
- --cancel-label \"Skip\" \
- $def_item_country \
- --stdout \
- --menu \"Select your country.\" \
- $height $width $rows $countries"`
+ f_dialog_title "Country selection"
+ prompt="Select your country."
+ eval f_dialog_menu_size height width rows \
+ \"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \"\" $countries
+ country=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --cancel-label \"\$msg_skip\" \
+ --default-item \"\$default_country\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $countries \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ f_dialog_data_sanitize country
country_set "$regdomain" "$country"
-
- return $?
}
+############################################################ MAIN
+
+: > "$BSDINSTALL_TMPETC/wpa_supplicant.conf"
+chmod 0600 "$BSDINSTALL_TMPETC/wpa_supplicant.conf"
+
+cat >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" << EOF
+ctrl_interface=/var/run/wpa_supplicant
+eapol_version=2
+ap_scan=1
+fast_reauth=1
+
+EOF
+
+#
+# Try to reach wpa_supplicant. If it isn't running and we can modify the
+# existing system, start it. Otherwise, fail.
+#
+if ! f_eval_catch -d wlanconfig wpa_cli "wpa_cli ping"; then
+ if [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then
+ f_show_err "Wireless cannot be configured without %s" \
+ "making changes to the local system!"
+ exit 1
+ fi
+ f_eval_catch wlanconfig wpa_supplicant \
+ 'wpa_supplicant -B -i "%s" -c "%s/wpa_supplicant.conf"' \
+ "$1" "$BSDINSTALL_TMPETC" || exit 1
+
+ # See if we succeeded
+ f_eval_catch wlanconfig wpa_cli "wpa_cli ping" || exit 1
+fi
+
+#
# There is no way to check country/regdomain without (possible)
# interface state modification
-if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
+#
+if [ "$BSDINSTALL_CONFIGCURRENT" ]; then
# Get current country/regdomain for selected interface
- WLAN_IFACE=`wpa_cli ifname | tail -n 1`
- INPUT=`ifconfig $WLAN_IFACE list regdomain | head -n 1`
- DEF_REGDOMAIN=`echo $INPUT | cut -w -f 2`
- if [ "$DEF_REGDOMAIN" = "0" ]; then
- DEF_REGDOMAIN="<not selected>"
- fi
- DEF_COUNTRY=`echo $INPUT | cut -w -f 4`
- if [ "$DEF_COUNTRY" = "0" ]; then
- DEF_COUNTRY="<not selected>"
- fi
- dialog --backtitle "FreeBSD Installer" --title "Regdomain/country" \
- --yesno "Change regdomain/country (now \
- $DEF_REGDOMAIN/$DEF_COUNTRY)?" 0 0
- if [ $? -eq 0 ]; then
- while :
- do
- dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY"
- if [ $? -eq $SUCCESS ]; then
- break
- fi
- done
+ WLAN_IFACE=$( wpa_cli ifname | tail -n 1 )
+ INPUT=$( ifconfig "$WLAN_IFACE" list regdomain | head -n 1 )
+ DEF_REGDOMAIN=$( echo "$INPUT" | cut -w -f 2 )
+ DEF_COUNTRY=$( echo "$INPUT" | cut -w -f 4 )
+ [ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="<not selected>"
+ [ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="<not selected>"
+ f_dialog_title "Regdomain/country"
+ if f_yesno "Change regdomain/country ($DEF_REGDOMAIN/$DEF_COUNTRY)?"
+ then
+ while ! dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY"
+ do :; done
fi
fi
-while :
-do
+while :; do
SCANSSID=0
- output=$( wpa_cli scan 2>&1 )
- f_dprintf "%s" "$output"
- dialog --backtitle "FreeBSD Installer" --title "Scanning" \
- --ok-label "Skip" \
- --pause "Waiting 5 seconds to scan for wireless networks..." \
- 9 40 5 || exit 1
+ f_eval_catch -d wlanconfig wpa_cli "wpa_cli scan"
+ f_dialog_title "Scanning"
+ f_dialog_pause "Waiting 5 seconds to scan for wireless networks..." 5 ||
+ exit 1
- SCAN_RESULTS=`wpa_cli scan_results`
- NETWORKS=`echo "$SCAN_RESULTS" | awk -F '\t' \
- '/..:..:..:..:..:../ {if (length($5) > 0) \
- printf("\"%s\"\t%s\n", $5, $4);}' | sort | uniq`
+ f_eval_catch -dk SCAN_RESULTS wlanconfig wpa_cli "wpa_cli scan_results"
+ NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' '
+ /..:..:..:..:..:../ && $5 { printf "\"%s\"\t\"%s\"\n", $5, $4 }
+ ' | sort | uniq )
- if [ -z "$NETWORKS" ]; then
- dialog --backtitle "FreeBSD Installer" --title "Error" \
- --yesno "No wireless networks were found. Rescan?" 0 0 && \
- continue
+ if [ ! "$NETWORKS" ]; then
+ f_dialog_title "$msg_error"
+ f_yesno "No wireless networks were found. Rescan?" && continue
exit 1
fi
- exec 3>&1
- NETWORK=`sh -c "dialog --extra-button --extra-label \"Rescan\" \
- --backtitle \"FreeBSD Installer\" --title \"Network Selection\" \
- --menu \"Select a wireless network to connect to.\" 0 0 0 \
- $(echo $NETWORKS | tr '\n' ' ')" 2>&1 1>&3`
- case $? in
- 0) # OK
- break
- ;;
- 1) # Cancel
- # here we ask if the user wants to select the network manually
+ f_dialog_title "Network Selection"
+ prompt="Select a wireless network to connect to."
+ f_dialog_menu_size height width rows "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" "$prompt" "" $menu_list
+ NETWORK=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --extra-button \
+ --extra-label \"Rescan\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $NETWORKS \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ f_dialog_data_sanitize NETWORK
+ case $retval in
+ $DIALOG_OK) break ;;
+ $DIALOG_CANCEL)
+ # Ask if the user wants to select network manually
f_dialog_title "Network Selection"
- f_dialog_yesno "Do you want to select the network manually?" || exit 1
- # and take the manual input
- # first, take the ssid
+ f_yesno "Do you want to select the network manually?" || exit 1
f_dialog_input NETWORK "Enter SSID" || exit 1
- # then, the encryption
- ENCRYPTION=$( dialog --backtitle "$DIALOG_BACKTITLE" --title \
- "$DIALOG_TITLE" --menu "Select encryption type" 0 0 0 \
- "1 WPA/WPA2 PSK" "" "2 WPA/WPA2 EAP" "" "3 WEP" "" "0 None" "" 2>&1 1>&3 ) || exit 1
+ prompt="Select encryption type"
+ menu_list="
+ '1 WPA/WPA2 PSK' ''
+ '2 WPA/WPA2 EAP' ''
+ '3 WEP' ''
+ '0 None' ''
+ " # END-QUOTE
+ eval f_dialog_menu_size height width rows \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \"\$prompt\" \"\" $menu_list
+ ENCRYPTION=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ ) || exit 1
SCANSSID=1
- f_dialog_title_restore
break
;;
- 3) # Rescan
+ $DIALOG_EXTRA) # Rescan
;;
esac
- exec 3>&-
done
-[ -z "$ENCRYPTION" ] && ENCRYPTION=`echo "$NETWORKS" | awk -F '\t' \
- "/^\"$NETWORK\"\t/ {printf(\"%s\n\", \\\$2 );}"`
+[ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" |
+ awk -F '\t' "/^\"$NETWORK\"\t/ { print \$2 }" )
-if echo $ENCRYPTION | grep -q 'PSK'; then
- exec 3>&1
- PASS=`dialog --insecure --backtitle "FreeBSD Installer" \
- --title "WPA Setup" --mixedform "" 0 0 0 \
+if echo "$ENCRYPTION" | grep -q PSK; then
+ PASS=$( $DIALOG \
+ --title "WPA Setup" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --insecure \
+ --mixedform "" \
+ 0 0 0 \
"SSID" 1 0 "$NETWORK" 1 12 0 0 2 \
- "Password" 2 0 "" 2 12 15 63 1 \
- 2>&1 1>&3` \
- || exec $0 $@
- exec 3>&-
-echo "network={
- ssid=\"$NETWORK\"
- scan_ssid=$SCANSSID
- psk=\"$PASS\"
- priority=5
-}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-elif echo $ENCRYPTION | grep -q EAP; then
- exec 3>&1
- USERPASS=`dialog --insecure --backtitle "FreeBSD Installer" \
- --title "WPA-Enterprise Setup" --mixedform "" 0 0 0 \
+ "Password" 2 0 "" 2 12 15 63 1 \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ ) || exec "$0" "$@"
+ awk 'sub(/^\t/,"")||1' \
+ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
+ network={
+ ssid="$NETWORK"
+ scan_ssid=$SCANSSID
+ psk="$PASS"
+ priority=5
+ }
+ EOF
+elif echo "$ENCRYPTION" | grep -q EAP; then
+ USERPASS=$( $DIALOG \
+ --title "WPA-Enterprise Setup" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --insecure \
+ --mixedform "" \
+ 0 0 0 \
"SSID" 1 0 "$NETWORK" 1 12 0 0 2 \
- "Username" 2 0 "" 2 12 25 63 0 \
- "Password" 3 0 "" 3 12 25 63 1 \
- 2>&1 1>&3` \
- || exec $0 $@
- exec 3>&-
-echo "network={
- ssid=\"$NETWORK\"
- scan_ssid=$SCANSSID
- key_mgmt=WPA-EAP" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo "$USERPASS" | awk '
-{
- if (NR == 1) {
- printf " identity=\"%s\"\n", $1;
- } else if (NR == 2) {
- printf " password=\"%s\"\n", $1;
+ "Username" 2 0 "" 2 12 25 63 0 \
+ "Password" 3 0 "" 3 12 25 63 1 \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ ) || exec "$0" "$@"
+ awk 'sub(/^\t/,"")||1' \
+ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
+ network={
+ ssid="$NETWORK"
+ scan_ssid=$SCANSSID
+ key_mgmt=WPA-EAP$(
+ echo "$USERPASS" | awk '
+ NR == 1 { printf "\n\t\tidentity=\"%s\"", $1 }
+ NR == 2 { printf "\n\t\tpassword=\"%s\"", $1 }
+ ' )
+ priority=5
}
-}' >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-echo " priority=5
-}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-elif echo $ENCRYPTION | grep -q WEP; then
- exec 3>&1
- WEPKEY=`dialog --insecure --backtitle "FreeBSD Installer" \
- --title "WEP Setup" --mixedform "" 0 0 0 \
+ EOF
+elif echo "$ENCRYPTION" | grep -q WEP; then
+ WEPKEY=$( $DIALOG \
+ --title "WEP Setup" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --insecure \
+ --mixedform "" \
+ 0 0 0 \
"SSID" 1 0 "$NETWORK" 1 12 0 0 2 \
- "WEP Key 0" 2 0 "" 2 12 15 0 1 \
- 2>&1 1>&3` \
- || exec $0 $@
-echo "network={
- ssid=\"$NETWORK\"
- scan_ssid=$SCANSSID
- key_mgmt=NONE
- wep_key0=\"$WEPKEY\"
- wep_tx_keyidx=0
- priority=5
-}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
-else # Open
-echo "network={
- ssid=\"$NETWORK\"
- scan_ssid=$SCANSSID
- key_mgmt=NONE
- priority=5
-}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+ "WEP Key 0" 2 0 "" 2 12 15 0 1 \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ ) || exec "$0" "$@"
+ awk 'sub(/^\t/,"")||1' \
+ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
+ network={
+ ssid="$NETWORK"
+ scan_ssid=$SCANSSID
+ key_mgmt=NONE
+ wep_key0="$WEPKEY"
+ wep_tx_keyidx=0
+ priority=5
+ }
+ EOF
+else # Open
+ awk 'sub(/^\t/,"")||1' \
+ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
+ network={
+ ssid="$NETWORK"
+ scan_ssid=$SCANSSID
+ key_mgmt=NONE
+ priority=5
+ }
+ EOF
fi
# Connect to any open networks policy
-echo "network={
+cat >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" << EOF
+network={
priority=0
key_mgmt=NONE
-}" >> $BSDINSTALL_TMPETC/wpa_supplicant.conf
+}
+EOF
# Bring up new network
-if [ "$BSDINSTALL_CONFIGCURRENT" ]; then
- output=$( wpa_cli reconfigure 2>&1 )
- f_dprintf "%s" "$output"
-fi
+[ "$BSDINSTALL_CONFIGCURRENT" ] &&
+ f_eval_catch -d wlanconfig wpa_cli "wpa_cli reconfigure"
exit $SUCCESS
OpenPOWER on IntegriCloud