svn commit: r309934 - head/usr.sbin/bsdinstall/scripts
Devin Teske
dteske at FreeBSD.org
Mon Dec 12 19:46:50 UTC 2016
Author: dteske
Date: Mon Dec 12 19:46:49 2016
New Revision: 309934
URL: https://svnweb.freebsd.org/changeset/base/309934
Log:
Consolidate redirects into here documents, with proper code indentation
Modified:
head/usr.sbin/bsdinstall/scripts/wlanconfig
Modified: head/usr.sbin/bsdinstall/scripts/wlanconfig
==============================================================================
--- head/usr.sbin/bsdinstall/scripts/wlanconfig Mon Dec 12 19:33:40 2016 (r309933)
+++ head/usr.sbin/bsdinstall/scripts/wlanconfig Mon Dec 12 19:46:49 2016 (r309934)
@@ -69,9 +69,10 @@ country_set()
return $SUCCESS # Skip
fi
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
@@ -137,11 +138,13 @@ dialog_country_select()
: > "$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"
+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
@@ -246,12 +249,15 @@ if echo $ENCRYPTION | grep -q 'PSK'; the
2>&1 1>&3 ) \
|| exec $0 $@
exec 3>&-
-echo "network={
- ssid=\"$NETWORK\"
- scan_ssid=$SCANSSID
- psk=\"$PASS\"
- priority=5
-}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf"
+ 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
exec 3>&1
USERPASS=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \
@@ -262,20 +268,23 @@ elif echo $ENCRYPTION | grep -q EAP; the
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;
+ awk 'sub(/^\t/,"")||1' \
+ >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf" <<-EOF
+ network={
+ ssid="$NETWORK"
+ scan_ssid=$SCANSSID
+ key_mgmt=WPA-EAP$(
+ echo "$USERPASS" | awk '
+ {
+ if (NR == 1) {
+ printf " identity=\"%s\"\n", $1;
+ } else if (NR == 2) {
+ printf " password=\"%s\"\n", $1;
+ }
+ }' )
+ priority=5
}
-}' >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf"
-echo " priority=5
-}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf"
+ EOF
elif echo $ENCRYPTION | grep -q WEP; then
exec 3>&1
WEPKEY=$( dialog --insecure --backtitle "$DIALOG_BACKTITLE" \
@@ -284,28 +293,36 @@ elif echo $ENCRYPTION | grep -q WEP; the
"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"
+ 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
-echo "network={
- ssid=\"$NETWORK\"
- scan_ssid=$SCANSSID
- key_mgmt=NONE
- priority=5
-}" >> "$BSDINSTALL_TMPETC/wpa_supplicant.conf"
+ 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
More information about the svn-src-all
mailing list