forked from EA7KDO/NX4832K035
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetwifi.sh
executable file
·77 lines (66 loc) · 1.66 KB
/
setwifi.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
74
75
76
77
#!/bin/bash
##############################################################
# Support for Nextion Screen to create basic wpa_supplicant #
# file in Nextion_Support directory. #
# #
# $1 is ssid and $2 is pre-shared key. #
# If $1 does not exist then will return hostname for AP mode #
# If $2 does not exist then will return default raspberry #
# #
# KF6S 07-04-2019 #
##############################################################
if [ -z "$1" ]; then
ssid="$HOSTNAME"
else ssid=$1
fi
if [ -z "$2" ]; then
psk="raspberry"
else psk=$2
fi
##echo $ssid
##echo $psk
sudo mount -o remount,rw /
sleep 1s
sudo cat >/usr/local/etc/Nextion_Support/wpa_supplicant.conf <<EOL
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
ap_scan=1
fast_reauth=1
country=US
network={
ssid="${ssid}"
psk="${psk}"
key_mgmt=WPA-PSK
id_str="0"
priority=100
}
EOL
status=$?
if test $status -eq 0
then
echo "Supplicant file was created! "
else
sudo mount -o remount,rw /
sleep 1s
sudo cat >/usr/local/etc/Nextion_Support/wpa_supplicant.conf <<EOL
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
ap_scan=1
fast_reauth=1
country=US
network={
ssid="${ssid}"
psk="${psk}"
key_mgmt=WPA-PSK
id_str="0"
priority=100
}
EOL
status=$?
if test $status -eq 0
then
echo "Supplicant file was created on second try!"
else
echo "Supplicant file was not created!"
fi
fi