-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIND42.sh
More file actions
executable file
·460 lines (370 loc) · 12.7 KB
/
IND42.sh
File metadata and controls
executable file
·460 lines (370 loc) · 12.7 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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
#!/bin/bash
############################################################
# This script will automate the process of #
# Installing the Nextion Driver #
# #
# VE3RD 2024/05/21 #
############################################################
set -o errexit
set -o pipefail
ver="20200512"
systemctl daemon-reload
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
echo -e '\e[1;44m'
clear
sudo mount -o remount,rw /
homedir=/home/pi-star/
echo " "
echo " NEW NEW NEW "
echo " The ON7LDS Nextion Screen Driver Version 1.25 is now in the Pi-Star Image"
echo " Vers 4,1,8, 4.2 and the Beta 4.3"
echo " Older versions will require you to run Option 7 Before Option 2"
echo " "
echo " If this is a fresh pi-star install - Select Option 1 - Update Pi-Star"
echo " This will do a pistar update before you proceed to step 2"
echo " Option 2 SHOULD do everything required to do a NORMAL NextionDriver Setup"
echo " "
echo " Option 7 will remove and re-install the Nextion Driver. Do this ONLY if the "
echo " Driver is causing problems OR You are prunning a Pre Version 4 version of pi-star"
sleep 1
echo " "
echo " "
read -n 1 -s -r -p "Press any key to Continue"
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
}
function SetTemp()
{
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
}
function SetHostName()
{
hn=$(cat /etc/hostname)
hostname $hn
}
############################## MAIN PROGRAM #################
if [ ! -d /temp ] ; then
sudo mkdir /temp
fi
SetHostName
HEIGHT=15
WIDTH=90
CHOICE_HEIGHT=10
BACKTITLE="This SCRIPT will Install the Nextion Driver, BC, and Firewall Rule - VE3RD $ver"
TITLE="Main Menu - Nextion Driver & Options Installation"
MENU="Select your Function Here - Note: Nextion Driver now in Pi-Star"
OPTIONS=(1 "Pi-Star Update - Required for New Install"
2 "Setup NextionDtiver, MMDVMHost and Install Auxiliary Components"
3 "Check Nextion Driver Installation"
4 "Update stripped.csv"
5 "Remove & Re-Install NextionDriver Configuration in /etc/mmdvmhost"
6 "Download & Install TGIFSPOT Nextion Screen Support Files"
7 "Remove and Re-Install ON7LDS Nextion Driver Binary"\
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"
sudo systemctl stop cron.service
sudo mount -o remount,rw /
sudo pistar-update
sudo ./IND42.sh
;;
2)
echo "Setup Nextion Configuration and Install TGIFSPOT Support"
continue=1
;;
3)
echo "Checking Nextion Driver Installation"
preparedir2
sudo /Nextion/check_installation.sh
echo "Sleeping 7 Seconds before re-staring the script"
sleep 7
sudo ./IND42.sh
;;
4)
sudo wget https://database.radioid.net/static/user.csv --output-document=/usr/local/etc/stripped.csv
# sudo rsync -avqru /home/pi-star/Nextion_Temp/stripped2.csv /usr/local/etc/
sudo ./IND42.sh
;;
5)
echo "You chose to Remove and ReInstall the NextionDriver Section"
# Remove Section
cleandriver
# Install section
sudo /Nextion/NextionDriver_ConvertConfig /etc/mmdvmhost
# 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
#Set UserDataMask Fields if not already there.
if grep -Fq SendUserDataMask /etc/mmdvmhost; then
echo "SendUserDataMask Found"
else
echo "Inserting SendUserDataMask"
sed -i '/^\[NextionDriver\]/a\SendUserDataMask=0b00011110' /etc/mmdvmhost
fi
sudo ./IND42.sh
;;
6)
if [ "$1" == "VE3RD" ]; then
echo "Installing the EA7KDO Nextion Support Files"
sudo ./gitcopy2.sh VE3RD
else
echo "Installing the EA7KDO Nextion Support Files"
sudo ./gitcopy2.sh
fi
sudo ./IND42.sh
;;
7)
echo "Removing and Re-Installing ON7LDS Nextion Driver"
installnxd
sudo ./IND42.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
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
fi
echo "$TOPort"
sleep 2
TITLE="Second Level Menue - 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 " "
SetTemp
#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 /
# 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
#Set UserDataMask Fields if not already there.
if grep -Fq SendUserDataMask /etc/mmdvmhost; then
echo "SendUserDataMask Found"
else
echo "Inserting SendUserDataMask"
sed -i '/^\[NextionDriver\]/a\SendUserDataMask=0b00011110' /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 cp /home/pi-star/Scripts/groups.txt /usr/local/etc/
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/stripped.csv
echo "Nextion Driver Installation Completed"
echo "Auxilliary Function Installation Completed"
echo "Rebooting Pi-Star in 3 seconds"
sleep 5
SetHostName
echo -e '\e[1;40m'
clear
sleep 3
sudo reboot