-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitcopy2.sh
More file actions
executable file
·304 lines (238 loc) · 6.48 KB
/
gitcopy2.sh
File metadata and controls
executable file
·304 lines (238 loc) · 6.48 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
#!/bin/bash
#########################################################
# Nextion TFT Support for Nextion 2.4" #
# 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 2020-05-12 #
#########################################################
# Valid Screen Names for EA7KDO - NX3224K024, NX4832K035
# Valid Screen Names for VE3RD - NX3224K024
#if [[ $EUID -ne 0 ]]; then
# clear
# echo ""
# echo "This script must be run as root"
# echo "Setting root user"
# echo "Re-Start Script"
# echo ""
# sudo su
# exit 1
#fi
p1=$(pwd) ; cd .. ; homedir=$(pwd) ; cd "$p1"
who=$(whoami)
echo "This script is running as $who user"
sleep 2
run=""
errtext="This is a test"
parm1="$1"
parm2="$2"
ver="20220124"
declare -i tst
export NCURSES_NO_UTF8_ACS=1
export LANG=en_US.UTF-8
if [ ! -f ~/.dialog ]; then
# j=1
# else
sudo dialog --create-rc ~/.dialogrc
fi
sudo sed -i '/use_colors = /c\use_colors = ON' ~/.dialogrc
sudo sed -i '/screen_color = /c\screen_color = (WHITE,BLUE,ON)' ~/.dialogrc
sudo sed -i '/title_color = /c\title_color = (YELLOW,RED,ON)' ~/.dialogrc
echo -e '\e[1;44m'
if [ -z "$1" ]; then
clear
fi
function exitcode
{
txt='Abort Function\n\n
This Script will Now Stop'"\n$errtext"
dialog --title " Programmed Exit " --ascii-lines --msgbox "$txt" 8 78
clear
echo -e '\e[1;40m'
run="Done"
exit
}
# EA7KDO Script Function
function getea7kdo
{
tst=0
# echo "Function EA7KDO"
calltxt="EA7KDO"
if [ -d "$homedir"/Nextion_Temp ]; then
sudo rm -R "$homedir"/Nextion_Temp
fi
if [ "$scn" == "NX3224K024" ]; then
sudo git clone --depth 1 https://github.com/EA7KDO/NX3224K024 "$homedir"/Nextion_Temp
tst=1
fi
if [ "$scn" == "NX4832K035" ]; then
sudo git clone --depth 1 https://github.com/EA7KDO/NX4832K035 "$homedir"/Nextion_Temp
tst=2
fi
}
# VE3RD Script Function
function getve3rd
{
if [ -d "$homedir"/Nextion_Temp ]; then
sudo rm -R "$homedir"/Nextion_Temp
fi
tst=0
# echo "Function VE3RD"
calltxt="VE3RD"
if [ "$scn" = "NX3224K024" ]; then
tst=1
sudo git clone --depth 1 https://github.com/VE3RD/Nextion "$homedir"/Nextion_Temp
elif [ "$scn" == "NX4832K035" ]; then
sudo git clone --depth 1 https://github.com/VE3RD/NX4832K035 "$homedir"/Nextion_Temp
tst=2
else
errtext="Invalid VE3RD Screen Name $scn, $s1, $s2"
exitcode
fi
}
function getcall
{
#Set Screen Author
calltxt=""
if [ "$parm2" == VE3RD ] || [ "$parm1" == VE3RD ] ; then
calltxt="VE3RD"
else
calltxt="EA7KDO"
fi
}
#### Start of Main Code
## Select User Screens
getcall
S1=""
S2=""
if [ -f "/usr/local/etc/NX4832K035.tft" ]; then
S1="NX4832K035"
S1A=" Available "
else
S1="NX4832K035"
S1A=" Not Available "
fi
if [ -f "/usr/local/etc/NX3224K024.tft" ]; then
S2="NX3224K024"
S2A=" Available "
else
S2="NX3224K024"
S2A=" Not Available "
fi
result=(dialog --backtitle "Screen Selector - $calltxt" --ascii-lines --menu "Choose Your $calltxt Nextion Screen Model" 22 76 16)
options=(1 "$S1A 3.5 Inch Nextion Screen"
2 "$S2A 2.4 Inch Nextion Screen"
3 " Abort - Exit Script")
choices=$("${result[@]}" "${options[@]}" 2>&1 >/dev/tty)
#errt="$?"
clear
echo "Choice = $choices"
if [ -z "$choices" ]; then
#if [ "$choices" != "1" ] || [ "$choices" != "2" ] || [ "$choices" != "3" ]; then
errtext="Cancel Button Pressed"
exitcode
fi
for choice in $choices
do
case $choice in
1)
echo "$S1A 3.5 Inch Nextion Screen Selected"
scn="NX4832K035"
;;
2)
echo "$S2A 2.4 Inch Nextion Screen Selected"
scn="NX3224K024"
;;
3)
echo "Abort - Exit Script"
errtext="Abort Selected"
exitcode
;;
esac
done
if [ "$calltxt" == "VE3RD" ]; then
if [ "$result" == "NX3224K024" ]; then
#echo "Trap2"
scn="$result"
else
#echo "Trap3"
errtext=" Invalid Screen name for $calltxt"
fi
fi
echo "$scn $calltxt"
#echo " End Processing Parameters - $scn $calltxt"
#Start Duration Timer
start=$(date +%s.%N)
model="$scn"
tft='.tft'
#gz='.gz'
#Put Pi-Star file system in RW mode
sudo mount -o remount,rw / > /dev/null
sleep 1s
#Stop the cron service
sudo systemctl stop cron.service > /dev/null
#Test for "$homedir"/Nextion_Temp and remove it, if it exists
if [ -d "$homedir"/Nextion_Temp ]; then
sudo rm -R "$homedir"/Nextion_Temp
fi
# Get Nextion Screen/Scripts and support files from github
# Get EA7KDO File Set
if [ "$calltxt" == "EA7KDO" ]; then
echo "getting Screens for $calltxt"
getea7kdo
fi
# Get VE3RD File Set
if [ "$calltxt" == "VE3RD" ]; then
echo "Getting Screens for $calltxt"
getve3rd
fi
if [ ! -d /usr/local/etc/Nextion_Support ]; then
sudo mkdir /usr/local/etc/Nextion_Support
else
sudo rm -R /usr/local/etc/Nextion_Support
sudo mkdir /usr/local/etc/Nextion_Support
fi
sudo chmod +x "$homedir"/Nextion_Temp/*.sh
sudo rsync -avqru "$homedir"/Nextion_Temp/* /usr/local/etc/Nextion_Support/ --exclude=NX* --exclude=profiles.txt
sudo rsync -avqru "$homedir"/Scripts/stripped2.csv /usr/local/etc/
sudo mount -o remount,rw /
sudo wget https://database.radioid.net/static/user.csv -O /usr/local/etc/stripped.csv
if [ -f "$homedir"/Nextion_Temp/profiles.txt ]; then
if [ ! -f /usr/local/etc/Nextion_Support/profiles.txt ]; then
if [ "$fb" ]; then
txtn= "Replacing Missing Profiles.txt"
txt="$txt\n""$txtn"
fi
sudo cp "$homedir"/Nextion_Temp/profiles.txt /usr/local/etc/Nextion_Support/
fi
fi
model="$scn"
echo "Remove Existing $model$tft and copy in the new one"
txtn="Remove Existing $model$tft and copy in the new one"
txt="$txt""$txtn"
if [ -f /usr/local/etc/"$model$tft" ]; then
sudo rm /usr/local/etc/NX*K*.tft
fi
sudo cp "$homedir"/Nextion_Temp/"$model$tft" /usr/local/etc/
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 seconds" $duration`
txt="$calltxt Scripts Loaded: $execution_time"
#whiptail --title "$title" --msgbox "$txt" 8 90
dialog --title " $title " --ascii-lines --msgbox "$txt" 8 78
echo -e '\e[1;40m'
if [ -z "$1" ]; then
clear
fi
sudo mount -o remount,ro /
exit