-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgitcopy-orig.sh
More file actions
executable file
·423 lines (357 loc) · 12 KB
/
Copy pathgitcopy-orig.sh
File metadata and controls
executable file
·423 lines (357 loc) · 12 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
#!/bin/bash
#################################################################
# Nextion Screen Support for Nextion 2.4, 3.5 and 7.0" Screen #
# Gets all Scripts and support files from github #
# and copies them into the Nextion_Support directory #
# and copies the NX??? tft file into /usr/local/etc #
# and returns a script duration time to the Screen #
# as a script completion flag #
# #
# KF6S/VE3RD 2021-12-21 #
#################################################################
# Use screen model from command $1
# Valid Screen Names for EA7KDO - NX3224K024, NX4832K935
declare -i tst
if [ -z "$1" ]; then
clear
echo ""
echo " No Screen Name Provided"
echo
echo " Valid Screens - EA7KDO - NX3224K024, NX4832K035"
echo " "
echo " Syntax: gitcopy.sh NX????K??? // Will copy EA7KDO Files - Default for Screen"
echo " Adding a second parameter(anything) will provide feedback as the script runs (Commandline)"
echo " "
exit
fi
s1="NX3224K024"
s2="NX4832K035"
s3="NX8048K070"
s4="NX8048P070"
errtext="Error! - Aborting"
if [ "$2" == "Beta" ] || [ "$2" == "Upgrade" ]; then
Release="Upgrade"
else
Release="0"
fi
#echo "$2"
## Strip off .tft - Take only the first 10 characters
scn=$(echo "$1" | tr [:lower:] [:upper:])
#tr [:lower:] [:upper:]
scn="${scn:0:10}"
#Feed back is off by default - Turn it on with anything as parameter 3
fb="$3"
#Set Call to EA7KDO
calltxt="EA7KDO"
#echo "$scn"
#if [ -d /home/pi-star/Nextion_Temp ]; then
rm -f -r /home/pi-star/Nextion_Temp
#fi
function Logit
{
echo "$1" &>> /home/pi-star/gc.log
}
## Programmed Shutdown
function exitcode
{
echo "Script Execution Failed "
echo "$scn"
echo "$errtext"
exit
}
function cleandirs()
{
sudo rm -f -r /home/pi-star/Nextion_Temp
Logit "Removed /home/pi-star/Nextion_Temp Directory"
sudo rm -f /usr/local/etc/*.tft
Logit "Remove All Existing tft files"
}
# 7.0" DScreen Function
function NX80()
{
cleandirs
if [ "$scn" == "NX8048K070" ]; then
Logit "Loading NX8048K070 Screen and Scripts"
rm -f -r /home/pi-star/Nextion_Temp
Logit "Removeing /home/pi-star/Nextion_Temp"
sudo git clone --depth 1 https://github.com/TGIF-Network/NX8048K070-KDO-Beta /home/pi-star/Nextion_Temp
# sudo git clone --depth 1 https://github.com/TGIF-Network/NX8048K070-KDO-Upgrade /home/pi-star/Nextion_Temp
status="$?"
if [ "$status" -eq 0 ]; then
Logit "Git Clone OK"
else
Logit "Git Clone Failed"
exit
fi
if [ ! -f /home/pi-star/Nextion_Temp/NX8048K070.tft ]; then
echo "GitCopy Process Failed!"
Logit "GitCopy Process Failed!"
exit
else
Logit "Git Copy Process Found New NX8048K070.tft"
fi
fi
if [ "$scn" == "NX8048P070" ]; then
Logit "Loading NX8048P070 Screen and Scripts"
rm -f -r /home/pi-star/Nextion_Temp
Logit "Removeing /home/pi-star/Nextion_Temp"
sudo git clone --depth 1 https://github.com/TGIF-Network/NX8048P070-KDO-Beta /home/pi-star/Nextion_Temp
status="$?"
if [ "$status" -eq 0 ]; then
Logit "Git Clone OK"
else
Logit "Git Clone Failed"
exit
fi
if [ ! -f /home/pi-star/Nextion_Temp/NX8048P070.tft ]; then
echo "GitCopy Process Failed!"
Logit "GitCopy Process Failed!"
exit
else
Logit "Git Copy Process Found New NX8048P070.tft"
fi
fi
#Backup Nextion_Temp
if [ "$fb" ]; then
echo "Downloaded new EA7KDO Upgrade Screen package for $model$tft"
echo "Copied new tft to /usr/local/etc/"
fi
Logit "Made Backup Dir"
# Create Nextion_Support Directory
mkdir /usr/local/etc/Nextion_Support
# Ensure all scripts are ececutable
sudo chmod +x /home/pi-star/Nextion_Temp/*.sh
# Send required files to Nextion_Support
sudo rsync -qru /home/pi-star/Nextion_Temp/* /usr/local/etc/Nextion_Support/ --exclude=NX* --exclude=ColorThemes.ini --exclude=profiles.ini --exclude=wifiprofiles.ini
#Send .tft to /usr/local/etc/
sudo cp /home/pi-star/Nextion_Temp/"$model$tft" /usr/local/etc/
if [ "$fb" ]; then
echo "Downloaded new Screen package for $model$tft"
echo "Copied new tft to /usr/local/etc/"
fi
tst=2
# Send ColorThemes.ini to /etc if required
if [ ! -f /etc/ColorThemes.ini ] && [ -f /home/pi-star/Nextion_Temp/ColorThemes.ini ]; then
cp /home/pi-star/Nextion_Temp/ColorThemes.ini /etc/
if [ "$fb" ]; then
echo "Copied ColorThemes.ini to /etc/"
fi
else
if [ "$fb" ]; then
echo "ColorThemes.ini found in /etc/ - Not Copied"
fi
fi
# Send profiles.ini to /etc/ if required.
if [ ! -f /etc/profiles.ini ] && [ -f /home/pi-star/Nextion_Temp/profiles.ini ]; then
cp /home/pi-star/Nextion_Temp/profiles.ini /etc/
if [ "$fb" ]; then
echo "Copied profiles.ini to /etc/"
fi
else
if [ "$fb" ]; then
echo "profiles.ini found in /etc/ - Not Copied"
fi
fi
# Send wifiprofiles.ini to /etc/ if required.
if [ ! -f /etc/wifiprofiles.ini ] && [ -f /home/pi-star/Nextion_Temp/wifiprofiles.ini ]; then
cp /home/pi-star/Nextion_Temp/wifiprofiles.ini /etc/
if [ "$fb" ]; then
echo "Copied wifiprofiles.ini to /etc/"
fi
else
if [ "$fb" ]; then
echo "wifiprofiles.ini found in /etc/ - Not Copied"
fi
fi
}
function NX48()
{
tst=0
# echo "Function EA7KDO"
calltxt="EA7KDO"
if [ "$scn" == "NX3224K024" ]; then
cleandirs
sudo git clone --depth 1 https://github.com/TGIF-Network/NX3224K024-KDO /home/pi-star/Nextion_Temp
chmod +x /home/pi-star/Nextion_Temp/*.sh
#mkdir /usr/local/etc/Nextion_Support
sudo rsync -qru /home/pi-star/Nextion_Temp/* /usr/local/etc/Nextion_Support/ --exclude=NX* --exclude=ColorThemes.ini
sudo cp /home/pi-star/Nextion_Temp/"$model$tft" /usr/local/etc/
if [ "$fb" ]; then
echo "Downloaded new Screen package for $model$tft"
echo "Copied new tft to /usr/local/etc/"
fi
tst=1
fi
if [ "$scn" == "NX4832K035" ]; then
# cleandirs
if [ "$Release" == "Beta" ] || [ "$Release" == "Upgrade" ]; then
# First attempt to clone
Logit "First Attempt to Clone Files Starting"
cleandirs
sudo git clone --depth 1 https://github.com/TGIF-Network/NX4832K035-KDO-Beta /home/pi-star/Nextion_Temp
# sudo git clone --depth 1 https://github.com/TGIF-Network/NX4832K035-KDO-Upgrade /home/pi-star/Nextion_Temp
# if not found
if [ ! -f /home/pi-star/Nextion_Temp/NX4832K035.tft ]; then
Logit "First Attempt to Clone Files Failed"
# Second attempt to clone
Logit "Second Attempt to Clone Files Started"
cleandirs
sudo git clone --depth 1 https://github.com/TGIF-Network/NX4832K035-KDO-Beta /home/pi-star/Nextion_Temp
# sudo git clone --depth 1 https://github.com/TGIF-Network/NX4832K035-KDO-Upgrade /home/pi-star/Nextion_Temp
# Did it work
if [ ! -f /home/pi-star/Nextion_Temp/NX4832K035.tft ]; then
Logit "Second Attempt to Clone Files Failed"
# Third and last attempt to clone
Logit "Third Attempt to Clone Files Started"
cleandirs
sudo git clone --depth 1 https://github.com/TGIF-Network/NX4832K035-KDO-Beta /home/pi-star/Nextion_Temp
# sudo git clone --depth 1 https://github.com/TGIF-Network/NX4832K035-KDO-Upgrade /home/pi-star/Nextion_Temp
fi
else
Logit "First Attempt to Clone NX4832K035.tft File Found"
if [ -d /usr/local/etc/Nextion_Support ]; then
rm -r /usr/local/etc/Nextion_Support
Logit "Nextion_Support Directory Removed"
fi
fi
if [ ! -f /home/pi-star/Nextion_Temp/NX4832K035.tft ]; then
echo "GitCopy Process Failed!"
Logit "GitCopy Process Failed!"
exit
else
Logit "Git Copy Process Found New NX4832K035.tft"
fi
#Backup Nextion_Temp
if [ "$fb" ]; then
echo "Downloaded new EA7KDO Upgrade Screen package for $model$tft"
echo "Copied new tft to /usr/local/etc/"
fi
else
#Not Beta/Upgrade
sudo git clone --depth 1 https://github.com/TGIF-Network/NX4832K035-KDO /home/pi-star/Nextion_Temp
if [ "$fb" ]; then
echo "Downloaded EA7KDO Original Screen package for $model$tft"
echo "Copied new tft to /usr/local/etc/"
fi
if [ -f /home/pi-star/Nextion_Temp/NX4832K035.tft ]; then
rm -r -f /usr/local/etc/Nextion_Support
if [ "$fb" ]; then
echo "Nextion_Support Directory Removed"
fi
fi
fi
# Create Nextion_Support Directory
mkdir /usr/local/etc/Nextion_Support
# Ensure all scripts are ececutable
sudo chmod +x /home/pi-star/Nextion_Temp/*.sh
# Send required files to Nextion_Support
sudo rsync -qru /home/pi-star/Nextion_Temp/* /usr/local/etc/Nextion_Support/ --exclude=NX* --exclude=ColorThemes.ini --exclude=profiles.ini --exclude=wifiprofiles.ini
#Send .tft to /usr/local/etc/
sudo cp /home/pi-star/Nextion_Temp/"$model$tft" /usr/local/etc/
if [ "$fb" ]; then
echo "Downloaded new Screen package for $model$tft"
echo "Copied new tft to /usr/local/etc/"
fi
tst=2
# Send ColorThemes.ini to /etc if required
if [ ! -f /etc/ColorThemes.ini ] && [ -f /home/pi-star/Nextion_Temp/ColorThemes.ini ]; then
cp /home/pi-star/Nextion_Temp/ColorThemes.ini /etc/
if [ "$fb" ]; then
echo "Copied ColorThemes.ini to /etc/"
fi
else
if [ "$fb" ]; then
echo "ColorThemes.ini found in /etc/ - Not Copied"
fi
fi
# Send profiles.ini to /etc/ if required.
if [ ! -f /etc/profiles.ini ] && [ -f /home/pi-star/Nextion_Temp/profiles.ini ]; then
cp /home/pi-star/Nextion_Temp/profiles.ini /etc/
if [ "$fb" ]; then
echo "Copied profiles.ini to /etc/"
fi
else
if [ "$fb" ]; then
echo "profiles.ini found in /etc/ - Not Copied"
fi
fi
# Send wifiprofiles.ini to /etc/ if required.
if [ ! -f /etc/wifiprofiles.ini ] && [ -f /home/pi-star/Nextion_Temp/wifiprofiles.ini ]; then
cp /home/pi-star/Nextion_Temp/wifiprofiles.ini /etc/
if [ "$fb" ]; then
echo "Copied wifiprofiles.ini to /etc/"
fi
else
if [ "$fb" ]; then
echo "wifiprofiles.ini found in /etc/ - Not Copied"
fi
fi
fi
#####################################
###################################
if [ "$tst" == 0 ]; then
errtext="Invalid EA7KDO Screen Name $scn"
exitcode
fi
}
#### Start of Main Code ===================================================================
errt=$(date)
echo "$errt" > /home/pi-star/gc.log
#echo "$scn - $call"
if [ "$fb" ]; then
# if [ "$scn" != "$s1" -a "$scn" != "$s2" -a "$scn" != "$s3" -a "$scn" !- "$s4" ]; then
if [ "$scn" != "$s1" ] && [ "$scn" != "$s2" ] && [ "$scn" != "$s3" ] && [ "$scn" !- "$s4" ]; then
echo "EA7KDO Screen Name MUST be NX3224K024 or NX4832K035 or NX8048K070 or NX8048P070"
errtext="Invalid EA7KDO Screen Name"
exitcode
else
echo "Loading EA7KDO $scn Screen Package"
fi
fi
#echo " End Processing Parameters - $scn $call"
#Start Duration Timer
start=$(date +%s.%N)
#Disable all command feedback
if [ ! "$fb" ]; then
exec 3>&2
exec 2> /dev/null
fi
model="$scn"
tft='.tft'
#gz='.gz'
#Put Pi-Star file system in RW mode
sudo mount -o remount,rw /
sleep 1s
#Stop the cron service
sudo systemctl stop cron.service > /dev/null
#echo "Loading Scripts for $1"
if [ "$1" == "NX8048K070" ] || [ "$1" == "NX8048P070" ]; then
# echo "Loading NX80 scripts $1"
NX80
sudo /home/pi-star/Scripts/installND127.sh
if [ "$fb" ]; then
echo "Installed NextionDriver Version 1.27"
fi
else
#echo "Loading EA7KDO scripts $1"
NX48
fi
#exit
model="$scn"
FILE=/usr/local/etc/"$model$tft"
if [ ! -f "$FILE" ]; then
# Copy failed
echo "No TFT File Available to Flash - Try Again"
errtext="Missing tft File Parameter"
exitcode
fi
sudo systemctl start cron.service > /dev/null
duration=$(echo "$(date +%s.%N) - $start" | bc)
execution_time=`printf "%.2f secs" "$duration"`
if [ ! "$fb" ]; then
exec 2>&3
fi
tag=$(git -C /home/pi-star/Nextion_Temp/ tag)
# echo "$scn Ready $execution_time"
echo "$scn $tag Ready to Flash! $execution_time"
######## cat /home/pi-star/gc.log