-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlphaBot2-Setup.sh
277 lines (214 loc) · 7.74 KB
/
AlphaBot2-Setup.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Written by spoonie (Rick Spooner) for RobotsGo
menu_option_one() {
echo ""
echo "Set your desired Hostname"
read Hostname
echo " "
echo "SET WIFI country code - See https://en.wikipedia.org/wiki/ISO_3166-1"
echo "Remeber your country code as it will needed later for hostap setup"
read CCrpi
echo " "
echo "Removing uneeded packages..."
sudo apt-get remove -y realvnc-vnc-server
sudo apt-get remove -y chromium-browser
sudo apt-get remove -y chromium-browser-l10n
sudo apt-get remove -y chromium-codecs-ffmpeg-extra
echo " "
echo "Checking system updates..."
sudo apt-get update
sudo apt-get -y full-upgrade
echo " "
echo "Enable SSH..."
sudo systemctl enable ssh
sudo systemctl start ssh
echo " "
echo "Installing AbphaBot2 RobotsGo required Dependencies..."
sudo apt-get install -y make gcc python3 python3-pip python3-gpiozero xrdp xboxdrv libusb-dev libevent-dev libjpeg8-dev libbsd-dev libraspberrypi-dev libgpiod-dev
sudo pip3 install rpi_ws281x adafruit-circuitpython-servokit psutil pynput netifaces
echo " "
echo "Add XboxOne controller bluetooh config..."
echo 'options bluetooth disable_ertm=Y' | sudo tee -a /etc/modprobe.d/bluetooth.conf
echo " "
echo "Compile sixpair for PS3 controller..."
mkdir ~/sixpair
cd ~/sixpair
wget http://www.pabr.org/sixlinux/sixpair.c
gcc -o sixpair sixpair.c -lusb
echo " "
echo "Clone RobotsGo AlphaBot2 repo..."
cd ~
git clone https://github.com/RobotsGo/AlphaBot2.git
echo " "
echo "Setting scripts to executable..."
chmod +x ~/AlphaBot2/AlphaBot2-Control/start.sh
chmod +x ~/AlphaBot2/AlphaBot2-Control/startStreamer.sh
chmod +x ~/AlphaBot2/AlphaBot2-Control/startGameHatClient.sh
echo " "
echo "Clone and build ustreamer with omx support"
cd ~
git clone --depth=1 https://github.com/pikvm/ustreamer
cd ~/ustreamer
make WITH_OMX=1
sudo make install
echo " "
echo "Adding needed entries to config.txt"
echo "gpu_mem_256" | sudo tee -a /boot/config.txt
echo "dtparam=spi=on" | sudo tee -a /boot/config.txt
echo "dtparam=i2c_arm=on" | sudo tee -a /boot/config.txt
echo "start_x=1" | sudo tee -a /boot/config.txt
sudo sed -i 's/dtparam=audio=on/#dtparam=audio=on/g' /boot/config.txt
echo " "
echo "Setting Hostname"
sudo hostnamectl set-hostname $Hostname
echo "127.0.0.1 "$Hostname | sudo tee -a /etc/hosts
echo " "
echo "Setting wifi wpa Country Code"
echo "country="$CCrpi | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf
sudo iw reg set $CCrpi
echo " "
echo "Unblocking wifi"
sudo rfkill unblock wifi
echo "Updating EEPROM if required"
sudo rpi-eeprom-update -a
echo "Please restart for changes to take effect."
exit
}
menu_option_two() {
echo "Installing client required Dependencies"
sudo pip3 install pynput
echo " "
echo "Clone RobotsGo AlphaBot2 repo..."
cd ~
git clone https://github.com/RobotsGo/AlphaBot2.git
echo " "
echo "Setting scripts to executable..."
chmod +x ~/AlphaBot2/AlphaBot2-Control/start.sh
chmod +x ~/AlphaBot2/AlphaBot2-Control/startStreamer.sh
chmod +x ~/AlphaBot2/AlphaBot2-Control/startGameHatClient.sh
echo " "
echo "Done........"
exit
}
menu_option_three() {
echo "Set SSID Name"
read SSID
echo " "
echo "SET WPA passphrase - Must be more than eight charters long"
read WPA
echo " "
echo "SET WIFI country code - See https://en.wikipedia.org/wiki/ISO_3166-1"
read CC
echo " "
sudo apt-get install -y hostapd
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo apt-get install -y dnsmasq
sudo systemctl enable dnsmasq
echo " "
echo "Altering /etc/dhcpcd.conf..."
echo "interface wlan0" | sudo tee -a /etc/dhcpcd.conf
echo "static ip_address=10.13.69.1/24" | sudo tee -a /etc/dhcpcd.conf
echo "nohook wpa_supplicant" | sudo tee -a /etc/dhcpcd.conf
echo ""
echo "Altering /etc/dnsmasq.conf"
HOST=$(cat /etc/hostname)
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo touch /etc/dnsmasq.conf
echo "interface=wlan0" | sudo tee -a /etc/dnsmasq.conf
echo "dhcp-range=10.13.69.2,10.13.69.20,255.255.255.0" | sudo tee -a /etc/dnsmasq.conf
echo "domain=wlan" | sudo tee -a /etc/dnsmasq.conf
echo "address=/"$HOST".wlan/10.13.69.1" | sudo tee -a /etc/dnsmasq.conf
echo ""
echo "Building hostap config..."
sudo touch /etc/hostapd/hostapd.conf
echo "country_code="$CC | sudo tee -a /etc/hostapd/hostapd.conf
echo "interface=wlan0" | sudo tee -a /etc/hostapd/hostapd.conf
echo "ssid="$SSID | sudo tee -a /etc/hostapd/hostapd.conf
echo "hw_mode=a" | sudo tee -a /etc/hostapd/hostapd.conf
echo "channel=48" | sudo tee -a /etc/hostapd/hostapd.conf
echo "macaddr_acl=0" | sudo tee -a /etc/hostapd/hostapd.conf
echo "ieee80211d=1" | sudo tee -a /etc/hostapd/hostapd.conf
echo "ieee80211n=1" | sudo tee -a /etc/hostapd/hostapd.conf
echo "ieee80211ac=1" | sudo tee -a /etc/hostapd/hostapd.conf
echo "wmm_enabled=1" | sudo tee -a /etc/hostapd/hostapd.conf
echo "auth_algs=1" | sudo tee -a /etc/hostapd/hostapd.conf
echo "ignore_broadcast_ssid=0" |sudo tee -a /etc/hostapd/hostapd.conf
echo "wpa=2" | sudo tee -a /etc/hostapd/hostapd.conf
echo "wpa_passphrase="$WPA | sudo tee -a /etc/hostapd/hostapd.conf
echo "wpa_key_mgmt=WPA-PSK" | sudo tee -a /etc/hostapd/hostapd.conf
echo "wpa_pairwise=TKIP" | sudo tee -a /etc/hostapd/hostapd.conf
echo "rsn_pairwise=CCMP" | sudo tee -a /etc/hostapd/hostapd.conf
echo " "
echo "AlphaBot2 WIFI AP available @ 10.13.69.1 or " $HOST".wlan"
echo "Please restart for changes to take effect."
exit
}
menu_option_four() {
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "@@@((((@@&((((((((((((((((%@@@@@@@@@@@@@"
echo "@@@(((//@@@/////////////////****@@@@@@@@"
echo "@@@(((((/&@@///////////////////***&@@@@@"
echo "@@@((((((((@@(//////@@@@@@@@@///****@@@@"
echo "@@@(((((((((@@@(((#@@@@#/(@@@@%/////(@@@"
echo "@@@@@@@@@@@@@@@@@@@@@@/////@@@@/////*@@@"
echo "@@@@@@@@(((@@@((//(@@@@&(%@@@@#/////(@@@"
echo "@@@@@@@@((((#@@(((((%@@@@@@@&///////@@@@"
echo "@@@@@@@@((((((@@@((((((///////////@@@@@@"
echo "@@@@@@@@##(((((@@@(((((((///////@@@@@@@@"
echo "@@@@@@@@###(((((&@@/(((((####@@@@@@@@@@@"
echo "@@@@@@@@#####(((((@@#/////((##@@@@@@@@@@"
echo "@@@@@@@@########(((@@@////(((((@@@@@@@@@"
echo "@@@@@@@@###########(@@@///((((((#@@@@@@@"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "AlphaBot2-Setup Version 0.2"
echo ""
echo "https://robotsgo.net/ https://github.com/RobotsGo"
echo "Credits: Spoonieau (Rick Spooner)"
}
launcher_exit() {
exit
}
press_enter() {
echo ""
echo -n " Press Enter to continue "
read
clear
}
incorrect_selection() {
echo "Incorrect selection! Try again."
}
until [ "$selection" = "0" ]; do
clear
echo ""
echo ""
echo "RobotsGo AlphaBot2-Setup Version 0.3"
echo ""
echo " 1 - Menu Option 1: Setup RobotsGo AlphaBot2 Robot platform"
echo " 2 - Menu Option 2: Setup up PC client"
echo " 3 - Menu Option 3: Setup AlphaBot2 as 5ghz WIFI AP + DHCP (RUN Menu Option 1 FIRST!!!!!)"
echo " 4 - Menu Option 4: View info"
echo " 0 - Exit"
echo ""
echo -n " Enter selection: "
read selection
echo ""
case $selection in
1 ) clear ; menu_option_one ;;
2 ) clear ; menu_option_two ; press_enter ;;
3 ) clear ; menu_option_three ;;
4 ) clear ; menu_option_four ; press_enter ;;
0 ) clear ; launcher_exit ;;
* ) clear ; incorrect_selection ; press_enter ;;
esac
done