-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIND.sh
More file actions
executable file
·416 lines (342 loc) · 11.8 KB
/
Copy pathIND.sh
File metadata and controls
executable file
·416 lines (342 loc) · 11.8 KB
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
#!/bin/bash
############################################################
# This script will automate the process of #
# Installing the Nextion Driver #
# #
# VE3RD 2020/10/04 #
############################################################
set -o errexit
set -o pipefail
ver="20200512"
sudo mount -o remount,rw /
arg1="$?"
export NCURSES_NO_UTF8_ACS=1
if [ -f ~/.dialog ]; then
j=1
else
sudo dialog --create-rc ~/.dialogrc
fi
#use_colors = ON
#screen_color = (WHITE,BLUE,ON)
#title_color = (YELLOW,RED,ON)
sed -i '/use_colors = /c\use_colors = ON' ~/.dialogrc
sed -i '/screen_color = /c\screen_color = (WHITE,BLUE,ON)' ~/.dialogrc
sed -i '/title_color = /c\title_color = (YELLOW,RED,ON)' ~/.dialogrc
echo -e '\e[1;44m'
clear
sudo mount -o remount,rw /
homedir=/home/pi-star/
curdir=$(pwd)
clear
echo " "
echo " If this is a fresh pi-star install - Select Update"
echo " This will do a pistar update before installing the Driver"
echo " "
echo " Selecting Start will install the driver without doing the Update"
echo " "
echo " This script installs the Nextion Driver. It will require a reboot "
echo " Part way through the procedure. After the Reboot, run this script again"
echo " and select 'Continue' in the following menu"
echo " "
sleep 3
continue=0
####################
function cleandriver(){
#Remove NextionDriver Section
sed -i '/\[NextionDriver/,/^$/d' /etc/mmdvmhost
echo "Removing Nextion Driver Configuration"
#Reset Nextion Port
tport="/dev/ttyUSB0"
TOPort=$(echo "$tport" | sed "s/\//\\\\\//g")
echo "Setting Nextion Port to /dev/ttyUSB0 for Pi-Star"
sudo sed -i '/^\[/h;G;/Nextion]/s/\(Port=\).*/\1'"$TOPort"'/m;P;d' /etc/mmdvmhost
if [ -f /etc/mmdvmhost.old ]; then
#Remove /etc/mmdvmhost.old
echo "Removing old /etc/mmdvmhost.old"
sudo rm /etc/mmdvmhost.old
fi
echo "Configuration Removed - Restarting Script"
sleep 2
}
function preparedir
{
if [ -d /Nextion ] ; then
sudo rm -R /Nextion
fi
sudo git clone https://github.com/on7lds/NextionDriverInstaller.git /Nextion/
}
####################
function preparedir2 () {
if [ ! -d /Nextion ] ; then
echo "Downloading Files to create /Nextion Directory"
sudo git clone https://github.com/on7lds/NextionDriverInstaller.git /Nextion/
fi
}
##################
function installnxd
{
echo " "
echo "STARTING NEXTION DRIVER INSTALLATION"
echo " "
echo "Remove Existing Nextion Driver"
sudo mount -o remount,rw /
#Remove the Nextion Driver if it exists
if [ -f /usr/local/bin/NextionDriver ] ; then
sudo rm /usr/local/bin/NextionDriver
fi
sudo mount -o remount,rw /
#Download the driver to /Nextion/
echo "Remove /Nextion Install Directory"
if [ -d /Nextion ] ; then
sudo rm -R /Nextion
fi
sudo mount -o remount,rw /
echo "Get Files from github"
sudo git clone https://github.com/on7lds/NextionDriverInstaller.git /Nextion/
#Check to ensure we created the Install Directory
if [ -d /Nextion ] ; then
echo "Install Directory created ok"
else
echo "Failed to Create Install Directory- Check RW Permissions"
exit
fi
#Run the Install Script
echo "Running the Install Script"
sudo mount -o remount,rw /
sudo /Nextion/install.sh
exit
}
function clearcomments()
{
sed '/DMRid/s/^#//g' -i /etc/mmdvmhost
}
############################## MAIN PROGRAM #################
if [ ! -d /temp ] ; then
sudo mkdir /temp
fi
HEIGHT=15
WIDTH=60
CHOICE_HEIGHT=10
BACKTITLE="This SCRIPT will Install the Nextion Driver, BC, and Firewall Rule - VE3RD $ver"
TITLE="Main Menu - Nextion Driver Installation"
MENU="Select your Installation Mode"
OPTIONS=(1 "Pi-Star Update + Install Nextion Driver"
2 "Install Nextion Driver - No Update"
3 "Continue after Reboot from Option 1 or 2"
4 "Check Nextion Driver Installation"
5 "Update stripped.csv"
6 "Remove NextionDriver Configuration"
7 "Download & Install Nextion Screen Support Files"
8 "Quit")
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
echo -e '\e[1;37m'
case $CHOICE in
1)
echo "You Chose Pi-Star Update + Install"
sudo systemctl stop cron.service
sudo mount -o remount,rw /
sudo pistar-update
sudo mount -o remount,rw /
installnxd
;;
2)
echo "You Chose Install - No Update"
installnxd
;;
3)
echo "You Chose Continue after Reboot"
continue=1
;;
4)
echo "Checking Nextion Driver Installation"
preparedir2
sudo /Nextion/check_installation.sh
echo "Sleeping 7 Seconds before re-starting the script"
sleep 7
sudo ./IND.sh
;;
5)
sudo wget https://database.radioid.net/static/user.csv --output-document=/usr/local/etc/stripped2.csv
Hostfilesupdate.sh
sudo ./IND.sh
;;
6)
echo "You chose to Remove the NextionDriver Configuration"
cleandriver
sudo ./IND.sh
;;
7)
echo "This function will install the Nextion Screen Support Files"
sudo ./gitcopy2.sh
sudo ./IND.sh
;;
8) echo " You Chose to Quit"
exit
;;
esac
clear
echo "Checking Nextion Driver Installation"
echo ""
preparedir2
sudo /Nextion/check_installation.sh
echo "Sleeping 3 seconds"
sleep 3
echo " "
sudo mount -o remount,rw /
sudo chmod 755 /usr/local/sbin/nextion*
sudo sed -i '/^\[/h;G;/Nextion]/s/\(Brightness=\).*/\199/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/Nextion]/s/\(IdleBrightness=\).*/\199/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/NextionDriver]/s/\(LogLevel=\).*/\12/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/Nextion]/s/\(Port=\).*/\1\/dev\/ttyNextionDriver/m;P;d' /etc/mmdvmhost
if [ -d /home/rock/ ]; then
tport="/dev/ttyAML0"
TOPort=$(echo "$tport" | sed "s/\//\\\\\//g")
echo "Setting NextionDriver Port to /dev/ttyAML0 for the RadXA Board"
sudo sed -i '/^\[/h;G;/NextionDriver]/s/\(Port=\).*/\1'"$TOPort"'/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/NextionDriver]/s/\(WaitForLan=\).*/\11/m;P;d' /etc/mmdvmhost
else
tport="/dev/ttyUSB0"
TOPort=$(echo "$tport" | sed "s/\//\\\\\//g")
echo "Setting NextionDriver Port to /dev/ttyUSB0 for Pi-Star"
sudo sed -i '/^\[/h;G;/NextionDriver]/s/\(Port=\).*/\1'"$TOPort"'/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/NextionDriver]/s/\(WaitForLan=\).*/\11/m;P;d' /etc/mmdvmhost
fi
echo "$TOPort"
sleep 2
TITLE="Second Level Menu - Continue"
MENU="Choose your Screen-to-Pi Interface"
OPTIONS=(1 "USB to TTL Interface"
2 "GPIO Pins"
3 "Quit")
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
sudo mount -o remount,rw /
case $CHOICE in
1) echo "Setting the Port to TTL Adapter, and ScreenLayout to 4 ON7LDSHS LS "
sudo sed -i '/^\[/h;G;/Nextion]/s/\(Port=\).*/\1\/dev\/ttyNextionDriver/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/NextionDriver]/s/\(Port=\).*/\1\/dev\/ttyUSB0/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/Nextion/s/\(ScreenLayout=\).*/\14/m;P;d' /etc/mmdvmhost
# if using TTL_Adapter set WaitForLan=0 we do not need to wait for LAN if using USB for screen
sudo sed -i '/^\[/h;G;/NextionDriver/s/\(WaitForLan=\).*/\10/m;P;d' /etc/mmdvmhost
if [ -d /home/rock/ ]; then
tport="/dev/ttyAML0"
TOPort=$(echo "$tport" | sed "s/\//\\\\\//g")
echo "Setting NextionDriver Port to /dev/ttyAML0 for the RadXA Board"
sudo sed -i '/^\[/h;G;/NextionDriver]/s/\(Port=\).*/\1'"$TOPort"'/m;P;d' /etc/mmdvmhost
fi
sleep 3
;;
2)
echo "Setting the Ports to GPIO, ScreenLayout to 3 ON7LDSHS"
sudo sed -i '/^\[/h;G;/Nextion]/s/\(Port=\).*/\1\/dev\/ttyNextionDriver/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/NextionDriver]/s/\(Port=\).*/\1\/dev\/ttyAMA0/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/Nextion/s/\(ScreenLayout=\).*/\13/m;P;d' /etc/mmdvmhost
sleep 3
;;
3)
exit
;;
*) echo "invalid option $REPLY";;
esac
echo " "
m1=$(sudo sed -n '/^[ \t]*\[Nextion\]/,/\[/s/^[ \t]*DisplayTempInFahrenheit[^#; \t]*=[ \t]*//p' /etc/mmdvmhost)
sudo mount -o remount,rw /
if [ -z "$m1" ]; then
sudo mount -o remount,rw /
p1="/^\[Nextion\]/,/^\[/ { x; /^$/ !{ x; H }; /^$/ { x; h; }; d; }; x; /^\[Nextion\]/ "
p2=" { s/\(\n\+[^\n]*\)$/\nDisplayTempInFahrenheit=0\1/; p; x; p; x; d }; x"
sudo sed -i "$p1$p2" /etc/mmdvmhost
fi
#TITLE="Select Temperature Mode"
MENU="Select your Temperature Display Type"
OPTIONS=(1 "Fahrenheit"
2 "Celcius"
3 "Quit")
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
1)
echo "Fahrenheit Selected"
sudo sed -i '/^\[/h;G;/Nextion/s/\(DisplayTempInFahrenheit=\).*/\11/m;P;d' /etc/mmdvmhost
sleep 3
;;
2)
echo "Celcius Selected "
sudo sed -i '/^\[/h;G;/Nextion/s/\(DisplayTempInFahrenheit=\).*/\10/m;P;d' /etc/mmdvmhost
sleep 3
;;
3)
exit
;;
esac
sudo mount -o remount,rw /
if [ "$1" != "Bata" ]; then
# Clear all comment flags on Nextion Driver Block, DMRid lines
sudo sed '/DMRid/s/^#//g' -i /etc/mmdvmhost
#Reset DMRidx State and Country Fields
sudo sed -i '/^\[/h;G;/NextionDriver/s/\(DMRidX1=\).*/\15/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/NextionDriver/s/\(DMRidX2=\).*/\16/m;P;d' /etc/mmdvmhost
sudo sed -i '/^\[/h;G;/NextionDriver/s/\(^DMRidFile=\).*/\1stripped2.csv/m;P;d' /etc/mmdvmhost
fi
#Set UserDataMask Fields if not already there.
if grep -Fq SendUserDataMask /etc/mmdvmhost; then
echo "SendUserDataMask Found"
sudo sed -i '/^\[/h;G;/NextionDriver/s/\(^SendUserDataMask=\).*/\10b01011111/m;P;d' /etc/mmdvmhost
else
echo "Inserting SendUserDataMask"
sed -i '/^\[NextionDriver\]/a\SendUserDataMask=0b01011111' /etc/mmdvmhost
fi
echo "Installing BC"
sudo apt-get install bc
sudo mount -o remount,rw /
sudo mount -o remount,rw /
sudo rm -R /temp
sudo sh -c 'echo "iptables -A OUTPUT -p tcp --dport 5040 -j ACCEPT" > /root/ipv4.fw'
echo -e '\e[1;33m'
echo ""
if [ ! -f /etc/cron.daily/getstripped ]; then
echo "setting getstripped to run in daily crontab"
sudo cp /home/pi-star/Scripts/getstripped.sh /etc/cron.daily/getstripped
else
echo "getstripped found in /etc/cron.daily/"
echo "No Action Required!"
fi
echo ""
echo -e '\e[1;37m'
sleep 3
sudo pistar-firewall
#rm -R /Nextion
sudo mount -o remount,rw /
if [ -f /home/pi-star/ndis.txt ]; then
sudo rm /home/pi-star/ndis.txt
fi
sleep 3
#sudo wget https://database.radioid.net/static/user.csv --output-document=/usr/local/etc/stripped2.csv
sudo /home/pi-star/Scripts/getstripped.sh
echo "Nextion Driver Installation Completed"
echo "Auxiliary Function Installation Completed"
echo "Rebooting Pi-Star in 3 seconds"
sleep 5
echo -e '\e[1;40m'
clear
sleep 3
sudo reboot