-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
APP-MANAGER
executable file
·1461 lines (1223 loc) · 51.8 KB
/
APP-MANAGER
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
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
AMVERSION="9.3"
# Determine main repository and branch
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
AMBRANCH=$(basename "$AMREPO")
MODULES_SOURCE="$AMREPO/modules"
# Determine catalogue in use
export AMCATALOGUEMARKDOWNS="https://portable-linux-apps.github.io/apps"
export AMCATALOGUEICONS="https://portable-linux-apps.github.io/icons"
# Determine the name of this script and its working directory
export REALDIR="$PWD"
DIR="$( cd "$( dirname "$0" )" && pwd )"
CLI=$(basename "$0")
# Determine system architecture and current user
arch="$HOSTTYPE"
export ARCH="$arch"
# XDG Variables
export BINDIR="${XDG_BIN_HOME:-$HOME/.local/bin}"
export DATADIR="${XDG_DATA_HOME:-$HOME/.local/share}"
export CONFIGDIR="${XDG_CONFIG_HOME:-$HOME/.config}"
export CACHEDIR="${XDG_CACHE_HOME:-$HOME/.cache}"
export APPMANCONFIG="$CONFIGDIR/appman"
APPMANCONFIG="$CONFIGDIR/appman"
SCRIPTDIR="$(xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME")"
export SCRIPTDIR
# Colors
RED='\033[0;31m'
Gold='\033[0;33m'
Green='\033[0;32m'
LightBlue='\033[1;34m'
DIVIDING_LINE="-----------------------------------------------------------------------------"
# Prevent the use of "sudo" ("AM")
[ -n "$SUDO_COMMAND" ] && echo -e "\n Please do not use \"sudo\" to execute \"$CLI\", try again.\n" && exit 1
function _create_cache_dir() {
AMCACHEDIR="$CACHEDIR/$AMCLI"
mkdir -p "$AMCACHEDIR"
}
function _clean_amcachedir() {
[ "$AMCLI" = am ] && [ -d "$CACHEDIR"/am ] && rm -f "$CACHEDIR"/am/*
[ -d "$CACHEDIR"/appman ] && rm -f "$CACHEDIR"/appman/*
}
# Fit texts to an acceptable width
function _fit() {
fold -sw 77 | sed 's/^/ /g'
}
################################################################################
# AM/APPMAN
################################################################################
# "APPMAN" CORE VARIABLES AND FUNCTIONS
APPMAN_SETUP_MSG="Before proceeding with any task, where do you want to install apps?
SYNTAX: /FULLPATH/TO/DIRNAME
EXAMPLE: $HOME/My-apps
NOTE: Any spaces in the path will be replaced for dashes
NOTE: If no input is given then \"~/Applications\" will be used as default
if you wish to later change the location, first remove all the programs and then edit the \"$APPMANCONFIG/appman-config\" file."
function _appman_check() {
if [ ! -f "$APPMANCONFIG"/appman-config ]; then
echo "$DIVIDING_LINE"
[ "$AMCLI" = am ] && echo ">>> Configure AppMan" || echo ">>> Thank you for choosing AppMan!"
echo "$DIVIDING_LINE"
echo "$APPMAN_SETUP_MSG" | _fit
echo "$DIVIDING_LINE"
read -r -ep " Write the path or just press enter to use default:$(printf "\n\n ")" location
location="$(echo "$location" | sed 's/[ \t]/-/g; s|^\./||' 2>/dev/null)"
[ -z "$location" ] && location="$HOME/Applications"
if ! echo "$location" | grep "^/" >/dev/null 2>&1; then
location="$HOME/$location"
fi
if echo "$location" | grep "$BINDIR" >/dev/null 2>&1; then
echo "$DIVIDING_LINE"
echo " 💀 ERROR, you can't install applications in \"$BINDIR\""
echo " $BINDIR is normally used for executables, Please choose a different path and retry!"
echo "$DIVIDING_LINE"
exit 1
elif ! mkdir -p "$location" 2>/dev/null || [ ! -w "$location" ]; then
echo " 💀 ERROR: You don't have write access to $location or it is invalid"
exit 1
fi
mkdir -p "$APPMANCONFIG" || exit 1
echo "${location%/}" > "$APPMANCONFIG"/appman-config || exit 1
echo "$DIVIDING_LINE"
echo " You are ready! Start installing your favorite apps locally!"
echo " All apps will be installed in $location"
echo " In case of problems, use the option \"-h\"."
echo "$DIVIDING_LINE"
fi
}
function _appman() {
_appman_check
if ! grep -q "^/" "$APPMANCONFIG"/appman-config; then
APPSDIR="$HOME/$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null)"
else
APPSDIR="$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null)"
fi
[ -n "$APPSDIR" ] && mkdir -p "$APPSDIR"/appman || exit 1
mkdir -p "$BINDIR" "$DATADIR"/applications "$DATADIR"/icons || exit 1
AMCLI="appman"
AMCLIPATH="$DIR/$AMCLI"
SUDOCMD=""
APPSPATH="$APPSDIR"
AMPATH="$APPSDIR/$AMCLI"
_create_cache_dir
if [ ! -w "$APPSPATH" ]; then
echo " ERROR: You don't have write access to $APPSPATH"
exit 1
elif ! echo "$PATH" | grep "$BINDIR" >/dev/null 2>&1; then
echo "$DIVIDING_LINE"
echo " ⚠️ WARNING: \"$BINDIR\" is not in PATH, apps may not run."
echo "$DIVIDING_LINE"
fi
MODULES_PATH="$AMPATH/modules"
mkdir -p "$MODULES_PATH" || exit 1
}
# "AM" CORE VARIABLES
function _am() {
AMCLI="am"
AMCLIPATH="$AMCLI"
if command -v sudo >/dev/null 2>&1; then
export SUDOCMD="sudo"
elif command -v doas >/dev/null 2>&1; then
export SUDOCMD="doas"
else
echo 'ERROR: No sudo or doas found'
exit 1
fi
APPSPATH="/opt"
AMPATH="$APPSPATH/$AMCLI"
_create_cache_dir
MODULES_PATH="$AMPATH/modules"
}
# DETERMINE WHEN TO USE "AM" OR "APPMAN"
if [ "$(realpath "$0")" = "/opt/am/APP-MANAGER" ]; then
_am
mkdir -p "$MODULES_PATH" || exit 1
elif [ "$(realpath "$0")" = "/usr/bin/am" ]; then
_am
AMPATH="$AMCACHEDIR"
MODULES_PATH="/usr/lib/am/modules"
else
_appman
fi
function _detect_appman_apps() {
[ -f "$APPMANCONFIG/appman-config" ] && APPMAN_APPSPATH=$(<"$APPMANCONFIG/appman-config")
if ! echo "$APPMAN_APPSPATH" | grep -q "^/"; then
[ -f "$APPMANCONFIG/appman-config" ] && APPMAN_APPSPATH="$HOME/$(<"$APPMANCONFIG/appman-config")"
fi
}
function _determine_args() {
ARGPATHS=$(find "$APPSPATH" -maxdepth 2 -name 'remove' -printf " %h\n" 2>/dev/null | sort -u | sed 's/ //g')
ARGS=$(echo "$ARGPATHS" | xargs -n 1 basename 2>/dev/null)
if [ "$AMCLI" = am ]; then
_detect_appman_apps
if [ -d "$APPMAN_APPSPATH" ]; then
APPMAN_PATHS=$(find "$APPMAN_APPSPATH" -maxdepth 2 -name 'remove' -printf " %h\n" 2>/dev/null | sort -u | sed 's/ //g')
ARGPATHS=$(echo -e "$ARGPATHS\n$APPMAN_PATHS")
ARGS=$(echo "$ARGPATHS" | xargs -n 1 basename 2>/dev/null)
fi
fi
# use "argpath=$(echo "$ARGPATHS" | grep "/$arg$")" to determine the full path of "arg"
}
function _icon_theme_export_to_datadir() {
PNG="$(file "$APPSPATH"/*/icons/* | grep -i '.png' | awk -F":" '{print $1}' | grep -vi .png)"
SVG="$(file "$APPSPATH"/*/icons/* | grep -i '.svg' | awk -F":" '{print $1}' | grep -vi .svg)"
for file in $PNG; do ln -s "$file" "${file}".png; done
for file in $SVG; do ln -s "$file" "${file}".svg; done
if [ -n "$APPMAN_APPSPATH" ]; then
PNG="$(file "$APPMAN_APPSPATH"/*/icons/* | grep -i '.png' | awk -F":" '{print $1}' | grep -vi .png)"
SVG="$(file "$APPMAN_APPSPATH"/*/icons/* | grep -i '.svg' | awk -F":" '{print $1}' | grep -vi .svg)"
for file in $PNG; do ln -s "$file" "${file}".png; done
for file in $SVG; do ln -s "$file" "${file}".svg; done
fi
mkdir -p "$DATADIR"/icons/hicolor/scalable/apps
find "$DATADIR"/icons/hicolor/scalable/apps -xtype l -exec rm {} \;
ln -s "$APPSPATH"/*/icons/*.* "$DATADIR"/icons/hicolor/scalable/apps
[ -n "$APPMAN_APPSPATH" ] && ln -s "$APPMAN_APPSPATH"/*/icons/*.* "$DATADIR"/icons/hicolor/scalable/apps
}
################################################################################
# FINALIZE
################################################################################
AMCLIUPPER=$(echo "$AMCLI" | tr '[:lower:]' '[:upper:]')
# Create new data directory and move important files there
AMDATADIR="$DATADIR/AM"
mkdir -p "$AMDATADIR"
# DEVELOPER MODE
if test -f "$AMDATADIR"/betatester; then
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/dev"
AMBRANCH=$(basename "$AMREPO")
MODULES_SOURCE="$AMREPO/modules"
fi
function _betatester_message_on() {
[ -f "$AMDATADIR"/betatester ] \
&& echo -e "$DIVIDING_LINE\n\"$AMCLIUPPER\" $AMVERSION: DEVELOPER MODE\n$DIVIDING_LINE"
}
# Apps database in use
APPSDB="$AMREPO/programs/$arch"
APPSLISTDB="$AMREPO/programs/$arch-apps"
################################################################################
# SECURITY
################################################################################
# SAFETY CHECKS
function _am_dependences_check() {
# Check for essential commands required by the application
missing_deps=()
AMDEPENDENCES="cat chmod chown curl grep less sed wget"
for name in $AMDEPENDENCES; do
if ! command -v "$name" &>/dev/null; then
missing_deps+=("$name")
fi
done
# Exit if any essential command is missing
if [ -n "$missing_deps" ]; then
echo "$DIVIDING_LINE"
printf " ${RED}💀 ERROR! MISSING ESSENTIAL COMMANDS\033[0m: %s\n\n Install the above and try again! \n" "${missing_deps[*]}"
echo -e "$DIVIDING_LINE\n ${Green}List of the $AMCLIUPPER $AMVERSION core dependences\033[0m:\n"
echo "$AMDEPENDENCES" | tr ' ' ',' | sed 's/,/, /g' | sed 's/^/ /g'
echo -e "\n$DIVIDING_LINE"
echo " If this message appears it is because you are missing some dependency"
echo " and if its the first time its because something new has been introduced."
echo -e "\n See ${LightBlue}https://github.com/ivan-hc/AM#core-dependences\033[0m for more information\n$DIVIDING_LINE"
exit 1
fi
}
function _check_ubuntu_mess() {
if ! unshare --user -p /bin/true >/dev/null 2>&1; then
echo "$DIVIDING_LINE"
echo ""
echo -e " ${RED}⚠️ WARNING: ACCESS TO USER NAMESPACES IS RESTRICTED! \033[0m"
echo ""
echo " Some apps may not run, you need to enable access to user namespaces,"
echo -e " please visit ${LightBlue}https://github.com/ivan-hc/AM#ubuntu-mess\033[0m to know more."
echo ""
echo "$DIVIDING_LINE"
fi
}
_am_dependences_check
_check_ubuntu_mess
# Function to check online connections (uses github.com by default, as the database and CLI itself are stored/hosted there)
function _online_check() {
if ! wget -q --tries=10 --timeout=20 --spider https://github.com; then
echo -e "\n $AMCLI is offline, please check your internet connection and try again\n"
exit 0
fi
}
# BLACKLIST FILES
appimagelauncher_msg="Your installation of AppImageLauncher may have been done via DEB, RPM, or AUR, which interrupts the \
natural operation of \"systemd-binfmt\" in addition to launching the aforementioned daemon. To avoid problems with \"$AMCLIUPPER\" \
and any other AppImages helper, it's preferable to use \"only\" the standalone AppImage of AppImageLauncher, whose official \
updated release can also be installed via \"$AMCLIUPPER\". But as long as you have the currently installed version, you can't use this CLI."
function _blacklisted_file() {
echo ""
echo -e " ${RED}💀WARNING! Detected \"$blacklisted_file\"\033[0m"
echo ""
echo "It will prevent \"$AMCLIUPPER\" from working correctly with AppImages, especially when extracting, integrating and updating them." | _fit
echo ""
if echo "$blacklisted_file" | grep -q appimagelauncherd; then
echo "$appimagelauncher_msg" | _fit
echo "" && echo " Please remove \"AppImageLauncher\", reboot and retry!"
else
echo " Please remove \"$blacklisted_file\", reboot and retry!"
fi
echo ""
exit 0
}
if command -v appimaged &>/dev/null; then
blacklisted_file=$(command -v appimaged)
_blacklisted_file
elif command -v appimagelauncherd &>/dev/null; then
blacklisted_file=$(command -v appimagelauncherd)
_blacklisted_file
fi
################################################################################
# 3RD PARTY
################################################################################
function _use_newrepo() {
[ -z "$2" ] && echo " USAGE: $AMCLI $1 [ARGUMENT]" && exit 1
case $2 in
'add')
[ -z "$3" ] && echo -e " USAGE: $AMCLI $1 $2 /path/to/dir\n $AMCLI $1 $2 {URL}" && exit 1
echo "$3" >> "$AMDATADIR/newrepo-lists"
;;
'enable'|'on')
[ ! -f "$AMDATADIR/newrepo-lists" ] && echo " ERROR, \"$AMDATADIR/newrepo-lists\" file not found" && exit 1
[ -f "$AMDATADIR/newrepo-off" ] && mv "$AMDATADIR/newrepo-off" "$AMDATADIR/newrepo-on" && echo " New repo ON!"
;;
'disable'|'off')
[ ! -f "$AMDATADIR/newrepo-lists" ] && echo " ERROR, \"$AMDATADIR/newrepo-lists\" file not found" && exit 1
[ -f "$AMDATADIR/newrepo-on" ] && mv "$AMDATADIR/newrepo-on" "$AMDATADIR/newrepo-off" && echo " New repo OFF!"
;;
'info')
echo -e " Source: $AMREPO\n Apps: $APPSDB\n List: $APPSLISTDB"
;;
'purge')
[ -f "$AMDATADIR/newrepo-lists" ] && rm -f "$AMDATADIR"/newrepo* && echo " Removed all 3rd party repositories"
;;
'select')
[ ! -f "$AMDATADIR/newrepo-lists" ] && echo " ERROR, \"$AMDATADIR/newrepo-lists\" file not found" && exit 1
echo -e "Select a repo from the list or press CTRL+C to abort:\n$DIVIDING_LINE\n"; sleep 1
select repo in $(sort -u "$AMDATADIR/newrepo-lists" | uniq); do
test -n "$repo" && break
echo ">>> Invalid Selection"
done
echo "$repo" > "$AMDATADIR/newrepo-on"
;;
esac
}
# 3RD PARTY DATABASES
function _am_newrepo_check() {
# Determine if the CLI uses the "main" branch of https://github.com/ivan-hc/AM or an alternative one
if [ -f "$AMDATADIR/newrepo-on" ]; then
if grep -q "^http" "$AMDATADIR/newrepo-on"; then
AMREPO=$(<"$AMDATADIR/newrepo-on")
elif grep -q "^/" "$AMDATADIR/newrepo-on"; then
AMREPO="file://$(<"$AMDATADIR/newrepo-on")"
fi
AMBRANCH=$(basename "$AMREPO")
export APPSDB="$AMREPO/programs/$arch"
export APPSLISTDB="$AMREPO/programs/$arch-apps"
export MODULES_PATH="$AMPATH/modules"
export AMCATALOGUEMARKDOWNS=""
export AMCATALOGUEICONS=""
[ "$1" != "newrepo" ] && [ "$1" != "neodb" ] && echo -e "$DIVIDING_LINE\n Source: $AMREPO\n$DIVIDING_LINE"
fi
}
_am_newrepo_check "$@"
# 3RD PARTY SOURCES
appbundle_repo="https://github.com/xplshn/AppBundleHUB"
appbundle_readme="https://raw.githubusercontent.com/xplshn/dbin-metadata/refs/heads/master/misc/cmd/AM-support/AM.txt"
toolpack_repo="https://github.com/Azathothas/Toolpacks"
toolpack_readme="https://bin.pkgforge.dev/${ARCH}/AM.txt"
export awk_name="1" awk_description="2" awk_site="3" awk_dl="4" awk_ver="5" # Numbers to use in "awk" to determine columns
################################################################################
# UTILITIES
################################################################################
# COMPLETION LIST
available_options="about add apikey backup clean config disable downgrade download enable extra files home icons info \
install install-appimage launcher list lock neodb newrepo nolibfuse off on overwrite purge query remove sandbox \
select sync template test unlock update --all --appimages --apps --byname --config --convert --debug \
--devmode-disable --devmode-enable --disable-notifications --enable-notifications --force-latest --home --icons \
-ias --launcher --less --pkg --rollback --disable-sandbox --sandbox --system --toolpack --user"
function _completion_lists() {
# Remove existing lists and download new ones
curl -Ls "$APPSLISTDB" > "$AMDATADIR/$arch-apps"
awk -v FS="(◆ | : )" '{print $2}' <"$AMDATADIR"/"$arch"-apps > "$AMDATADIR"/list
[ -f "$AMDATADIR"/"$ARCH"-appbundle ] && awk '{print $2}' "$AMDATADIR"/"$ARCH"-appbundle >> "$AMDATADIR"/list
[ -f "$AMDATADIR"/"$ARCH"-toolpack ] && awk '{print $2}' "$AMDATADIR"/"$ARCH"-toolpack | sed -e 's/$/.toolpack/' >> "$AMDATADIR"/list
# Append options to the list
for o in $available_options; do
echo "$o" >> "$AMDATADIR"/list
done
}
# BASH AND ZSH COMPLETION
completion_file="$DATADIR/bash-completion/completions/$AMCLI"
mkdir -p "$DATADIR/bash-completion/completions" || exit 1
[ -f "$HOME"/.bash_completion ] && sed -i "/ $AMCLI$/d" "$HOME"/.bash_completion
if ! grep -o " $AMCLI$" "$completion_file" >/dev/null 2>&1; then
echo "complete -W \"\$(cat $AMDATADIR/list 2>/dev/null)\" $AMCLI" >> "$completion_file"
if [ -f "${ZDOTDIR:-$HOME}"/.zshrc ] && echo "$SHELL" | grep -q "zsh"; then
cat <<-HEREDOC >> "${ZDOTDIR:-$HOME}"/.zshrc
autoload bashcompinit
bashcompinit
source "$completion_file"
HEREDOC
fi
echo "Shell completion has been enabled!"
fi
# VERSION OF THE INSTALLED APPS
# Filters
function _check_version_filters() {
sed -E "s/$arch|amd64|x86-64|x64|basic|standard|full|help|Qt[0-9]//g; s/-/\n/g; s/_/\n/g;" |\
grep -vi "appimage\|$arg\|?\|tar." | grep "[0-9]" | head -1 | sed 's/^v//g; s/^\.//g; s/\.$//g;'
}
function _check_version_grep_numbers() {
grep -Eo "([0-9]{1,}\.)+[0-9]{1,}" | head -1
}
# Versions
function _check_version_if_any_version_reference_is_somewhere() {
APPVERSION=$(grep -i "version=" "$argpath"/* 2>/dev/null | _check_version_grep_numbers)
}
function _check_version_if_version_file_exists() {
APPVERSION=$(sort "$argpath"/version | head -1 | sed 's:.*/::' | _check_version_filters)
if [ -z "$APPVERSION" ]; then
if grep -q "download$" "$argpath"/version; then
APPVERSION=$(sort "$argpath"/version | tr '/' '\n' | _check_version_filters)
elif grep -q "://" "$argpath"/version; then
APPVERSION=$(sort "$argpath"/version | tr '/' '\n' | _check_version_grep_numbers)
elif grep -q "/v[0-9]*" "$argpath"/version; then
APPVERSION=$(sort "$argpath"/version | tr '/' '\n' | grep "^v[0-9]" | head -1 | sed 's/^v//g')
elif [ "$(sort "$argpath"/version | wc -w)" = 1 ]; then
APPVERSION=$(sort "$argpath"/version | head -1)
fi
fi
if [ -z "$APPVERSION" ]; then
if grep -q "http.*download/.*[0-9].*/" "$argpath"/version; then
APPVERSION=$(sort "$argpath"/version | tr '/-' '\n' | grep "[0-9]" | _check_version_filters | tail -1)
fi
fi
}
function _check_version_if_an_updater_exists() {
APPVERSION=$("$argpath"/updater -d "$argpath"/"$arg" 2>/dev/null | grep -i "$arg" |\
_check_version_grep_numbers)
[ -z "$APPVERSION" ] && _check_version_if_any_version_reference_is_somewhere
}
function _check_version_if_library() {
LIBNAME=$(sort "$argpath"/remove | tr ' ' '\n' | grep "usr/local/lib" | head -1 | sed 's:.*/::')
APPVERSION=$(find /usr/local/lib -type f -name "$LIBNAME" -type f | sed 's:.*.so.::' | tail -1)
}
function _check_version_if_binary_in_place() {
APPVERSION=$(date -r "$argpath"/"$arg" "+%Y.%m.%d")
}
function _check_version() {
rm -f "$AMCACHEDIR"/version-args
_determine_args
for arg in $ARGS; do
argpath=$(echo "$ARGPATHS" | grep "/$arg$")
if test -f "$argpath"/remove 2>/dev/null; then
if test -f "$argpath"/version 2>/dev/null; then
_check_version_if_version_file_exists
elif test -f "$argpath"/updater 2>/dev/null; then
_check_version_if_an_updater_exists
elif [ "$arg" = "$AMCLI" ]; then
APPVERSION="$AMVERSION"
elif grep -qi "version=" "$argpath"/* 2>/dev/null; then
_check_version_if_any_version_reference_is_somewhere
elif echo "$arg" | grep -q "ffwa-"; then
APPVERSION="WebApp"
elif grep -q "usr/local/lib" "$argpath"/remove 2>/dev/null; then
_check_version_if_library
else
APPVERSION="unknown"
fi
if [ -z "$APPVERSION" ]; then
[ -f "$argpath"/"$arg" ] && _check_version_if_binary_in_place || APPVERSION="unknown"
fi
echo " ◆ $arg | $APPVERSION" >> "$AMCACHEDIR"/version-args
fi
done
}
function _check_version_for_auto_updatable_apps() {
_determine_args
for arg in $ARGS; do
argpath=$(echo "$ARGPATHS" | grep "/$arg$")
if test -f "$argpath"/updater 2>/dev/null; then
_check_version_if_an_updater_exists
OLDAPPVERSION=$(grep " ◆ $arg |" "$AMCACHEDIR"/version-args | tr '|' '\n' | sed 's/ //g' | head -2 | tail -1)
sed -i "/ ◆ $arg |/s#$OLDAPPVERSION#$APPVERSION#" "$AMCACHEDIR"/*
fi
done
}
if test -f "$AMCACHEDIR"/version-args; then
_check_version_for_auto_updatable_apps 2>/dev/null
fi
# This function removes all info and versions from the register
function _remove_info_files() {
rm -f "$AMCACHEDIR"/files*
rm -f "$AMCACHEDIR"/version-args
}
################################################################################
# APIKEY
################################################################################
ghapikey_file="$AMDATADIR/ghapikey.txt"
# Set header authorization if GitHub API key file exists
[ -f "$ghapikey_file" ] && HeaderAuthWithGITPAT=" --header \"Authorization: token $(<"$ghapikey_file")\" "
function _use_apikey() {
case $2 in
'del'|'delete'|'remove')
[ -f "$ghapikey_file" ] || { echo " ✖ No file named $ghapikey_file has been found"; exit 1; }
rm -f "$ghapikey_file" && echo " ✔ $ghapikey_file has been removed"
exit 0
esac
if [[ "$2" =~ ^(gh[ps]_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59})$ ]]; then
test_apikey_output_with_wget=$(curl -Ls --header "Authorization: token $2" 'https://api.github.com/repos/ivan-hc/AM/releases' | head -1)
[ -n "$test_apikey_output_with_wget" ] && echo "$2" > "$ghapikey_file" \
&& echo "Validation successful!" || echo "ERROR: This is not a valid key!"
else
echo "ERROR: Wrong expression, validation failed!"
fi
}
function _update_github_api_key_in_the_updater_files() {
if [ -f "$ghapikey_file" ]; then
ghapikey=$(<"$ghapikey_file")
updater_files=("$APPSPATH"/*/AM-updater) # Assuming AM-updater is one level deeper
for f in "${updater_files[@]}"; do
if [ -f "$f" ] && grep -q "https://api.github.com" "$f"; then
# Check if the file already contains a valid API key
if ! grep -qE "(gh[ps]_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59})" "$f"; then
# Insert HeaderAuthWithGITPAT before the GitHub API URL
sed -i "s#https://api.github.com#$HeaderAuthWithGITPAT https://api.github.com#g" "$f"
else
# Replace existing API key with the one from ghapikey.txt
sed -i "s#\(gh[ps]_[a-zA-Z0-9]\{36\}\|github_pat_[a-zA-Z0-9]\{22\}_[a-zA-Z0-9]\{59\}\)#$ghapikey#g" "$f"
fi
fi
done
fi
}
################################################################################
# APPMAN MODE
################################################################################
APPMAN_MSG="$DIVIDING_LINE\n \"AM\" is running as \"AppMan\", use ${Green}am --system\033[0m to switch it back to \"AM\"\n$DIVIDING_LINE"
APPMAN_MSG_OFF="$DIVIDING_LINE\n \"AppMan Mode\" disabled! \n$DIVIDING_LINE"
APPMAN_MSG_THINK="$DIVIDING_LINE\nNOTE: You can also choose to simply use \"--user\" as a flag to install apps locally \
(options \"-i\", \"-ia\" and \"-e\") instead of going fully into \"AppMan Mode\". \"AM\" can handle local applications as well.\n$DIVIDING_LINE"
function _use_appman() {
_online_check
[ "$CLI" = appman ] && echo " This function only works for AM" && exit 0
echo -e "$APPMAN_MSG_THINK" | _fit
read -r -p " Do you wish to enter \"AppMan Mode\" (y,N)?" yn
if ! echo "$yn" | grep -i '^y' >/dev/null 2>&1; then
echo "$DIVIDING_LINE"
else
[ ! -f "$APPMANCONFIG"/appman-mode ] && mkdir -p "$APPMANCONFIG" && touch "$APPMANCONFIG"/appman-mode
_appman && echo -e "$APPMAN_MSG"
fi
}
if [ "$AMCLI" = am ]; then
if test -f "$APPMANCONFIG"/appman-mode; then
[ ! -f "$APPMANCONFIG"/appman-config ] && echo -e "$APPMAN_MSG"
_appman
AMCLIPATH="$(realpath "$0")"
elif [ ! -w "$AMPATH" ]; then
read -r -p " \"AM\" is read-only, want to use it in \"AppMan Mode\" (Y,n)? " yn
if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then
exit 0
else
echo -e "$DIVIDING_LINE\n \"AppMan Mode\" enabled! \n$DIVIDING_LINE"
_use_appman 1>/dev/null
fi
fi
fi
################################################################################
# CLEAN
################################################################################
function _clean_amcachedir_message() {
_clean_amcachedir
[ "$AMCLI" = am ] && [ -d "$CACHEDIR"/am ] && echo " ✔ Clear the contents of $CACHEDIR/am"
[ -d "$CACHEDIR"/appman ] && echo " ✔ Clear the contents of $CACHEDIR/appman"
}
function _clean_all_home_cache_directories_of_appimages() {
for arg in $ARGPATHS; do
if test -d "$arg"/*.home/.cache; then
rm -Rf "$arg"/*/*.home/.cache/* && echo " ✔ Clear the contents of $arg/*.home/.cache"
fi
done
}
function _clean_all_tmp_directories_from_appspath() {
_determine_args
for arg in $ARGPATHS; do
if test -d "$arg"/tmp; then
rm -Rf "$arg"/tmp && echo " ✔ Removed $arg/tmp"
fi
done
}
function _clean_launchers() {
if test -d "$DATADIR"/applications/AppImages; then
rm -f "$AMCACHEDIR"/mountpoints
for var in "$DATADIR"/applications/AppImages/*.desktop; do
# full path to appimage
appimagename=$(awk -F'=| ' '/Exec=/{print $2; exit}' "$var" | sed 's/"//g; s/\s.*$//')
# name of the appimage
launcher2del=$(basename -- "$(echo "$appimagename" | tr '[:upper:]' '[:lower:]')")
# removable mount point where the appimage may be stored
mountpoint=$(echo "$appimagename" | cut -d'/' -f1-4)
if ! test -f "$appimagename"; then
if echo "$appimagename" | grep -q "^/media/\|^/mnt/"; then
mountpoint=$(echo "$appimagename" | cut -d'/' -f1-4)
unmounted_point=$(echo "$mountpoint" | cut -d'/' -f1-2)
elif echo "$appimagename" | grep -q "^/run/media/"; then
mountpoint=$(echo "$appimagename" | cut -d'/' -f1-5)
unmounted_point="/run/media"
else
mountpoint=""
fi
if [ -n "$mountpoint" ] && ! test -d "$mountpoint"; then
echo "$mountpoint" >> "$AMCACHEDIR"/mountpoints
echo " ✖ ERROR: cannot remove \"$(basename "$var")\""
echo " related AppImage is located in an unmounted path of $unmounted_point"
else
rm -f "$var"
[ -n "$BINDIR" ] && [ -n "$launcher2del" ] && rm -f "$BINDIR"/"$launcher2del"*
fi
fi
done
if test -f "$AMCACHEDIR"/mountpoints; then
mountpoints=$(sort "$AMCACHEDIR"/mountpoints)
for m in $mountpoints; do
[ ! -d "$m" ] && mountpoint_enabled=1
done
fi
[ -z "$mountpoint_enabled" ] && [ -n "$BINDIR" ] && cd "$BINDIR" && find . -xtype l -delete
rm -f "$AMCACHEDIR"/mountpoints
echo ' ✔ Removed orphaned launchers produced with the "--launcher" option'
rmdir "$DATADIR"/applications/AppImages
else
[ -n "$BINDIR" ] && cd "$BINDIR" && find . -xtype l -delete
fi
}
function _clean_old_modules() {
MODULES=$(sort "$(realpath "$0")" | tr '"' '\n' | grep "[a-z]\.am$" | uniq)
[ -z "$MODULES_PATH" ] && exit 1
for m in "$MODULES_PATH"/*; do
if [[ "${MODULES}" != *"$(basename -- "$m")"* ]];then
rm -f "$m" 2>/dev/null
echo " ✔ Removed obsolete module named \"$(basename -- "$m")\""
fi
done
}
function _use_clean() {
echo " Cleaning temporary files and folders..." && sleep 0.1
for i in {100..000}; do
echo -ne " $i\r" && sleep 0.0001
done
_detect_appman_apps
_determine_args
_clean_amcachedir_message
_clean_all_home_cache_directories_of_appimages
_clean_all_tmp_directories_from_appspath
_clean_launchers 2>/dev/null
_clean_old_modules
}
################################################################################
# SYNC
################################################################################
function _sync_installation_scripts() {
echo -e "$DIVIDING_LINE\n Checking for changes of the installation scripts in the online database..."
_determine_args
for arg in $ARGS; do
argpath=$(echo "$ARGPATHS" | grep "/$arg$")
if [ -f "$argpath"/AM-updater ]; then
mkdir -p "$argpath"/.am-installer
if test -f "$argpath/.am-installer"/*; then
scriptname=$(ls "$argpath/.am-installer/" | head -1)
CURRENT=$(cat "$argpath"/.am-installer/"$scriptname")
SOURCE=$(curl -Ls "$APPSDB"/"$scriptname")
if [ "$CURRENT" = "$SOURCE" ]; then
echo -ne "\r" 2>/dev/null
else
echo -e " ◆ Changed https://github.com/ivan-hc/AM/blob/main/programs/$arch/$scriptname"
fi
else
if curl --output /dev/null --silent --head --fail "$APPSDB"/"$arg" 1>/dev/null; then
echo -e " ◆ No installation script for $arg, downloading one..."
mkdir -p "$argpath"/.am-installer
wget -q "$APPSDB/$arg" -O "$argpath"/.am-installer/"$arg"
fi
fi
fi
done
}
function _sync_appimages_list() {
APPIMAGES_LIST="https://raw.githubusercontent.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/refs/heads/main/x86_64-appimages"
if [ "$ARCH" = x86_64 ]; then
curl -Ls "$APPIMAGES_LIST" > "$AMDATADIR/$ARCH-appimages"
else
rm -f "$AMDATADIR/$ARCH-appimages"
APPIMAGE_NAMES=$(curl -Ls "$APPIMAGES_LIST" | awk -v FS="(◆ | : )" '{print $2}')
for appimage in $APPIMAGE_NAMES; do
grep "◆ $appimage :" "$AMDATADIR/$ARCH-apps" >> "$AMDATADIR/$ARCH-appimages" &
done
wait
fi
}
function _sync_appbundle_list() {
rm -f "$AMDATADIR/$ARCH-appbundle"
curl -Ls "$appbundle_readme" | grep -v "\.appimage \|?" | grep "\.appbundle " | cut -d":" -f1 | cut -d"@" -f2 | sed 's/^| /◆ /g; s/ https$//g; s/ :$//g; s/ | / : /g; s/ |$/./g; s/\.\.$/./g;' | sort > "$AMDATADIR/$ARCH-appbundle"
}
function _sync_toolpacks_list() {
rm -f "$AMDATADIR/$ARCH-toolpack"
curl -Ls "$toolpack_readme" | grep -v "\.appimage \|.appbundle \|?" | cut -d":" -f1 | cut -d"@" -f2 | sed 's/^| /◆ /g; s/ | https$/. To install it use the "--toolpack" flag./g; s/ | / : /g' | sort > "$AMDATADIR/$ARCH-toolpack"
}
function _sync_third_party_lists() {
_sync_appbundle_list
_sync_toolpacks_list
}
function _sync_databases() {
echo -e "$DIVIDING_LINE\n Check and update offline lists of additional databases..."
_sync_appimages_list
_sync_third_party_lists
_completion_lists
}
function _sync_modules() {
echo -e "$DIVIDING_LINE\n Check for updates in modules..."
MODULES=$(curl -Ls "$AMREPO/APP-MANAGER" | tr '"' '\n' | grep "[a-z]\.am$")
for module_name in $MODULES; do
cd "$MODULES_PATH" || return 1
if ! test -f ./"$module_name"; then
echo " ◆ Downloading $module_name (not previously installed)..."
curl -Os "$MODULES_SOURCE/$module_name" 2>/dev/null
chmod a+x ./"$MODULENAME"
fi
CURRENT=$(cat ./"$module_name" 2>/dev/null)
SOURCE=$(curl -Ls "$MODULES_SOURCE/$module_name")
if [ "$CURRENT" = "$SOURCE" ]; then
echo -ne "\r" 2>/dev/null
else
echo " ◆ Updating $module_name..."
curl -Ls "$MODULES_SOURCE/$module_name" > ./"$module_name" 2>/dev/null
fi
done
_clean_old_modules
}
function _sync_amcli() {
echo "$DIVIDING_LINE"
CURRENT_AM_VERSION="$AMVERSION"
echo -ne "\n ◆ SYNCHRONIZING \"$AMCLIUPPER\" VERSION \"$CURRENT_AM_VERSION\"...\r" && sleep 0.25
_clean_amcachedir 1>/dev/null
cd "$AMCACHEDIR" || return 1
curl -Ls "$AMREPO"/APP-MANAGER > ./APP-MANAGER && chmod a+x ./APP-MANAGER
echo y | mv ./APP-MANAGER "$(realpath "$0")"
NEW_AM_VERSION=$("$AMCLIPATH" -v)
if [ ! "$CURRENT_AM_VERSION" = "$NEW_AM_VERSION" ]; then
echo -ne " A new release of \"$AMCLIUPPER\" is available, please wait...\r"
echo " ◆ \"$AMCLIUPPER\" IS NOW UPDATED TO THE BRAND NEW \"$NEW_AM_VERSION\" VERSION!"
echo -e "\n Replacement of version \"$CURRENT_AM_VERSION\" currently in use, COMPLETED!"
echo -e "\n See https://github.com/ivan-hc/AM/commits/main\n"
else
echo " ◆ \"$AMCLIUPPER\" IS ALREADY UPDATED, CURRENT VERSION \"$CURRENT_AM_VERSION\""
echo -e "\n See https://github.com/ivan-hc/AM/commits/$AMBRANCH\n"
fi
}
function _use_sync() {
_online_check
_betatester_message_on
_sync_installation_scripts
_sync_databases
if [ "$(realpath "$0")" != "/usr/bin/am" ]; then
_sync_modules
_sync_amcli
fi
echo "$DIVIDING_LINE"
}
################################################################################
# UPDATE
################################################################################
function _update_updatable_apps_msg_head() {
printf " \"%b\" CAN MANAGE UPDATES FOR THE FOLLOWING PROGRAMS:\n%b\n\n" "$AMCLIUPPER" "$DIVIDING_LINE"
[ -f "$AMCACHEDIR/updatable-args-list" ] && grep "◆" "$AMCACHEDIR/updatable-args-list" | sort || echo " None"
printf "\n All self-updatable programs are excluded\n"
echo "$DIVIDING_LINE"
}
function _update_list_updatable_apps() {
_determine_args
_check_version
for arg in $ARGS; do
argpath=$(echo "$ARGPATHS" | grep "/$arg$")
if [ -d "$argpath" ]; then
if [ -f "$argpath/AM-updater" ]; then
app_version=$(grep -w " ◆ $arg |" "$AMCACHEDIR/version-args" | sed 's:.*| ::')
echo " ◆ $arg $app_version" >> "$AMCACHEDIR"/updatable-args-list
fi
fi
done
}
function _update_determine_apps_version_changes() {
[ -z "$debug_update" ] && echo "$DIVIDING_LINE"
if test -f "$AMCACHEDIR"/updatable-args-list; then
mv "$AMCACHEDIR"/updatable-args-list "$AMCACHEDIR"/updatable-args-list-old
_update_list_updatable_apps
OLDVER="$AMCACHEDIR/updatable-args-list-old"
NEWVER="$AMCACHEDIR/updatable-args-list"
if cmp --silent -- "$NEWVER" "$OLDVER"; then
echo ' Nothing to do here!'
else
echo -e " The following apps have been updated:\n"
diff --new-line-format="" --unchanged-line-format="" "$NEWVER" "$OLDVER"
echo ""
fi
else
echo ' No apps to update here!'
fi
}
function _update_run_updater() {
if grep -q "api.github.com" "$argpath"/AM-updater; then
GH_API_ALLOWED=$(curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/ivan-hc/AM/releases/latest | sed 's/[()",{} ]/\n/g' | grep "^ivan-hc" | head -1)
if [ -z "$GH_API_ALLOWED" ]; then
if command -v torsocks 1>/dev/null; then
if [ -z "$debug_update" ]; then
torsocks "$argpath"/AM-updater >/dev/null 2>&1
else
torsocks "$argpath"/AM-updater
fi
else
echo " ✖ $APPNAME cannot be updated, you have reached GitHub API limit. Install \"torsocks\" from your system package manager and retry!" \
| fold -sw 72 | sed 's/^/ /g; s/ ✖/✖/g'
fi
else
if [ -z "$debug_update" ]; then
"$argpath"/AM-updater >/dev/null 2>&1
else
"$argpath"/AM-updater
fi
fi
else
if [ -z "$debug_update" ]; then
"$argpath"/AM-updater >/dev/null 2>&1
else
"$argpath"/AM-updater
fi
fi
end=$(date +%s)
echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!"
[ -n "$debug_update" ] && echo "$DIVIDING_LINE"
}
function _update_app() {
APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]')
start=$(date +%s)
if [ -w "$argpath"/AM-updater ]; then
_update_run_updater &
else
echo " ✖ $APPNAME is read-only, cannot update it!"
fi
}
function _update_all_apps() {
for arg in $ARGS; do
argpath=$(echo "$ARGPATHS" | grep "/$arg$")
cd "$argpath" || exit 1
arg=$(printf '%s\n' "${PWD##*/}")
if test -f "$argpath"/AM-updater; then
_update_app
fi
done
wait
_update_determine_apps_version_changes
rm -Rf "$APPSPATH"/*/tmp
[ -d "$APPMAN_APPSPATH" ] && rm -Rf "$APPMAN_APPSPATH"/*/tmp
}
function _update_launchers_not_found_msg() {
MISSING_LAUNCHERS_MSG=" No launcher found."
printf "%b\n%b\n%b\n" "$DIVIDING_LINE" "$MISSING_LAUNCHERS_MSG" "$DIVIDING_LINE"
}
function _update_launchers() {
_clean_launchers 2>/dev/null 1>/dev/null
MISSING_LAUNCHERS_MSG="No launcher found, use option \"--launcher\" to create them."
[ ! -d "$DATADIR"/applications/AppImages ] && _update_launchers_not_found_msg && exit 0
[ -d "$DATADIR"/applications/AppImages ] && [ -z "$( ls -A "$DATADIR"/applications/AppImages )" ] && _update_launchers_not_found_msg && exit 0
if ! command -v appimageupdatetool 1>/dev/null; then
update_launchers_error_message=" 💀 ERROR! Missing command \"${RED}appimageupdatetool\033[0m\", install it and retry!"
printf "%b\n%b\n%b\n" "$DIVIDING_LINE" "$update_launchers_error_message" "$DIVIDING_LINE"
else
echo " ◆ Update local AppImages integrated manually"
for var in "$DATADIR"/applications/AppImages/*.desktop; do
appimage_full_path=$(awk -F'=| ' '/Exec=/{print $2; exit}' "$var" | sed 's/"//g; s/\s.*$//')
appimagename=$(basename -- "$appimage_full_path")
appimage_path=$(echo "$appimage_full_path" | sed -E 's|/[^/]+$|/|; s/\/*$//g')
printf "%b\n File: %b%b\033[0m\n Path: %b" "$DIVIDING_LINE" "${Green}" "$appimagename" "$appimage_path"
if ! test -f "$appimage_full_path"; then
echo "(unmounted)" | _fit
else
printf "\n\n"
appimageupdatetool -Or "$appimage_full_path"
fi
done
fi
}
function _use_update() {
_online_check
_update_github_api_key_in_the_updater_files
_clean_all_tmp_directories_from_appspath >/dev/null
ENTRIES="$(echo "$@" | cut -f2- -d ' ' | tr ' ' '\n' | grep -v -- "^-\|^$1$")"
FLAGS=$(echo "$@" | tr ' ' '\n' | grep -- "--" | tr '\n ' ' ')
if echo "$FLAGS" | grep -q -- "--debug"; then
debug_update="1"
fi
if [ -z "$ENTRIES" ]; then
_clean_amcachedir
_update_list_updatable_apps
printf "%b\n >> START OF ALL PROCESSES << \n%b\n" "$DIVIDING_LINE" "$DIVIDING_LINE"
if echo "$FLAGS" | grep -q -- "--apps"; then
_update_updatable_apps_msg_head
_update_all_apps
elif echo "$FLAGS" | grep -q -- "--launcher"; then
_update_launchers
else
_update_updatable_apps_msg_head
_update_all_apps
_use_sync
printf " >> END OF ALL PROCESSES << \n%b\n" "$DIVIDING_LINE"
sleep 0.2
exit 0
fi
printf "%b\n >> END OF ALL PROCESSES << \n%b\n" "$DIVIDING_LINE" "$DIVIDING_LINE"
sleep 0.2
exit 0
else
[ -n "$debug_update" ] && echo "$DIVIDING_LINE"
_determine_args
for arg in $ENTRIES; do
argpath=$(echo "$ARGPATHS" | grep "/$arg$")
if test -f "$argpath"/AM-updater; then
cd "$argpath" 2>/dev/null || exit 1
_update_app
else
UPDATERS=$(cd "$argpath" 2>/dev/null && find . -name "*update*" -print 2>/dev/null)
[ -n "$UPDATERS" ] && arg_autoupdatable=", it may have its update system"
echo " ✖ Cannot manage updates for \"$(echo "$arg" | tr '[:lower:]' '[:upper:]')\"$arg_autoupdatable"
fi
done
wait
exit 0
fi
}
function _use_force_latest() {
_online_check
_determine_args