2011-02-18 14:54:34 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#-
|
|
|
|
# Copyright (c) 2011 Nathan Whitehorn
|
2016-12-08 19:28:12 +00:00
|
|
|
# Copyright (c) 2013-2016 Devin Teske
|
2011-02-18 14:54:34 +00:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
# SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
2013-11-08 09:57:03 +00:00
|
|
|
#
|
|
|
|
############################################################ INCLUDES
|
|
|
|
|
|
|
|
BSDCFG_SHARE="/usr/share/bsdconfig"
|
|
|
|
. $BSDCFG_SHARE/common.subr || exit 1
|
2016-06-08 20:42:35 +00:00
|
|
|
f_include $BSDCFG_SHARE/dialog.subr
|
2016-12-12 19:01:04 +00:00
|
|
|
f_dialog_backtitle "FreeBSD Installer"
|
2013-11-08 09:57:03 +00:00
|
|
|
|
2016-12-08 19:28:12 +00:00
|
|
|
############################################################ FUNCTIONS
|
2011-02-18 14:54:34 +00:00
|
|
|
|
2016-06-08 20:42:35 +00:00
|
|
|
country_set()
|
|
|
|
{
|
2016-12-12 18:21:56 +00:00
|
|
|
local error_str iface_up ifconfig_args=
|
2016-06-08 20:42:35 +00:00
|
|
|
|
2016-12-12 18:05:54 +00:00
|
|
|
#
|
2016-06-08 20:42:35 +00:00
|
|
|
# Setup what was selected
|
2016-12-12 18:05:54 +00:00
|
|
|
# NB: Do not change order of arguments (or regdomain will be ignored)
|
|
|
|
#
|
2016-12-12 18:24:41 +00:00
|
|
|
[ "$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# }"
|
2016-06-08 20:42:35 +00:00
|
|
|
|
|
|
|
# Regdomain/country cannot be applied while interface is running
|
2016-12-12 22:57:07 +00:00
|
|
|
iface_up=$( ifconfig -lu | grep -w "$WLAN_IFACE" )
|
|
|
|
[ "$iface_up" ] && ifconfig "$WLAN_IFACE" down
|
|
|
|
error_str=$( ifconfig "$WLAN_IFACE" $ifconfig_args 2>&1 |
|
2016-12-12 18:39:26 +00:00
|
|
|
sed -e 's/ifconfig: //' )
|
2016-12-12 18:17:30 +00:00
|
|
|
if [ "$iface_up" ]; then
|
2016-06-08 20:42:35 +00:00
|
|
|
# Restart wpa_supplicant(8) (should not fail).
|
2016-12-12 22:57:07 +00:00
|
|
|
wpa_supplicant -B -i "$WLAN_IFACE" -c \
|
2016-12-12 18:52:22 +00:00
|
|
|
"$BSDINSTALL_TMPETC/wpa_supplicant.conf"
|
2016-06-08 20:42:35 +00:00
|
|
|
fi
|
2016-12-12 18:17:30 +00:00
|
|
|
if [ "$error_str" ]; then
|
2016-12-12 20:43:09 +00:00
|
|
|
$DIALOG \
|
2016-12-12 21:23:47 +00:00
|
|
|
--title "$msg_error" \
|
2016-12-12 20:54:20 +00:00
|
|
|
--backtitle "$DIALOG_BACKTITLE" \
|
2016-12-12 20:41:27 +00:00
|
|
|
--yes-label Change \
|
|
|
|
--no-label Ignore \
|
|
|
|
--yesno \
|
|
|
|
"Error while applying chosen settings ($error_str)" \
|
2016-12-13 00:27:56 +00:00
|
|
|
0 0 || return $SUCCESS # Skip
|
|
|
|
return $FAILURE # Restart
|
2016-06-08 20:42:35 +00:00
|
|
|
else
|
2016-12-12 19:46:49 +00:00
|
|
|
awk 'sub(/^\t\t/,"")||1' \
|
|
|
|
> "$BSDINSTALL_TMPETC/rc.conf.net.wlan" <<-EOF
|
|
|
|
create_args_$WLAN_IFACE="$ifconfig_args"
|
|
|
|
EOF
|
2016-06-08 20:42:35 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return $SUCCESS
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog_country_select()
|
|
|
|
{
|
2016-12-13 00:22:01 +00:00
|
|
|
local input regdomains countries regdomain country prompt
|
2016-12-12 19:07:42 +00:00
|
|
|
local no_default="<not selected>"
|
2016-12-12 19:10:39 +00:00
|
|
|
local default_regdomain="${1:-$no_default}"
|
|
|
|
local default_country="${2:-$no_default}"
|
2016-06-08 20:42:35 +00:00
|
|
|
|
2016-12-12 18:05:54 +00:00
|
|
|
#
|
2016-06-08 20:42:35 +00:00
|
|
|
# Parse available countries/regdomains
|
2016-12-12 18:05:54 +00:00
|
|
|
#
|
2016-12-12 22:57:07 +00:00
|
|
|
input=$( ifconfig "$WLAN_IFACE" list countries | sed -e 's/DEBUG//gi' )
|
2016-12-13 01:35:26 +00:00
|
|
|
regdomains=$( echo "$input" | awk '
|
|
|
|
sub(/.*domains:/, ""), /[^[:alnum:][[:space:]]/ {
|
|
|
|
n = split($0, domains)
|
|
|
|
for (i = 1; i <= n; i++)
|
|
|
|
printf "'\''%s'\'' '\'\''", domains[i]
|
|
|
|
}
|
2016-12-13 01:36:46 +00:00
|
|
|
' | sort )
|
2016-12-13 00:02:59 +00:00
|
|
|
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)
|
|
|
|
}
|
2016-06-08 20:42:35 +00:00
|
|
|
}
|
2016-12-13 00:02:59 +00:00
|
|
|
' | sort )
|
2016-06-08 20:42:35 +00:00
|
|
|
|
2016-12-12 21:00:09 +00:00
|
|
|
f_dialog_title "Regdomain selection"
|
2016-12-13 00:22:01 +00:00
|
|
|
prompt="Select your regdomain."
|
2016-12-13 01:35:26 +00:00
|
|
|
eval f_dialog_menu_size height width rows \
|
|
|
|
\"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \
|
|
|
|
\"\$prompt\" \"\" $regdomains
|
|
|
|
regdomain=$( eval $DIALOG \
|
2016-12-13 01:39:09 +00:00
|
|
|
--title \"\$DIALOG_TITLE\" \
|
|
|
|
--backtitle \"\$DIALOG_BACKTITLE\" \
|
|
|
|
--cancel-label \"\$msg_skip\" \
|
2016-12-13 01:35:26 +00:00
|
|
|
--default-item \"\$default_regdomain\" \
|
2016-12-13 01:39:09 +00:00
|
|
|
--menu \"\$prompt\" \
|
|
|
|
$height $width $rows \
|
|
|
|
$regdomains \
|
2016-12-13 01:35:26 +00:00
|
|
|
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
|
2016-12-12 18:52:22 +00:00
|
|
|
)
|
2016-12-13 01:41:06 +00:00
|
|
|
f_dialog_data_sanitize regdomain
|
2016-06-08 20:42:35 +00:00
|
|
|
|
2016-12-12 21:00:09 +00:00
|
|
|
f_dialog_title "Country selection"
|
2016-12-13 00:22:01 +00:00
|
|
|
prompt="Select your country."
|
2016-12-13 00:02:59 +00:00
|
|
|
eval f_dialog_menu_size height width rows \
|
|
|
|
\"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \
|
2016-12-13 00:22:01 +00:00
|
|
|
\"\$prompt\" \"\" $countries
|
2016-12-13 00:02:59 +00:00
|
|
|
country=$( eval $DIALOG \
|
2016-12-13 01:39:09 +00:00
|
|
|
--title \"\$DIALOG_TITLE\" \
|
|
|
|
--backtitle \"\$DIALOG_BACKTITLE\" \
|
|
|
|
--cancel-label \"\$msg_skip\" \
|
2016-12-13 00:18:51 +00:00
|
|
|
--default-item \"\$default_country\" \
|
2016-12-13 01:39:09 +00:00
|
|
|
--menu \"\$prompt\" \
|
|
|
|
$height $width $rows \
|
|
|
|
$countries \
|
2016-12-13 00:02:59 +00:00
|
|
|
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
|
2016-12-12 18:52:22 +00:00
|
|
|
)
|
2016-12-13 01:41:06 +00:00
|
|
|
f_dialog_data_sanitize country
|
2016-06-08 20:42:35 +00:00
|
|
|
|
|
|
|
country_set "$regdomain" "$country"
|
|
|
|
}
|
|
|
|
|
2016-12-08 19:28:12 +00:00
|
|
|
############################################################ MAIN
|
|
|
|
|
2016-12-12 18:43:42 +00:00
|
|
|
: > "$BSDINSTALL_TMPETC/wpa_supplicant.conf"
|
2016-12-12 18:38:18 +00:00
|
|
|
chmod 0600 "$BSDINSTALL_TMPETC/wpa_supplicant.conf"
|
2016-12-08 19:28:12 +00:00
|
|
|
|
2016-12-12 19:46:49 +00:00
|
|
|
cat >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" << EOF
|
|
|
|
ctrl_interface=/var/run/wpa_supplicant
|
|
|
|
eapol_version=2
|
|
|
|
ap_scan=1
|
|
|
|
fast_reauth=1
|
|
|
|
|
|
|
|
EOF
|
2016-12-08 19:28:12 +00:00
|
|
|
|
2016-12-12 18:05:54 +00:00
|
|
|
#
|
2016-12-08 19:28:12 +00:00
|
|
|
# Try to reach wpa_supplicant. If it isn't running and we can modify the
|
|
|
|
# existing system, start it. Otherwise, fail.
|
2016-12-12 18:05:54 +00:00
|
|
|
#
|
2016-12-13 01:54:44 +00:00
|
|
|
if ! wpa_cli ping > /dev/null 2>&1; then
|
2016-12-13 02:04:50 +00:00
|
|
|
if [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then
|
2016-12-13 01:54:44 +00:00
|
|
|
$DIALOG --backtitle "$DIALOG_BACKTITLE" --title "$msg_error" --msgbox \
|
2016-12-13 02:04:50 +00:00
|
|
|
"Wireless cannot be configured without making changes to the local system!" 0 0
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
wpa_supplicant -B -i $1 -c "$BSDINSTALL_TMPETC/wpa_supplicant.conf") || exit 1
|
2016-12-08 19:28:12 +00:00
|
|
|
|
2016-12-13 01:59:35 +00:00
|
|
|
if ! wpa_cli ping > /dev/null 2>&1 && [ ! "$BSDINSTALL_CONFIGCURRENT" ]; then
|
2016-12-13 01:56:28 +00:00
|
|
|
$DIALOG \
|
|
|
|
--title "$msg_error" \
|
|
|
|
--backtitle "$DIALOG_BACKTITLE" \
|
2016-12-13 02:02:14 +00:00
|
|
|
--msgbox "Could not start wpa_supplicant!" \
|
2016-12-13 01:56:28 +00:00
|
|
|
0 0
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-12-08 19:28:12 +00:00
|
|
|
fi
|
|
|
|
|
2016-12-12 18:05:54 +00:00
|
|
|
#
|
2016-06-08 20:42:35 +00:00
|
|
|
# There is no way to check country/regdomain without (possible)
|
|
|
|
# interface state modification
|
2016-12-12 18:05:54 +00:00
|
|
|
#
|
2016-12-12 18:17:30 +00:00
|
|
|
if [ "$BSDINSTALL_CONFIGCURRENT" ]; then
|
2016-06-08 20:42:35 +00:00
|
|
|
# Get current country/regdomain for selected interface
|
2016-12-12 18:48:00 +00:00
|
|
|
WLAN_IFACE=$( wpa_cli ifname | tail -1 )
|
2016-12-12 22:57:07 +00:00
|
|
|
INPUT=$( ifconfig "$WLAN_IFACE" list regdomain | head -1 )
|
2016-12-13 01:44:18 +00:00
|
|
|
DEF_REGDOMAIN=$( echo "$INPUT" | cut -w -f 2 )
|
|
|
|
DEF_COUNTRY=$( echo "$INPUT" | cut -w -f 4 )
|
2016-12-12 18:34:21 +00:00
|
|
|
[ "$DEF_REGDOMAIN" = 0 ] && DEF_REGDOMAIN="<not selected>"
|
2016-12-12 18:33:40 +00:00
|
|
|
[ "$DEF_COUNTRY" = 0 ] && DEF_COUNTRY="<not selected>"
|
2016-12-12 21:00:09 +00:00
|
|
|
f_dialog_title "Regdomain/country"
|
2016-12-12 20:43:09 +00:00
|
|
|
$DIALOG \
|
2016-12-12 21:00:09 +00:00
|
|
|
--title "$DIALOG_TITLE" \
|
2016-12-12 20:54:20 +00:00
|
|
|
--backtitle "$DIALOG_BACKTITLE" \
|
2016-12-12 20:41:27 +00:00
|
|
|
--yesno "Change regdomain/country (now $DEF_REGDOMAIN/$DEF_COUNTRY)?" \
|
|
|
|
0 0
|
2016-06-08 20:42:35 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
2016-12-12 21:26:36 +00:00
|
|
|
while :; do
|
2016-06-08 20:42:35 +00:00
|
|
|
dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY"
|
|
|
|
if [ $? -eq $SUCCESS ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2011-02-18 14:54:34 +00:00
|
|
|
fi
|
|
|
|
|
2016-12-12 18:52:22 +00:00
|
|
|
while :; do
|
2016-12-08 16:41:18 +00:00
|
|
|
SCANSSID=0
|
2016-06-08 20:42:35 +00:00
|
|
|
output=$( wpa_cli scan 2>&1 )
|
|
|
|
f_dprintf "%s" "$output"
|
2016-12-12 21:00:09 +00:00
|
|
|
f_dialog_title "Scanning"
|
2016-12-12 20:43:09 +00:00
|
|
|
$DIALOG \
|
2016-12-12 21:00:09 +00:00
|
|
|
--title "$DIALOG_TITLE" \
|
2016-12-12 20:54:20 +00:00
|
|
|
--backtitle "$DIALOG_BACKTITLE" \
|
2016-12-12 21:23:47 +00:00
|
|
|
--ok-label "$msg_skip" \
|
2016-12-12 20:41:27 +00:00
|
|
|
--pause "Waiting 5 seconds to scan for wireless networks..." \
|
|
|
|
9 40 5 || exit 1
|
2016-06-08 20:42:35 +00:00
|
|
|
|
2016-12-12 18:10:33 +00:00
|
|
|
SCAN_RESULTS=$( wpa_cli scan_results )
|
2016-12-12 20:41:27 +00:00
|
|
|
NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' '
|
2016-12-13 02:07:12 +00:00
|
|
|
/..:..:..:..:..:../ && $5 { printf "\"%s\"\t%s\n", $5, $4 }
|
2016-12-12 20:41:27 +00:00
|
|
|
' | sort | uniq )
|
2016-06-08 20:42:35 +00:00
|
|
|
|
2016-12-12 18:17:30 +00:00
|
|
|
if [ ! "$NETWORKS" ]; then
|
2016-12-12 21:23:47 +00:00
|
|
|
f_dialog_title "$msg_error"
|
2016-12-12 20:43:09 +00:00
|
|
|
$DIALOG \
|
2016-12-12 21:00:09 +00:00
|
|
|
--title "$DIALOG_TITLE" \
|
2016-12-12 20:54:20 +00:00
|
|
|
--backtitle "$DIALOG_BACKTITLE" \
|
2016-12-12 20:41:27 +00:00
|
|
|
--yesno "No wireless networks were found. Rescan?" \
|
|
|
|
0 0 && continue
|
2016-06-08 20:42:35 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-12-12 21:00:09 +00:00
|
|
|
f_dialog_title "Network Selection"
|
2016-12-12 20:43:09 +00:00
|
|
|
NETWORK=$( sh -c "$DIALOG \
|
2016-12-12 21:00:09 +00:00
|
|
|
--title \"$DIALOG_TITLE\" \
|
2016-12-12 20:54:20 +00:00
|
|
|
--backtitle \"$DIALOG_BACKTITLE\" \
|
2016-12-12 20:41:27 +00:00
|
|
|
--extra-button \
|
|
|
|
--extra-label \"Rescan\" \
|
|
|
|
--menu \"Select a wireless network to connect to.\" \
|
|
|
|
0 0 0 \
|
|
|
|
$( echo $NETWORKS | tr '\n' ' ' )" \
|
2016-12-12 21:20:56 +00:00
|
|
|
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
|
2016-12-12 20:41:27 +00:00
|
|
|
)
|
2016-12-13 01:41:06 +00:00
|
|
|
retval=$?
|
|
|
|
f_dialog_data_sanitize NETWORK
|
|
|
|
case $retval in
|
2016-12-12 21:26:36 +00:00
|
|
|
$DIALOG_OK) break ;;
|
2016-12-12 18:55:41 +00:00
|
|
|
$DIALOG_CANCEL)
|
2016-12-08 16:41:18 +00:00
|
|
|
# here we ask if the user wants to select the network manually
|
|
|
|
f_dialog_title "Network Selection"
|
2016-12-13 01:42:13 +00:00
|
|
|
f_yesno "Do you want to select the network manually?" || exit 1
|
2016-12-08 16:41:18 +00:00
|
|
|
f_dialog_input NETWORK "Enter SSID" || exit 1
|
2016-12-12 20:43:09 +00:00
|
|
|
ENCRYPTION=$( $DIALOG \
|
2016-12-12 20:41:27 +00:00
|
|
|
--title "$DIALOG_TITLE" \
|
2016-12-12 20:54:20 +00:00
|
|
|
--backtitle "$DIALOG_BACKTITLE" \
|
2016-12-12 20:41:27 +00:00
|
|
|
--menu "Select encryption type" \
|
|
|
|
0 0 0 \
|
|
|
|
"1 WPA/WPA2 PSK" "" \
|
|
|
|
"2 WPA/WPA2 EAP" "" \
|
|
|
|
"3 WEP" "" \
|
|
|
|
"0 None" "" \
|
2016-12-12 21:20:56 +00:00
|
|
|
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
|
2016-12-12 20:41:27 +00:00
|
|
|
) || exit 1
|
2016-12-08 16:41:18 +00:00
|
|
|
SCANSSID=1
|
|
|
|
break
|
2016-06-08 20:42:35 +00:00
|
|
|
;;
|
2016-12-12 18:55:41 +00:00
|
|
|
$DIALOG_EXTRA) # Rescan
|
2016-06-08 20:42:35 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2011-02-18 14:54:34 +00:00
|
|
|
|
2016-12-12 20:41:27 +00:00
|
|
|
[ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" |
|
2016-12-13 02:14:40 +00:00
|
|
|
awk -F '\t' "/^\"$NETWORK\"\t/ { print \$2 }" )
|
2011-02-18 14:54:34 +00:00
|
|
|
|
2016-12-13 02:15:36 +00:00
|
|
|
if echo "$ENCRYPTION" | grep -q 'PSK'; then
|
2016-12-12 20:43:09 +00:00
|
|
|
PASS=$( $DIALOG \
|
2016-12-13 02:11:09 +00:00
|
|
|
--title "WPA Setup" \
|
|
|
|
--backtitle "$DIALOG_BACKTITLE" \
|
|
|
|
--insecure \
|
|
|
|
--mixedform "" \
|
|
|
|
0 0 0 \
|
2011-02-18 14:54:34 +00:00
|
|
|
"SSID" 1 0 "$NETWORK" 1 12 0 0 2 \
|
2016-12-13 02:11:09 +00:00
|
|
|
"Password" 2 0 "" 2 12 15 63 1 \
|
2016-12-12 21:20:56 +00:00
|
|
|
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
|
2016-12-12 21:04:11 +00:00
|
|
|
) || exec "$0" "$@"
|
2016-12-12 19:46:49 +00:00
|
|
|
awk 'sub(/^\t/,"")||1' \
|
|
|
|
>> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
|
|
|
|
network={
|
|
|
|
ssid="$NETWORK"
|
|
|
|
scan_ssid=$SCANSSID
|
|
|
|
psk="$PASS"
|
|
|
|
priority=5
|
|
|
|
}
|
|
|
|
EOF
|
2016-12-13 02:15:36 +00:00
|
|
|
elif echo "$ENCRYPTION" | grep -q EAP; then
|
2016-12-12 20:43:09 +00:00
|
|
|
USERPASS=$( $DIALOG \
|
2016-12-13 02:11:09 +00:00
|
|
|
--title "WPA-Enterprise Setup" \
|
|
|
|
--backtitle "$DIALOG_BACKTITLE" \
|
|
|
|
--insecure \
|
|
|
|
--mixedform "" \
|
|
|
|
0 0 0 \
|
2014-01-04 17:09:41 +00:00
|
|
|
"SSID" 1 0 "$NETWORK" 1 12 0 0 2 \
|
2016-12-13 02:11:09 +00:00
|
|
|
"Username" 2 0 "" 2 12 25 63 0 \
|
|
|
|
"Password" 3 0 "" 3 12 25 63 1 \
|
2016-12-12 21:20:56 +00:00
|
|
|
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
|
2016-12-12 21:04:11 +00:00
|
|
|
) || exec "$0" "$@"
|
2016-12-12 19:46:49 +00:00
|
|
|
awk 'sub(/^\t/,"")||1' \
|
|
|
|
>> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
|
|
|
|
network={
|
|
|
|
ssid="$NETWORK"
|
|
|
|
scan_ssid=$SCANSSID
|
|
|
|
key_mgmt=WPA-EAP$(
|
|
|
|
echo "$USERPASS" | awk '
|
2016-12-12 21:18:24 +00:00
|
|
|
NR == 1 { printf "\n\t\tidentity=\"%s\"", $1 }
|
|
|
|
NR == 2 { printf "\n\t\tpassword=\"%s\"", $1 }
|
2016-12-12 21:16:37 +00:00
|
|
|
' )
|
2016-12-12 19:46:49 +00:00
|
|
|
priority=5
|
2014-01-04 17:09:41 +00:00
|
|
|
}
|
2016-12-12 19:46:49 +00:00
|
|
|
EOF
|
2016-12-13 02:15:36 +00:00
|
|
|
elif echo "$ENCRYPTION" | grep -q WEP; then
|
2016-12-12 20:43:09 +00:00
|
|
|
WEPKEY=$( $DIALOG \
|
2016-12-13 02:11:09 +00:00
|
|
|
--title "WEP Setup" \
|
|
|
|
--backtitle "$DIALOG_BACKTITLE" \
|
|
|
|
--insecure \
|
|
|
|
--mixedform "" \
|
|
|
|
0 0 0 \
|
2011-02-18 14:54:34 +00:00
|
|
|
"SSID" 1 0 "$NETWORK" 1 12 0 0 2 \
|
2016-12-13 02:11:09 +00:00
|
|
|
"WEP Key 0" 2 0 "" 2 12 15 0 1 \
|
2016-12-12 21:20:56 +00:00
|
|
|
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
|
2016-12-12 21:04:11 +00:00
|
|
|
) || exec "$0" "$@"
|
2016-12-12 19:46:49 +00:00
|
|
|
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
|
2016-12-12 20:41:27 +00:00
|
|
|
else # Open
|
2016-12-12 19:46:49 +00:00
|
|
|
awk 'sub(/^\t/,"")||1' \
|
|
|
|
>> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
|
|
|
|
network={
|
|
|
|
ssid="$NETWORK"
|
|
|
|
scan_ssid=$SCANSSID
|
|
|
|
key_mgmt=NONE
|
|
|
|
priority=5
|
|
|
|
}
|
|
|
|
EOF
|
2011-02-18 14:54:34 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Connect to any open networks policy
|
2016-12-12 19:46:49 +00:00
|
|
|
cat >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" << EOF
|
|
|
|
network={
|
2014-01-04 16:44:05 +00:00
|
|
|
priority=0
|
2011-02-18 14:54:34 +00:00
|
|
|
key_mgmt=NONE
|
2016-12-12 19:46:49 +00:00
|
|
|
}
|
|
|
|
EOF
|
2011-02-18 14:54:34 +00:00
|
|
|
|
|
|
|
# Bring up new network
|
2013-11-08 09:57:03 +00:00
|
|
|
if [ "$BSDINSTALL_CONFIGCURRENT" ]; then
|
|
|
|
output=$( wpa_cli reconfigure 2>&1 )
|
|
|
|
f_dprintf "%s" "$output"
|
|
|
|
fi
|
2011-02-18 14:54:34 +00:00
|
|
|
|
2015-09-11 21:14:48 +00:00
|
|
|
exit $SUCCESS
|
2013-11-08 09:57:03 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# END
|
|
|
|
################################################################################
|