forked from openmiko/openmiko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpa-gen.sh
executable file
·73 lines (54 loc) · 1.45 KB
/
wpa-gen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
echo "Openmiko WPA Supplicant Generator"
OUTPUT_DIRECTORY="${1}"
if [ -z "${OUTPUT_DIRECTORY}" ]; then
echo "Error: Must supply output directory"
echo "Usage: ${0} output_directory"
exit 1
fi
if [ ! -d "${OUTPUT_DIRECTORY}" ]; then
echo "Output directory '${OUTPUT_DIRECTORY}' not found. Creating."
mkdir -p "${OUTPUT_DIRECTORY}"
fi
DETAILS_CORRECT=n
while [[ ${DETAILS_CORRECT} != [yY] ]]; do
WPA_SSID=""
WPA_PASSWORD=""
IS_HIDDEN_SSID=""
echo ""
while [[ -z "${WPA_SSID}" ]]; do
read -rp "Enter the SSID:" WPA_SSID
done
while [[ -z "${WPA_PASSWORD}" ]]; do
read -rp "Enter the password:" WPA_PASSWORD
done
while [[ ${IS_HIDDEN_SSID} != [yYnN] ]]; do
read -n1 -rp "Is this a hidden SSID? (y/n): " IS_HIDDEN_SSID
echo ""
done
echo -e "\nSSID: ${WPA_SSID}"
echo "Password: ${WPA_PASSWORD}"
echo "Hidden SSID: ${IS_HIDDEN_SSID}"
read -n1 -rp "Is this correct? (y/n): " DETAILS_CORRECT
done
echo ""
SCAN_SSID="0"
if [ "${IS_HIDDEN_SSID}" == "y" ]; then
SCAN_SSID="1"
fi
cat << EOF > "${OUTPUT_DIRECTORY}/wpa_supplicant.conf"
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1
bgscan="simple:30:-45:300"
network={
ssid="${WPA_SSID}"
scan_ssid=${SCAN_SSID}
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
psk="${WPA_PASSWORD}"
priority=2
}
EOF
echo "${OUTPUT_DIRECTORY}/wpa_supplicant.conf generated"