-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIND.sh
More file actions
303 lines (250 loc) · 8.39 KB
/
Copy pathIND.sh
File metadata and controls
303 lines (250 loc) · 8.39 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
#!/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 /
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 Uppdate"
echo " This will do a pistar update before installing the Driver"
echo " "
echo " Selecting Start will install the driver witout 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 preparedir
{
if [ -d /Nextion ] ; then
sudo rm -R /Nextion
fi
sudo git clone https://github.com/on7lds/NextionDriverInstaller.git /Nextion/
}
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
}
if [ ! -d /temp ] ; then
sudo mkdir /temp
fi
HEIGHT=15
WIDTH=60
CHOICE_HEIGHT=7
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 Instllation"
5 "Update stripped.csv"
6 "Quit")
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
echo -e '\e[1;44m'
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-staring the script"
sleep 7
sudo ./IND.sh
;;
5)
sudo wget https://database.radioid.net/static/user.csv --output-document=/usr/local/etc/stripped.csv
exit
;;
6) echo " You Chose to Quit"
exit
;;
esac
clear
echo "Checking Nextion Driver Installation"
echo ""
preparedir2
sudo /Nextion/check_installation.sh
echo "Sleeping 5 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
echo " "
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
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 /
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'
sudo pistar-firewall
echo "Nextion Driver Installation Completed"
echo "Rebooting Pi-Star in 3 seconds"
#rm -R /Nextion
sudo mount -o remount,rw /
if [ -f /home/pi-star/ndis.txt ]; then
sudo rm /home/pi-star/ndis.txt
fi
echo -e '\e[1;40m'
clear
sleep 3
sudo reboot