-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathconfigure-network
executable file
·65 lines (57 loc) · 1.04 KB
/
configure-network
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
#!/usr/bin/env bash
set -e
help="
Usage:
-s <ssid> WiFi ssid
-p <psk> WiFi Password
Example:
$ ./tools/configure-network -s <ssid> -p <psk>
"
ssid=""
psk=""
while [ $# -gt 0 ]; do
case "$1" in
-s)
ssid="$2"
shift
;;
-p)
psk="$2"
shift
;;
--help)
printf "$help"
exit
;;
-h)
printf "$help"
exit
;;
--*)
echo "Illegal option $1"
;;
esac
shift $(( $# > 0 ? 1 : 0 ))
done
adb shell "mount -o remount,rw /"
# MARK: - Setup Network
if ! test -z "$ssid" && ! test -z "$psk"; then
set +e
content="$(adb shell cat /data/system/wpa_supplicant.conf | grep ssid)"
set -e
if test -z "$content"; then
adb shell << EOC
cat >> /data/system/wpa_supplicant.conf <<- EOS
network={
ssid="$ssid"
psk="$psk"
}
EOS
EOC
else
printf "Device already configured WiFi connection. No network modification was made.\n"
fi
else
printf "No network modification was made for no ssid or psk specified.\n$help\n"
fi
adb shell wpa_cli reconfigure