-
Notifications
You must be signed in to change notification settings - Fork 1
/
grm.func
519 lines (448 loc) · 17.8 KB
/
grm.func
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
#!/bin/bash
##################################################################################
# Copyright 2022 steadfasterX <steadfasterX |at| gmail - com>
# Copyright 2023 steadfasterX <steadfasterX |at| gmail - com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##################################################################################
## @file grm.func
## @brief The heart of GRM - all global functions
## @author steadfasterX <steadfasterX -AT- gmail -DOT- com>
## @date 2022
## @copyright Apache License 2.0
## @details GRM - [G]rapheneOS [R]epo [M]anager
##
## global functions
##
## include this with:
## source grm.func
#
##########################################################################
# doxygen copy templates:
#
# # @var
# # @brief
# # @showinitializer
# # @details
#
# # @fn F_NAME()
# # @brief ..
# # @param 1 ..
# # @return ..
# # @exception ..
# # @details ..
#
##########################################################################
VARS="${0%/*}/grm.vars"
source "$VARS"
[ $? -ne 0 ] && echo "$0 - ERROR: including $VARS" && exit 3
######################################################################################
# do not echo but write log entry
F_LOG(){
# takes 1 argument
# 1 => Message to log/echo (can handle \t and \n)
echo -e "$(date '+%F %T') - $1" >> $LOG
}; export -f F_LOG
# echo output and save it in a log as well
F_ELOG(){
# takes 1 argument
# 1 => Message to log/echo (can handle \t and \n)
echo -e "$(date '+%F %T'): $1" | tee -a $LOG
}; export -f F_ELOG
######################################################################################
# print a message
F_MSG(){ F_LOG "$FUNCNAME: started"
# takes 2 arguments
#
# 1 => box width
# 2 => message to show
# optional:
# 3 => free args
$FYAD --width=$1 --title="$YTITLE" --text "$2" $3
RET=$?
F_LOG "$2"
F_LOG "$FUNCNAME: ended"
echo $RET
}; export -f F_MSG
# print an error message
F_MSGE(){ F_LOG "$FUNCNAME: started"
# takes up to 3 arguments
#
# 1 => width
# 2 => message
#
# optional:
# 3 => yad stuff
$FYAD --width="$1" --title="$YTITLE - ERROR" --image="$SICONS/error.png" --text "ERROR:\n\n$2" $3 --button=Exit:0
RES=$?
F_LOG "ERROR: $2"
F_LOG $RES
echo $RES
}; export -f F_MSGE
# print an OK message
F_MSGOK(){ F_LOG "$FUNCNAME: started"
# takes up to 3 arguments
#
# 1 => width
# 2 => message
#
# optional:
# 3 => yad stuff
$FYAD --width="$1" --title="$YTITLE - SUCCESS" --image="$SICONS/ok_64x64.png" --text "\n$2" $3 --button=Close:0
RES=$?
F_LOG "$2"
F_LOG $RES
echo $RES
}; export -f F_MSGOK
# print a warning message
F_MSGW(){ F_LOG "$FUNCNAME: started"
# takes up to 3 arguments
#
# 1 => width
# 2 => message
#
# optional:
# 3 => yad stuff
$FYAD --width="$1" --title="$YTITLE - WARNING" --image="$SICONS/warning_64x64.png" --text "\n$2" $3 --button=Close:0
RES=$?
F_LOG "$2"
F_LOG $RES
echo $RES
}; export -f F_MSGW
# check errorcode + exit when not errorcode not as expected
F_ERR(){ F_LOG "$FUNCNAME: started"
# takes 2-4 arguments
#
# mandantory:
# 1 => the process initiating this function
# 2 => the errorcode (usually $? in your call)
# optional (4 requires at least an empty 3):
# 3 => the message to show
# 4 => the expected error code (if missing we expect 0)
# 5 => yad code for F_MSGE (requires at least emtpy 3 and 4)
CALLER=$1
ERRCODE=$2
MSG="$3"
EXPECTED=$4
YADSTUFF="$5"
[ -z "$EXPECTED" ] && EXPECTED=0
if [ -z "$CALLER" ]||[ -z "$ERRCODE" ];then
F_ELOG "Required argument missing in $FUNCNAME!"
F_EXIT $FUNCNAME 3
fi
if [ "$ERRCODE" != "$EXPECTED" ];then
F_ELOG "ERROR: $ERRCODE occurred in $CALLER (expected $EXPECTED, got $ERRCODE)"
[ ! -z "$MSG" ] && F_MSGE 800 "$MSG" "$YADSTUFF"
F_EXIT "${CALLER}->${FUNCNAME}" 4
else
echo "OK: $CALLER"
fi
}; export -f F_ERR
# exit properly
F_EXIT(){ F_LOG "$FUNCNAME: started"
# takes 3 arguments
# mandantory:
# 1 => the function or reason who calls the exit function
# 2 => the exitcode to be used
#
# optional:
# 3 => type: cleaning lock file (full) or just close (when not set)
EREASON=$1
ECODE=$2
ETYPE=$3
F_ELOG "EXIT: $EREASON with code $ECODE"
[ "$ETYPE" == "full" ] && rm -vf $LOCKFILE >> $LOG
exit $ECODE
F_LOG "$FUNCNAME: ended"
}; export -f F_EXIT
###############################################################################################
# about/support screen
F_ABOUT(){ F_LOG "$FUNCNAME: started"
# takes no args
$FYAD --image="$SICONS/grm_big.png" --title="$YTITLE - ABOUT" --width=800 --height=500 --fixed --text \
"\n <b>$TNAME is based on / Credits:</b>\n\t- <a href='https://sourceforge.net/projects/yad-dialog'>YAD</a> - without this no GUI\n\
\t- <a href='https://www.docker.com'>Docker</a> for the $TNAME docker releases\n\
\t\t-> <a href='https://github.com/phusion/baseimage-docker/'>Phusion</a> for the minimal Ubuntu container\n\
\t\t-> <a href='https://www.xquartz.org'>XQuartz</a> for using X on Mac\n\
\t\t-> <a href='https://sourceforge.net/projects/vcxsrv/'>VcXsrv</a> for using X on Windows\n\
\t\t-> <a href='https://docs.gtk.org/gtk3/broadway.html'>GTK project</a> for using $TNAME <b>without</b> X on Windows and Mac\n\
\t- the work by <a href='https://github.com/steadfasterX'>steadfasterX</a> so you can actually do what you can do with GRM ;) \n\n\
<b>Source code:</b>\n\
\t- <a href='https://github.com/sfX-Android/GRM'>$TNAME</a>\n\
\t- <a href='https://github.com/GrapheneOS/apps.grapheneos.org'>apps.grapheneos.org</a>\n\n\
<b>Support:</b>\n\
\t- [matrix]:\t<a href='https://matrix.to/#/#sfX_Android:matrix.org'>#sfX_Android:matrix.org</a>\n\
\t- Telegram:\t<a href='https://t.me/sfX_android'>sfX_android</a>\n\n\
<b>Images/Icons:</b>\n\
\t- The $TNAME logo is created by <a href='https://github.com/steadfasterX'>steadfasterX</a> and licensed under <a href='https://creativecommons.org/publicdomain/zero/1.0/'>CC0 1.0</a>\n\
\t- <a href='https://commons.wikimedia.org/wiki/File:Earth_clip_art.svg'>$TNAME logo</a> (modified in size + added several resized Package icons)\n \
\t- <a href='https://commons.wikimedia.org/wiki/File:Nuvola_apps_package.png'>Package</a> (modified in size)\n \
\t- <a href='https://commons.wikimedia.org/wiki/File:Nuvola_apps_kthememgr.png'>Package add</a> (modified in size)\n \
\t- <a href='https://commons.wikimedia.org/wiki/File:Nuvola_mimetypes_txt.png'>List packages/About</a> (modified in size + added several resized Package icons)\n \
\t- <a href='https://commons.wikimedia.org/wiki/File:Nuvola_apps_kghostview.png'>Log</a> (modified in size)\n" \
--button=Close:0
}; export -f F_ABOUT
# load dynamic variables
F_DYNVARS(){
source .dyn.vars
}; export -f F_DYNVARS
# Update everything!
F_UPDATE(){ F_LOG "$FUNCNAME: started"
# takes no arguments
#
CNT=0
for u in ${MYPATH},$MYGIT; do
CNT=$((CNT+1))
F_LOG "$FUNCNAME: updating ${u/,*} on branch ${u/*,} ..."
echo "${CNT}:5"
cd ${u/,*}
echo "${CNT}:10"
F_LOG "$FUNCNAME: git checkout:\n$($GIT checkout ${u/*,} 2>&1)"
F_LOG "$FUNCNAME: git pull:\n"
$GIT pull 2>&1 | tee -a $LOG | sed "s/^/${CNT}:#/g"
test ${PIPESTATUS[0]} -eq 0 && echo "${CNT}:100"
done | $FYAD --title="$YTITLE - UPDATING" --text="\n <b>Be patient while freshen up your installation...</b>\n (if a progress bar do NOT get to 100% a manual update is required)\n\n" --width 800 --multi-progress --bar="Main codebase":norm --button=Close
F_MSGW 600 "You must restart ROME if you have updated before the changes become active. " "--fixed"
F_LOG "$FUNCNAME: ended"
}; export -f F_UPDATE
# prepare remote repo
F_PREPARE(){ F_LOG "$FUNCNAME: started with this args: $@"
F_DYNVARS
CMD="rm $UPLPATH/*"
F_SSHCMD
SCPFILE=/tmp/$UPDATEEXEC
cat > $SCPFILE << _EOCMD
#!/bin/bash
cd $REPOPATH
./generate2.py $COMPRESSION >> $REMLOG 2>&1
ERR=\$?
if [ \$ERR -eq 0 ];then
echo "Updated repo successfully!" >> $REMLOG
else
echo "Error \$ERR occured while updating repo!" >> $REMLOG
fi
exit \$ERR
_EOCMD
chmod +x $SCPFILE
F_SCPFILE
F_LOG "$FUNCNAME: ended with $ERR"
}; export -f F_PREPARE
# will set any host key as valid so should be used once only on initial use
F_INIT(){
F_WAITBOX $FUNCNAME "initialize.."
KPID=$(cat /tmp/${FUNCNAME}_F_WAITBOX.pid)
ssh "$SSHARGS" -v -o 'StrictHostKeyChecking=no' -o 'IdentitiesOnly yes' -i $SSHKEY ${SSHUSER}@${REPOSERVER} true
[ $? -eq 0 ] && touch "$MYPATH/${TNAME}.init"
kill $KPID
}; export -f F_INIT
# run a SIMPLE remote command
F_SSHCMD(){ F_LOG "$FUNCNAME: started with this args: $@"
# requires CMD var to be set
[ -z "$CMD" ] && F_LOG "empty CMD var!!!!" && return 3
F_WAITBOX $FUNCNAME "running command $CMD on server"
KPID=$(cat /tmp/${FUNCNAME}_F_WAITBOX.pid)
ssh "$SSHARGS" -o 'IdentitiesOnly yes' -i $SSHKEY ${SSHUSER}@${REPOSERVER} "$CMD" 2>> $LOG # 2>&1
ERR=$?
kill $KPID
F_LOG "$FUNCNAME: ended with $ERR"
return $ERR
}; export -f F_SSHCMD
# run a COMPLEX remote command
F_SCPEXEC(){ F_LOG "$FUNCNAME: started with this args: $@"
[ -z "$SCPFILE" ] && F_LOG "empty SCPFILE var!!!!" && return 3
chmod +x $SCPFILE
F_SCPFILE
CMD="${UPLPATH}/${SCPFILE##*/}"
F_SSHCMD
F_LOG "$FUNCNAME: ended with $ERR"
return $ERR
}; export -f F_SCPEXEC
# just scp a file without running it
F_SCPFILE(){ F_LOG "$FUNCNAME: started with this args: $@"
# requires SCPFILE var to be set
[ -z "$SCPFILE" ] && F_LOG "empty SCPFILE var!!!!" && return 3
scp "$SCPARGS" -p -o 'IdentitiesOnly yes' -i $SSHKEY $SCPFILE ${SSHUSER}@${REPOSERVER}:${UPLPATH}/ 2>&1 >> $LOG
ERR=$?
if [ "$ERR" -eq 0 ];then
F_LOG "$FUNCNAME: transferring $SCPFILE to $REPOSERVER was successful"
else
F_LOG "$FUNCNAME: Error $ERR occured while transferring $SCPFILE to $REPOSERVER"
fi
F_LOG "$FUNCNAME: ended with $ERR"
return $ERR
}; export -f F_SCPFILE
# fetch remote logs from repo server
F_FETCHLOG(){ F_LOG "$FUNCNAME: started with this args: $@"
[ -f /tmp/$TNAME.remote.log ] && rm /tmp/$TNAME.remote.log
scp "$SCPARGS" -p -o 'IdentitiesOnly yes' -i $SSHKEY ${SSHUSER}@${REPOSERVER}:${REMLOG} /tmp/$TNAME.remote.log 2>&1 >> $LOG
ERR=$?
if [ "$ERR" -eq 0 ];then
F_LOG "$FUNCNAME: fetching $TNAME.remote.log from $REPOSERVER was successful"
CMD="rm ${REMLOG}"
F_SSHCMD
cat /tmp/$TNAME.remote.log >> $LOG
else
F_LOG "$FUNCNAME: Error $ERR occured while fetching $TNAME.remote.log from $REPOSERVER"
fi
F_LOG "$FUNCNAME: ended with $ERR"
}; export -f F_FETCHLOG
# calc message length
F_MSGLEN(){
F_LOG "$FUNCNAME: started with $1"
MSG="$1"
MSGLENGTH=$((${#MSG} + 300))
F_LOG "$FUNCNAME: calculated a message length of: $MSGLENGTH"
echo $MSGLENGTH
F_LOG "$FUNCNAME: ended"
}; export -f F_MSGLEN
# wait dialog
F_WAITBOX(){
F_LOG "$FUNCNAME: started with $1, $2"
unset MSG CALLER
CALLER="$1"
MSG=$(echo "$2" | sed 's/[<>;$!&]//g')
MINLENGTH=$(F_MSGLEN "$TNAME v$VERSION")
MSGLENGTH=$(F_MSGLEN "$MSG")
[ "$MSGLENGTH" -lt "$MINLENGTH" ] && MSGLENGTH=$MINLENGTH
for i in $(seq 20 10000);do echo $i ; sleep 1; done | $FYAD --width=$MSGLENGTH --progress --auto-close --pulsate --hide-text --on-top --text "\n$MSG" &
WBPID=$!
F_LOG "$FUNCNAME: WBPID is $WBPID"
echo $WBPID > /tmp/${CALLER}_$FUNCNAME.pid
F_LOG "$FUNCNAME: ended"
}; export -f F_WAITBOX
# list all repo apps
F_LISTAPPS(){ F_LOG "$FUNCNAME: started with this args: $@"
# Takes no argument
unset FORMFIELDS
F_DYNVARS
F_WAITBOX $FUNCNAME "...parsing remote app repo on $REPOSERVER"
KPID=$(cat /tmp/${FUNCNAME}_F_WAITBOX.pid)
F_LOG "$FUNCNAME: PID is $KPID"
CMD="jq -r .time $REPOPATH/apps/metadata.$REPO_VER.json"
LTIME=$(F_SSHCMD)
RTIME=$(date --date @$LTIME)
SCPFILE="/tmp/cmd.sh"
cat > $SCPFILE << _EOFCMD
#!/bin/bash
[ ! -d "$REMLOGPATH" ] && mkdir -p $REMLOGPATH
# ensure the next for loop will not split unexpectedly
#saveIFS="\$IFS"
#IFS=';'
# FIXME: using IFS was not working, replacing spaces can break things but atm the way to go:
for p in \$(jq -c '.packages' $REPOPATH/apps/metadata.$REPO_VER.json | tr ' ' '_');do
echo "\$(date '+%F %T') - cmd.sh@${REPOSERVER}: parsing metadata for channel: $APPSTATE" >> $REMLOG
PKG_NAMES=\$(echo "\$p" | jq -r keys[])
for pkg in \$PKG_NAMES;do
for appver in \$( echo "\$p" | jq -c '.['\"\$pkg\"'].variants | map(select(.channel == "$APPSTATE"))' | tr ' ' '_');do
if [ "\$appver" == "[]" ]; then continue; fi
for aver in \$(echo "\$appver" | jq -c .[]); do
APPNAME=\$(echo "\$aver" | jq -r .label 2>> $REMLOG) && PKGVER=\$(echo "\$aver" | jq -r .versionName 2>> $REMLOG) && PKGVERCODE=\$(echo "\$aver" | jq -r .versionCode 2>> $REMLOG) && PKGNAME="\$pkg"
if [ \$? -eq 0 ];then
echo "\$APPNAME:\$PKGVER:\$PKGNAME/\$PKGVERCODE"
echo "\$(date '+%F %T') - cmd.sh@${REPOSERVER}: parsed metadata correctly for \$pkg -> \$APPNAME:\$PKGVER:\$PKGNAME/\$PKGVERCODE" >> $REMLOG
else
echo "\$(date '+%F %T') - cmd.sh@${REPOSERVER}: WARNING: could not parse metadata for \$pkg. This likely just means it has not a state of '$APPSTATE' and so can be safely ignored" >> $REMLOG
echo -e "\$(date '+%F %T') - cmd.sh@${REPOSERVER}: command was: jq -r '.packages.\"\$pkg\".variants' $REPOPATH/apps/metadata.$REPO_VER.json\n" >> $REMLOG
fi
done
done
done
done
#IFS="\$saveIFS"
_EOFCMD
ALLAPPS=$(F_SCPEXEC | tr -d " ")
kill $KPID
F_LOG "$FUNCNAME: ALLAPPS: $ALLAPPS"
# list all apps
for a in $(echo -e "$ALLAPPS" |sort); do
ANAME=$(echo "$a" | cut -d ':' -f 1)
AVERSION=$(echo "$a" | cut -d ':' -f 2)
APKG=$(echo "$a" | cut -d ':' -f 3)
LISTFIELDS="$LISTFIELDS false $ANAME $AVERSION $APKG"
done
F_LOG "$ALLAPPS, $LISTFIELDS"
RMAPPS=$($FYAD --height=500 --width=700 --search-column=2 --print-column=4 --text "\nThe following <b>$APPSTATE</b> apps are currently deployed on $REPOSERVER\nLast updated on: <b>$RTIME</b>\n" --list --checklist --column=Selection:CHK --column="App name:TXT" --column="App version:TXT" --column="PackagePath:HD" $LISTFIELDS --button=Close:0 --button="Remove Selected:10" | tr "\n" " " ; exit ${PIPESTATUS[0]})
ANS=$?
F_LOG "$FUNCNAME: closed with $ANS"
# remove apps if any selected
F_LOG "$FUNCNAME: Apps selected for removal: $RMAPPS"
[ ! -z "$RMAPPS" ] && [ "$ANS" -eq 10 ] && F_RMAPPS
F_LOG "$FUNCNAME: ended"
}; export -f F_LISTAPPS
# delete apps
F_RMAPPS(){ F_LOG "$FUNCNAME: started with this args: $@"
[ -z "$RMAPPS" ] && F_LOG "$FUNCNAME: empty RMAPPS var!!!!" && return 3
# prep orphan dir
CMD="[ ! -d $REPOPATH/deleted-apps/ ] && mkdir $REPOPATH/deleted-apps/"
F_SSHCMD
for app in $(echo "$RMAPPS" | tr "|" " ");do
CMD="cp -a $REPOPATH/apps/packages/$app $REPOPATH/deleted-apps/ && rm -rf $REPOPATH/apps/packages/$app"
F_SSHCMD
[ $ERR -ne 0 ] && F_LOG "$FUNCNAME: Error $ERR occured while uploading $apk" && F_MSGE 800 "Error $ERR occured while removing $app"
[ $ERR -ne 0 ] && return 3
done
F_ACTIVATE
F_LOG "$FUNCNAME: ended"
}; export -f F_RMAPPS
# add app
F_ADDAPP(){ F_LOG "$FUNCNAME: started with this args: $@"
SELAPK=$($FYAD --height=800 --width=800 --file --multiple --separator=" " --file-filter="APK|*.apk")
[ $? -ne 0 ] && return 3
F_PREPARE
for apk in $SELAPK;do
F_WAITBOX $FUNCNAME "... uploading to $REPOSERVER:\n\n\t${apk##*/}\n"
KPID=$(cat /tmp/${FUNCNAME}_F_WAITBOX.pid)
SCPFILE=$apk
F_SCPFILE
ERR=$?
kill $KPID
[ $ERR -ne 0 ] && F_LOG "$FUNCNAME: Error $ERR occured while uploading $apk" && F_MSGE 800 "Error $ERR occured while uploading:\n\n$apk"
[ $ERR -ne 0 ] && return 3
SCPFILE="/tmp/${apk##*/}.sh"
cat > $SCPFILE << _EOCMD
#!/bin/bash
set -e
cd $REPOPATH
./grm-import.py ${UPLPATH}/${apk##*/} $APPSRC $APPSTATE >> $REMLOG 2>&1 && rm ${UPLPATH}/${apk##*/} 2>> $REMLOG
_EOCMD
F_SCPEXEC
ERR=$?
[ $ERR -ne 0 ] && F_LOG "$FUNCNAME: Error $ERR occured while importing $apk" && F_MSGE 800 "Error $ERR occured while importing:\n\n$apk"
done
#F_MSGOK 500 "Successfully uploaded all APKs!"
F_ACTIVATE
F_LOG "$FUNCNAME: ended"
}; export -f F_ADDAPP
F_ACTIVATE(){ F_LOG "$FUNCNAME: started with this args: $@"
#F_WAITBOX $FUNCNAME "... activating APK changes on $REPOSERVER"
#KPID=$(cat /tmp/${FUNCNAME}_F_WAITBOX.pid)
# activate changes
CMD="${UPLPATH}/$UPDATEEXEC"
F_SSHCMD
ERR=$?
#kill $KPID
if [ $ERR -eq 0 ];then
F_MSGOK 400 "Repo update finished successfully!"
else
F_LOG "$FUNCNAME: Error $ERR occured while activating new APKs" && F_MSGE 800 "Error occured while activating repo changes! SHARE THE LOG!"
fi
F_LOG "$FUNCNAME: ended"
}; export -f F_ACTIVATE
# remove sensitive data from log before uploading
F_CLEANLOG(){ F_LOG "$FUNCNAME: started with this args: $@"
cp -v $LOG ${LOG}.paste >> $LOG 2>&1
for pat in $RMPATTERN;do
sed -i "s/$pat/REDACTED/g" ${LOG}.paste 2>> $LOG
done
F_LOG "$FUNCNAME: ended"
}; export -f F_CLEANLOG