forked from ivan-hc/AM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
APP-MANAGER
1767 lines (1461 loc) · 75.1 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
AMCLI="am"
AMCLIPATH=$AMCLI
SUDOCOMMAND="sudo"
APPSPATH="/opt"
AMPATH="$APPSPATH/$AMCLI"
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM-application-manager/main"
arch=$(printf '%s\n' "$HOSTTYPE")
currentuser=$(printf '%s\n' "$USER")
for name in "ar" "cat" "chmod" "chown" "curl" "grep" "sed" "tar" "unzip" "wget" "zsync"; do
test -x "$(command -v $name 2>/dev/null)" \
|| { printf "\n%s\n" "ERROR: $name not found, required by some installation scripts."; deps=1; };
done; [ "$deps" != "1" ] || { printf "\nInstall the above and try again\n\n"; exit 1; }
rm -rf "$AMPATH/options"
cat <<-HEREDOC >> "$AMPATH/options"
about
backup
clean
download
files
install
list
lock
overwrite
query
remove
sync
template
unlock
update
web
--disable-completion
--enable-completion
--home
--rollback
--user
HEREDOC
case "$1" in
'') printf "\n USAGE: '$AMCLI [option]'\n '$AMCLI [option] [argument]'\n\n Run the '$AMCLI -h' command to find out more\n\n";;
'-h'|'help') printf '
_____ _____
/\ \ /\ \
/::\ \ /::\____\
/::::\ \ /::::| |
/::::::\ \ /:::::| |
/:::/\:::\ \ /::::::| |
/:::/__\:::\ \ /:::/|::| |
/::::\ \:::\ \ /:::/ |::| |
/::::::\ \:::\ \ /:::/ |::|___|______
/:::/\:::\ \:::\ \ /:::/ |::::::::\ \
/:::/ \:::\ \:::\____\/:::/ |:::::::::\____\
\::/ \:::\ /:::/ /\::/ / ~~~~~/:::/ /
\/____/ \:::\/:::/ / \/____/ /:::/ /
\::::::/ / /:::/ /
\::::/ / /:::/ /
/:::/ / /:::/ /
/:::/ / /:::/ /
/:::/ / /:::/ /
/:::/ / /:::/ /
\::/ / \::/ /
\/____/ \/____/
▄▀█ █▀█ █▀█ █░░ █ █▀▀ ▄▀█ ▀█▀ █ █▀█ █▄░█ █▀▄▀█ ▄▀█ █▄░█ ▄▀█ █▀▀ █▀▀ █▀█
█▀█ █▀▀ █▀▀ █▄▄ █ █▄▄ █▀█ ░█░ █ █▄█ █░▀█ █░▀░█ █▀█ █░▀█ █▀█ █▄█ ██▄ █▀▄
by Ivan Alex HC
###########################################################################
>> The database of all AppImage packages and portable apps for GNU/Linux <<
###########################################################################
___________________________________________________________________________
USAGE:
'$AMCLI' {OPTION}
'$AMCLI' {OPTION} {PROGRAM}
___________________________________________________________________________
###########################################################################
___________________________________________________________________________
OPTIONS
(standard, for both "AM" AND "APPMAN")
___________________________________________________________________________
___________________________________________________________________________
-a, about
SYNOPSIS: -a {PROGRAM}
DESCRIPTION: Shows more info about one or more apps, all the pages are
downloaded from https://portable-linux-apps.github.io
___________________________________________________________________________
-b, backup
SYNOPSIS: -b {PROGRAM}
DESCRIPTION: Save the current version of one or more apps, each snapshot
is stored into a dedicated directory, under $HOME/.am-snapshots/$PROGRAM
To restore the snapshots see the "-o" option.
___________________________________________________________________________
-c, clean
SYNOPSIS: -c
DESCRIPTION: Removes all the unnecessary files and folders.
___________________________________________________________________________
-d, download
SYNOPSIS: -d {PROGRAM}
DESCRIPTION: Download one or more installation scripts to your desktop.
___________________________________________________________________________
-f, files
SYNOPSIS: -f
DESCRIPTION: Shows the list of all installed programs, with sizes.
___________________________________________________________________________
-h, help
SYNOPSIS: -h
DESCRIPTION: Prints this message.
___________________________________________________________________________
-H, --home
SYNOPSIS: -H {PROGRAM}
DESCRIPTION: Set a dedicated $HOME directory for one or more AppImages.
___________________________________________________________________________
-i, install
SYNOPSIS: -i {PROGRAM}
DESCRIPTION: Install one or more programs.
___________________________________________________________________________
-l, list
SYNOPSIS: -l
DESCRIPTION: Shows the list of all the apps available in the repository.
___________________________________________________________________________
-o, overwrite
SYNOPSIS: -o {PROGRAM}
DESCRIPTION: Overwrite the existing version of the app with a snapshot
saved previously (see the option "-b", above).
___________________________________________________________________________
-q, query
SYNOPSIS: -q {KEYWORD}
DESCRIPTION: Can be used to search for keywords and terms in the list of
available applications packages to display matches. This can be useful if
you are looking for applications having a specific feature.
___________________________________________________________________________
-r, remove
SYNOPSIS: -r {PROGRAM}
DESCRIPTION: Removes one or more apps, requires confirmation.
___________________________________________________________________________
-R
SYNOPSIS: -R {PROGRAM}
DESCRIPTION: Removes one or more apps without asking.
___________________________________________________________________________
-s, sync
SYNOPSIS: -s
DESCRIPTION: Updates this script to the latest version hosted.
___________________________________________________________________________
-t, template
SYNOPSIS: -t {PROGRAM}
DESCRIPTION: This option allows you to generate a custom script from a
list of different templates that may be vary according to the kind of app
you want to upload to the "AM" repo, and the source where it is available.
___________________________________________________________________________
-u, -U, update
SYNOPSIS: -u
-u {PROGRAM}
DESCRIPTION: Update all the apps or just one.
___________________________________________________________________________
-v, version
SYNOPSIS: -v
DESCRIPTION: Shows the version.
___________________________________________________________________________
-w, web
SYNOPSIS: -w
DESCRIPTION: Shows the URLs of the sites/sources of then app.
___________________________________________________________________________
--disable-completion
SYNOPSIS: --disable-completion
DESCRIPTION: Disable bash-completion.
___________________________________________________________________________
--enable-completion
SYNOPSIS: --enable-completion
DESCRIPTION: Enable bash-completion to complete a keyword with the "TAB"
key, using the names of all installable applications available.
___________________________________________________________________________
--rollback
SYNOPSIS: --rollback {PROGRAM}
DESCRIPTION: Download an older or specific version of the software you
are interested in (only works with Github).
___________________________________________________________________________
--user, appman
SYNOPSIS: --user
DESCRIPTION: Run "AM" as an unprivileged user making it act as "AppMan".
___________________________________________________________________________
lock
SYNOPSIS: lock {PROGRAM}
DESCRIPTION: Lock the selected app to the current version installed, this
only works if exists a dedicated "AM-updater" installed with the app.
___________________________________________________________________________
unlock
SYNOPSIS: unlock {PROGRAM}
DESCRIPTION: Unlock updates for the selected program. This option nulls
the option "lock" (see above).
___________________________________________________________________________
___________________________________________________________________________
EXTRA OPTIONS
(only available for "APPMAN")
___________________________________________________________________________
conv, convert
SYNOPSIS: conv {PROGRAM}
DESCRIPTION: Download the installation scripts for "AM" and converts them
to rootless installation scripts that can be installed locally.
___________________________________________________________________________
###########################################################################
___________________________________________________________________________
ABOUT "AM" APPLICATION MANAGER
___________________________________________________________________________
"AM" is a software manager that deals with the management of all portable
apps and AppImages out there. It is distributed in two versions:
◆ "AM", the main version that integrates applications at the system level,
installing them in /opt, for all the users;
◆ "AppMan", the portable and "rootless" version that installs all the apps
in the $HOME directory, integrating additional options to convert all the
installation scripts from "AM".
___________________________________________________________________________
SITES
___________________________________________________________________________
HTTPS://PORTABLE-LINUX-APPS.GITHUB.IO (main website)
HTTPS://GITHUB.COM/IVAN-HC/APPMAN
HTTPS://GITHUB.COM/IVAN-HC/AM-APPLICATION-MANAGER
___________________________________________________________________________
###########################################################################' | less;;
'-a'|'about')
if [ -n "$SUDO_COMMAND" ]; then
printf "\n WARNING: You don't need to run the option '$1' with SUDO.\n\n";
exit 1;
fi
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
while [ -n "$1" ]; do
rm -f "$AMPATH/.cache/about-args";
printf "%s\n" "$@" | tr ' ' '\n' >> "$AMPATH/.cache/about-args" && printf "STOP\n" >> "$AMPATH/.cache/about-args";
ARGS="$(tail -n +2 $AMPATH/.cache/about-args)"
for arg in $ARGS; do
for var in "$arg"; do
if [ "$arg" == "STOP" ]; then
exit 1;
else
markdown="https://raw.githubusercontent.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/main/apps/$arg.md"
if curl -o /dev/null -sIf "$markdown" 1>/dev/null; then
printf "%s\n" "-----------------------------------------------------------------------"
case "$arg" in
*)
rm -rf "$AMPATH/.cache/about";
mkdir -p "$AMPATH/.cache/about";
cd "$AMPATH/.cache/about" && wget -q "$markdown" &&
sed -i '1,${ /^\s*#/ d; /^\s*!/ d; /\[Applications]/d; /\ --- /d; }' "$arg.md";
printf "%s\n" " PACKAGE: $(echo $arg | tr a-z A-Z)";
if test -f "$APPSPATH/$arg/remove"; then
printf "%s\n" " STATUS: INSTALLED, ABOUT $(du -sm $APPSPATH/$arg | cut -f1) MB OF DISK SPACE IN USE";
else
printf "%s\n" " STATUS: NOT INSTALLED";
fi
cat ./$arg.md && printf "%s\n" "-----------------------------------------------------------------------";
;;
esac
else
printf "%s\n" " \"$arg\" is not a valid argument" | tr 'a-z' 'A-Z' && break;
fi
fi
done
done
done
shift
;;
'-b'|'backup')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
while [ -n "$1" ]; do
rm -f $AMPATH/.cache/backup-args;
echo $@ | tr ' ' '\n' >> $AMPATH/.cache/backup-args && echo STOP >> $AMPATH/.cache/backup-args;
ARGS=$(tail -n +2 $AMPATH/.cache/backup-args)
for arg in $ARGS; do
for var in $arg; do
if [ $arg == STOP ]; then
exit
else
case $arg in
'')
echo " Specify the name of a program to back up"; echo ""; exit;;
*)
if test -f $APPSPATH/$arg/remove; then
echo ""; read -p " Do you wish to backup the current version of $arg (y,N)?" yn
case $yn in
[Yy]* )
mkdir -p "$(xdg-user-dir USER)/.am-snapshots/$arg"; cp -r $APPSPATH/$arg "$(xdg-user-dir USER)/.am-snapshots/$arg/$(date +%F-%X | sed 's/://g' | sed 's/-//g')"; echo ""; echo " SAVED in $(xdg-user-dir USER)/.am-snapshots/$arg"; echo "" ; break;;
[Nn]*|* )
echo ""; echo " OPERATION ABORTED!"; echo ""; break;;
esac
else
echo ""; echo " '$arg' is not a valid argument or is not installed."; echo ""; break;
fi
esac
fi
done
done
done
shift
;;
'-c'|'clean')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
echo -e "\n Cleaning of temporary files and folders in progress...\n" && sleep 0.1 &&
for i in {1000..0000}; do
echo -ne " $i\r" && sleep 0.0001;
done
rm -R -f $AMPATH/appdb; rm -R -f $AMPATH/.cache/*; rm -R -f $APPSPATH/*/tmp; echo -e "\n DONE!\n"
;;
'-d'|'download')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
while [ -n "$1" ]; do
rm -f $AMPATH/.cache/download-args
echo $@ | tr ' ' '\n' >> $AMPATH/.cache/download-args && echo STOP >> $AMPATH/.cache/download-args
ARGS=$(tail -n +2 $AMPATH/.cache/download-args)
for arg in $ARGS; do
for var in $arg; do
if [ $arg == STOP ]; then
exit
else
case $arg in
*)
if curl --output /dev/null --silent --head --fail $AMREPO/programs/$arch/$arg 1>/dev/null; then
echo ""; echo ' "'$arg'" installation script downloaded! ' | tr a-z A-Z
cd $(xdg-user-dir DESKTOP); wget -q $AMREPO/programs/$arch/$arg; echo ""; break;
elif curl --output /dev/null --silent --head --fail $AMREPO/testing/$arch/$arg 1>/dev/null; then
echo ""; echo ' "'$arg'" downloaded from "testing", the unstable branch ' | tr a-z A-Z; echo ""; echo ' WARNING! PROGRAMS COMING FROM "TESTING" ARE BROKEN, USE AT YOUR OWN RISK!'
cd $(xdg-user-dir DESKTOP); wget -q $AMREPO/testing/$arch/$arg; echo ""; break;
else
echo ""; echo ' "'$arg'" is NOT a valid argument, check the list (command "'$AMCLI' -l")'; echo ""; break;
fi
esac
fi
done
done
done
shift
;;
'-f'|'files')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
echo ""; echo $(echo "YOU HAVE INSTALLED "; cd $APPSPATH && find . -type f -name 'remove' 2>/dev/null | sed -r 's|/[^/]+$||' | sort | uniq | wc -l;
echo " STANDALONE PROGRAMS MANAGED BY '$(echo $AMCLI | tr a-z A-Z)':"); echo "";
cd $APPSPATH && find -name 'remove' -printf "%h\n" 2>/dev/null | sort -u | echo $(xargs -n 1 basename 2> /dev/null) | du -sh $(find . -type f -name 'remove' 2>/dev/null | sed -r 's|/[^/]+$||' | sort | uniq | cut -c 3-) | awk '{ print " ◆ "$2 " - " $1"iB of disk space used"}' | grep -w -v "◆ ."; echo ""
;;
'-H'|'--home')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
while [ -n "$1" ]; do
rm -f $AMPATH/.cache/home-args
echo $@ | tr ' ' '\n' >> $AMPATH/.cache/home-args && echo STOP >> $AMPATH/.cache/home-args
ARGS=$(tail -n +2 $AMPATH/.cache/home-args)
for arg in $ARGS; do
for var in $arg; do
if [ $arg == STOP ]; then
exit
else
cd $APPSPATH
if ! test -d ./$arg; then
echo ' ERROR: "'$arg'" is not installed'
else
case $arg in
*)
keyword=$(grep -hios appimage ./$arg/AM-updater ./$arg/version | tail -1 | tr A-Z a-z 2> /dev/null)
if [ "$keyword" = "appimage" ]; then
cd ./$arg
./$arg --appimage-extract AppRun > /dev/null 2>&1
if test -f ./squashfs-root/AppRun; then
mkdir -p ./$arg.home
echo ' Setting $HOME to '$APPSPATH'/'$arg'/'$arg'.home for this AppImage'
rm -R -f ./squashfs-root; break
elif test -h ./squashfs-root/AppRun; then
mkdir -p ./$arg.home
echo ' Setting $HOME to '$APPSPATH'/'$arg'/'$arg'.home for this AppImage'
rm -R -f ./squashfs-root; break
else
echo ' ERROR: "'$arg'" is NOT an AppImage'; break
fi
else
echo ' ERROR: "'$arg'" is NOT an AppImage'; break
fi
esac
fi
fi
done
done
done
;;
'-i'|'install')
while [ -n "$1" ]; do
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
$SUDOCOMMAND echo "" 2>/dev/null
if $SUDOCOMMAND -n true 2>/dev/null; then
echo -e "-----------------------------------------------------------------------\n >> START OF ALL INSTALLATION PROCESSES <<\n-----------------------------------------------------------------------"
rm -f $AMPATH/.cache/install-args
rm -R -f $AMPATH/.cache/installed
echo $@ | tr ' ' '\n' >> $AMPATH/.cache/install-args
echo STOP >> $AMPATH/.cache/install-args
ARGS=$(tail -n +2 $AMPATH/.cache/install-args)
for arg in $ARGS; do
for var in $arg; do
if [ $arg == STOP ]; then
if test -f $AMPATH/.cache/installed; then
echo -e "\n-----------------------------------------------------------------------\n >> END OF ALL INSTALLATION PROCESSES <<\n-----------------------------------------------------------------------\n\n THE FOLLOWING NEW PROGRAMS HAVE BEEN INSTALLED:\n"
echo -e "\n-----------------------------------------------------------------------" >> $AMPATH/.cache/installed
cat $AMPATH/.cache/installed | grep -w -v "◆ am"
exit
else
exit
fi
else
echo ""
case $arg in
am)
echo '"'$(echo $AMCLI | tr a-z A-Z)'" IS ALREADY INSTALLED!'; break;;
*)
if test -f $APPSPATH/$arg/remove; then
echo ' ERROR: "'$arg'" is already installed, please try to remove it first' && echo ""; break;
else
if curl --output /dev/null --silent --head --fail $AMREPO/programs/$arch/$arg 1>/dev/null; then
case $arg in
*)
for var in $arg; do
cd $AMPATH/.cache; mkdir -p tmp; cd tmp; wget -q $AMREPO/programs/$arch/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp;
chmod a+x ./$arg
sed -i "s#wget #wget -q --show-progress #g" ./$arg
sed -i 's#$(wget -q --show-progress #$(wget -q #g' ./$arg
sed -i 's#wget http#wget -q http#g' ./$arg
sed -i "s#rm #rm -f #g" ./$arg
sed -i "s#form -f #form #g" ./$arg
sed -i "s#unzip #unzip -qq #g" ./$arg
sed -i 's/currentuser=/#currentuser=/g' ./$arg
sed -i 's/chown -R $currentuser/#chown -R $currentuser/g' ./$arg
sed -i '/# MESSAGE/,$d' ./$arg
sed -i 's# /opt/$APP/icons/$APP# /opt/$APP/icons/$APP 2> /dev/null#g' ./$arg
sed -i 's#.svg;#.svg 2> /dev/null;#g' ./$arg
sed -i 's#programs/.icons/$APP.svg#programs/.icons/$APP.svg 2> /dev/null;#g' ./$arg
sed -i 's#*.desktop ./$APP.desktop#*.desktop ./$APP.desktop 2> /dev/null;#g' ./$arg
echo -ne " ◆ RUNNING THE INSTALLATION SCRIPT FOR $(echo '"'$arg'"' | tr a-z A-Z)... \r" && sleep 3 &&
$SUDOCOMMAND ./$arg | less -E && echo -ne " \r" &&
echo -ne " ◆ CONFIGURING $(echo '"'$arg'"' | tr a-z A-Z)...\r" && sleep 2 && echo -ne " \r" &&
$SUDOCOMMAND chown -R $currentuser $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) 2> /dev/null
echo -ne " ◆ $(echo '"'$arg'"' | tr a-z A-Z) INSTALLED ($(du -sm $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) | awk '{print $1}' ) MB OF DISK SPACE)\n"
$SUDOCOMMAND rm $AMPATH/.cache/$arg
unset $LATESTDIR
LATESTDIR=$(cd $APPSPATH && ls -td * | head -1)
if test -f $APPSPATH/$LATESTDIR/remove; then
if test -d $APPSPATH/$LATESTDIR/tmp; then
echo -e " 💀 ERROR DURING INSTALLATION, REMOVED $(echo '"'$arg'"' | tr a-z A-Z)!"
$AMCLIPATH -R $LATESTDIR 1> /dev/null
else
echo " ◆ $LATESTDIR" >> $AMPATH/.cache/installed &&
chown -R $currentuser $AMPATH/.cache/about 2> /dev/null
fi
else
echo " INSTALLATION ABORTED!";
fi
break; done
esac
else
echo ' "'$arg'" is NOT a valid argument, please try again!'; echo ""; break;
fi
fi
esac
fi
done
done
else
exit
fi
done
shift
;;
'-l'|'list')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
rm -R -f $AMPATH/$arch-apps $AMPATH/list && wget -q $AMREPO/programs/$arch-apps -P $AMPATH && echo -e "$(cat $AMPATH/$arch-apps | awk -v FS="(◆ | : )" '{print $2}')" >> $AMPATH/list
cd $AMPATH && cat options >> list 2>/dev/null
MESSAGE=$(echo " YOU HAVE INSTALLED $(cd $APPSPATH && find -name 'remove' -printf "%h\n" 2>/dev/null | sort -u | wc -l) APPLICATIONS OUT OF $(grep -e "$" -c $AMPATH/$arch-apps) AVAILABLE")
echo -e "\n$MESSAGE\n\n LIST OF THE $(grep -e "$" -c $AMPATH/$arch-apps) APPLICATIONS AVAILABLE IN THE 'AM' REPOSITORY:\n\n$(cat $AMPATH/$arch-apps)" | less -I
echo -e "\n $MESSAGE\n"
;;
'-o'|'overwrite')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
while [ -n "$1" ]; do
rm -f $AMPATH/.cache/overwrite-args
echo $@ | tr ' ' '\n' >> $AMPATH/.cache/overwrite-args && echo STOP >> $AMPATH/.cache/overwrite-args
ARGS=$(tail -n +2 $AMPATH/.cache/overwrite-args)
for arg in $ARGS; do
for var in $arg; do
if [ $arg == STOP ]; then
exit
else
case $arg in
$AMCLI)
$AMCLIPATH -s; break;;
'')
echo " Specify the name of a program to overwrite"; echo ""; break;;
*)
if test -f $APPSPATH/$arg/remove; then
echo ""; read -p " Do you wish to overwrite this version of $arg with an old one (y,N)?" yn
case $yn in
[Yy]* )
echo ""; printf " Please, select a snapshot or press CTRL+C to abort:\n"; sleep 1;
select d in $(xdg-user-dir USER)/.am-snapshots/$arg/*; do test -n "$d" && break; echo ">>> Invalid Selection"; done
cp -r --backup=t $d/* $APPSPATH/$arg/
echo " RESTORE COMPLETED SUCCESSFULLY!"; echo ""; break;;
[Nn]*|* )
echo ""; echo " OPERATION ABORTED!"; echo ""; break;;
esac
else
echo ""; echo " '$arg' is not a valid argument or is not installed."; echo ""; break;
fi
esac
fi
done
done
done
shift
;;
'-q'|'query')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
rm -R -f $AMPATH/$arch-apps $AMPATH/list && wget -q $AMREPO/programs/$arch-apps -P $AMPATH && echo -e "$(cat $AMPATH/$arch-apps | awk -v FS="(◆ | : )" '{print $2}')" >> $AMPATH/list
cd $AMPATH && cat options >> list
ARGS=$(echo "$@" | sed 's/-q //')
echo ""
echo ' Search results for "'$ARGS'" in the list of available programs:' | tr a-z A-Z
echo ""
grep -i -E "$2" $AMPATH/$arch-apps | grep -i -E "$3" | grep -i -E "$4" | grep -i -E "$5" | grep -i -E "$6" | grep -i -E "$7" | grep -i -E "$8" | grep -i -E "$9"
echo ""
exit
;;
'-r'|'remove')
while [ -n "$1" ]; do
rm -f $AMPATH/.cache/remove-args
echo $@ | tr ' ' '\n' >> $AMPATH/.cache/remove-args && echo STOP >> $AMPATH/.cache/remove-args
ARGS=$(tail -n +2 $AMPATH/.cache/remove-args)
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
for arg in $ARGS; do
for var in $arg; do
if [ $arg == STOP ]; then
if test -f $AMPATH/.cache/unavailable-args; then
echo -e "-----------------------------------------------------------------------"
echo -e " ◆ ERROR: $(echo $(cat $AMPATH/.cache/unavailable-args) | rev | cut -c 2- | rev) not available in $APPSPATH \n INSTALLED PROGRAMS (valid arguments):"
cd $APPSPATH && find -name 'remove' -printf " %h\n" 2>/dev/null | sort -u | xargs -n 1 basename 2> /dev/null; rm $AMPATH/.cache/unavailable-args
echo -e "-----------------------------------------------------------------------"
exit
else
exit
fi
else
if ls $APPSPATH/$arg > /dev/null 2>&1; then
case $arg in
*)
for var in $arg; do
$SUDOCOMMAND echo "" > /dev/null; read -p ' ◆ DO YOU WISH TO REMOVE "'$(echo $arg | tr a-z A-Z)'" (Y,n)?' yn
case $yn in
[Nn]* )
echo ' - "'$(echo $arg | tr a-z A-Z)'" HAS NOT BEEN REMOVED!'; echo ""; break;;
[Yy]*|* )
$SUDOCOMMAND $APPSPATH/$arg/remove && echo ' ◆ "'$(echo $arg | tr a-z A-Z)'" HAS BEEN SUCCESSFULLY REMOVED!' && break; break;;
esac
done;;
esac
else
echo '"'$arg'",' >> $AMPATH/.cache/unavailable-args; break;
fi
fi
done
done
done
shift
;;
'-R')
while [ -n "$1" ]; do
rm -f $AMPATH/.cache/remove-args
echo $@ | tr ' ' '\n' >> $AMPATH/.cache/remove-args && echo STOP >> $AMPATH/.cache/remove-args
ARGS=$(tail -n +2 $AMPATH/.cache/remove-args)
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
for arg in $ARGS; do
for var in $arg; do
if [ $arg == STOP ]; then
if test -f $AMPATH/.cache/unavailable-args; then
echo -e "-----------------------------------------------------------------------"
echo -e " ◆ ERROR: $(echo $(cat $AMPATH/.cache/unavailable-args) | rev | cut -c 2- | rev) not available in $APPSPATH \n INSTALLED PROGRAMS (valid arguments):"
cd $APPSPATH && find -name 'remove' -printf " %h\n" 2>/dev/null | sort -u | xargs -n 1 basename 2> /dev/null; rm $AMPATH/.cache/unavailable-args
echo -e "-----------------------------------------------------------------------"
exit
else
exit
fi
else
if ls $APPSPATH/$arg > /dev/null 2>&1; then
case $arg in
*)
for var in $arg; do
$SUDOCOMMAND $APPSPATH/$arg/remove && echo ' ◆ "'$(echo $arg | tr a-z A-Z)'" HAS BEEN SUCCESSFULLY REMOVED!' && break; break
done;;
esac
else
echo '"'$arg'",' >> $AMPATH/.cache/unavailable-args; break;
fi
fi
done
done
done
shift
;;
'-s'|'sync')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
rm -R -f $AMPATH/$arch-apps $AMPATH/list && wget -q $AMREPO/programs/$arch-apps -P $AMPATH && echo -e "$(cat $AMPATH/$arch-apps | awk -v FS="(◆ | : )" '{print $2}')" >> $AMPATH/list
cd $AMPATH && cat options >> list
echo ""; echo ' SYNCHRONIZING "'$(echo $AMCLI | tr a-z A-Z)'" VERSION '$($AMCLIPATH -v)'...'; sleep 0.5; echo "";
rm -R -f $AMPATH/.cache/* 1>/dev/null; cd $AMPATH/.cache; wget -q $AMREPO/APP-MANAGER && chmod a+x ./APP-MANAGER; cd ..;
mv $AMPATH/.cache/APP-MANAGER $AMPATH; chmod 777 $AMPATH; echo ' THE "'$(echo $AMCLI | tr a-z A-Z)'" SCRIPT IS NOW UPDATED TO THE '$($AMCLIPATH -v)' VERSION! '; echo ""
;;
'-t'|'template'|'convert')
if [ -n "$SUDO_COMMAND" ]; then
echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n";
exit;
fi
case $2 in
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
esac
while [ -n "$1" ]; do
rm -f $AMPATH/.cache/template-args
echo $@ | tr ' ' '\n' >> $AMPATH/.cache/template-args && echo STOP >> $AMPATH/.cache/template-args
ARGS=$(tail -n +2 $AMPATH/.cache/template-args)
for arg in $ARGS; do
for var in $arg; do
if [ $arg == STOP ]; then
exit
else
case $arg in
*)
for var in $arg; do
cd $(xdg-user-dir DESKTOP)
echo "##############################################################"; echo ""
echo ' Create templates for "'$arg'"
' | tr a-z A-Z
echo "--------------------------------------------------------------"; echo ""
echo " EACH MODEL IS BASED ON A DIFFERENT METHOD OF BUILDING/UPDATING THE PROGRAM.
"
echo ' PLEASE, SELECT A TEMPLATE FOR "'$(echo $arg | tr a-z A-Z)'":
'
echo ' 0) APPIMAGE updatable with "appimageupdatetool"' | tr a-z A-Z
echo ' 1) APPIMAGE updatable using a separated zsync file' | tr a-z A-Z
echo " 2) ANY ARCHIVE from github.com (always updatable)" | tr a-z A-Z
echo " 3) ANY ARCHIVE from AUR (always updatable)" | tr a-z A-Z
echo " 4) APPIMAGE, build your own with pkg2appimage and appimagetool" | tr a-z A-Z
echo " 5) APPIMAGE, build your own with pkg2appimage using a custom AppRun" | tr a-z A-Z
echo ' 6) WEBAPP based on a Firefox profile (requires "firefox" in $PATH)' | tr a-z A-Z
echo " 7) APPIMAGE from github.com (always updatable)" | tr a-z A-Z
echo " 8) APPIMAGE from any website out there (for advanced users)" | tr a-z A-Z
echo " 9) APPIMAGE from the AUR (always updatable)" | tr a-z A-Z
echo " 10) ANY PROGRAM from any website (for advanced users)" | tr a-z A-Z
echo " "
read -r -p " WHAT KIND OF PROGRAM DO YOU WANT TO WRITE A SCRIPT FOR? : " response
case "$response" in
# APPIMAGE UPDATABLE USING APPIMAGEUPDATETOOL
0)
mkdir -p ./am-scripts ./am-scripts/$arch ./am-scripts/WEBPAGE &&
# DOWNLOAD THE TEMPLATE AND CONVERT THE ARGUMENT INTO A COMMAND
wget -c -q $AMREPO/templates/AM-SAMPLE-for-appimageupdate -O ./am-scripts/$arch/$arg &&
sed -i s/SAMPLE/$arg/g ./am-scripts/$arch/$arg &&
# IF YOU CAN, USE A ONE-LINE COMMAND TO DOWNLOAD THE APPIMAGE
read -r -ep " USE A ONE-LINE COMMAND TO DOWNLOAD THE LATEST APPIMAGE $(echo -e '\n :') " response
case $response in
*)
mv ./am-scripts/$arch/$arg ./am-scripts/$arch/$arg.old
sed -n '1,17p' ./am-scripts/$arch/$arg.old >> ./am-scripts/$arch/$arg
echo ''$response'' >> ./am-scripts/$arch/$arg
sed -n '19,105p' ./am-scripts/$arch/$arg.old >> ./am-scripts/$arch/$arg
rm -f ./am-scripts/$arch/$arg.old;;
esac
# ADD THE URL TO THE MAIN PAGE OF THE WEBSITE
read -r -ep " ◆ ADD THE URL TO THE MAIN PAGE OF THE WEBSITE $(echo -e '\n : ')" RESPONSE
case "$RESPONSE" in
*)
sed -i s#REPLACETHIS#$RESPONSE#g ./am-scripts/$arch/$arg
esac
echo "-----------------------------------------------------------------------"
# ADD A DESCRIPTION FOR THIS APPLICATION
read -r -ep " ◆ ADD A BRIEF DESCRIPTION FOR THIS APPLICATION $(echo -e '\n : ')" COMMENT
case "$COMMENT" in
*)
# CREATE A WEBPAGE FOR https://portable-linux-apps.github.io CONTAINING ALL THE INFO ABOUT THIS APP
echo "# $(echo $arg | tr a-z A-Z)" >> ./am-scripts/WEBPAGE/$arg.md
echo -e "\n $COMMENT\n\n SITE: $RESPONSE\n\n | [Applications](https://portable-linux-apps.github.io/apps.html) | [Home](https://portable-linux-apps.github.io)\n | --- | --- |" >> ./am-scripts/WEBPAGE/$arg.md &&
# CREATE A NEW LINE FOR THE APPLICATION'S LIST
echo "◆ $arg : $COMMENT" >> ./am-scripts/list
esac
echo "-----------------------------------------------------------------------"
# END OF THIS FUNCTION
echo -e "\n All files are saved in $(xdg-user-dir DESKTOP)/am-scripts\n";;
# APPIMAGE UPDATABLE USING ZSYNC
1)
mkdir -p ./am-scripts ./am-scripts/$arch ./am-scripts/WEBPAGE &&
# DOWNLOAD THE TEMPLATE AND CONVERT THE ARGUMENT INTO A COMMAND
wget -c -q $AMREPO/templates/AM-SAMPLE-for-zsync -O ./am-scripts/$arch/$arg &&
sed -i s/SAMPLE/$arg/g ./am-scripts/$arch/$arg &&
# IF YOU CAN, USE A ONE-LINE COMMAND TO DOWNLOAD THE APPIMAGE
read -r -ep " USE A ONE-LINE COMMAND TO CHECK ONLY THE URL TO THE APPIMAGE $(echo -e '\n THE DEFAULT PROGRAM ASSIGNED TO DOWNLOAD THIS LINK WILL BE "WGET"\n USE YOUR BEST SKILLS TO GET THE URL OF THE LATEST VERSION AVAILABLE\n :') " response
case $response in
*)
mv ./am-scripts/$arch/$arg ./am-scripts/$arch/$arg.old
sed -n '1,3p' ./am-scripts/$arch/$arg.old >> ./am-scripts/$arch/$arg
echo 'URL=$('$response')' >> ./am-scripts/$arch/$arg
sed -n '5,36p' ./am-scripts/$arch/$arg.old >> ./am-scripts/$arch/$arg
echo 'URL=$('$response')' >> ./am-scripts/$arch/$arg
sed -n '38,118p' ./am-scripts/$arch/$arg.old >> ./am-scripts/$arch/$arg
rm -f ./am-scripts/$arch/$arg.old;;
esac
# ADD THE URL TO THE MAIN PAGE OF THE WEBSITE
read -r -ep " ◆ ADD THE URL TO THE MAIN PAGE OF THE WEBSITE $(echo -e '\n : ')" RESPONSE
case "$RESPONSE" in
*)
sed -i s#REPLACETHIS#$RESPONSE#g ./am-scripts/$arch/$arg
esac
echo "-----------------------------------------------------------------------"
# ADD A DESCRIPTION FOR THIS APPLICATION
read -r -ep " ◆ ADD A BRIEF DESCRIPTION FOR THIS APPLICATION $(echo -e '\n : ')" COMMENT
case "$COMMENT" in
*)
# CREATE A WEBPAGE FOR https://portable-linux-apps.github.io CONTAINING ALL THE INFO ABOUT THIS APP
echo "# $(echo $arg | tr a-z A-Z)" >> ./am-scripts/WEBPAGE/$arg.md
echo -e "\n $COMMENT\n\n SITE: $RESPONSE\n\n | [Applications](https://portable-linux-apps.github.io/apps.html) | [Home](https://portable-linux-apps.github.io)\n | --- | --- |" >> ./am-scripts/WEBPAGE/$arg.md &&
# CREATE A NEW LINE FOR THE APPLICATION'S LIST
echo "◆ $arg : $COMMENT" >> ./am-scripts/list
esac
echo "-----------------------------------------------------------------------"
# END OF THIS FUNCTION
echo -e "\n All files are saved in $(xdg-user-dir DESKTOP)/am-scripts\n";;
# DOWNLOAD ANY ARCHIVE FROM GITHUB
2)
mkdir -p ./am-scripts ./am-scripts/$arch ./am-scripts/WEBPAGE &&
# DOWNLOAD THE TEMPLATE AND CONVERT THE ARGUMENT INTO A COMMAND
wget -c -q $AMREPO/templates/AM-SAMPLE-GitHub-generic -O ./am-scripts/$arch/$arg &&
sed -i s/SAMPLE/$arg/g ./am-scripts/$arch/$arg &&
echo "-----------------------------------------------------------------------"
# ADD THE NAME OF THE GITHUB REPOSITORY, ALSO ADD SOME BASIC INFO IF AVAILABLE
read -r -ep " ◆ ADD THE NAME OF THE REPOSITORY (EXAMPLE 'NAME/REPOSITORY') $(echo -e '\n https://github.com/')" GITHUBREPO
case "$GITHUBREPO" in
*)
sed -i s#REPLACETHIS#$GITHUBREPO#g ./am-scripts/$arch/$arg
# GET THE DESCRIPTION OF THIS REPOSITORY TO ADD IN ALL CREATED FILES
COMMENT=$(curl https://api.github.com/repos/$GITHUBREPO 2>/dev/null | grep description | sed 's/"description": "//' | sed 's/",//')
# CREATE A WEBPAGE FOR https://portable-linux-apps.github.io CONTAINING ALL THE INFO ABOUT THIS APP
echo "# $(echo $arg | tr a-z A-Z)" >> ./am-scripts/WEBPAGE/$arg.md
echo -e "\n $COMMENT\n\n SITE: https://github.com/$GITHUBREPO\n\n | [Applications](https://portable-linux-apps.github.io/apps.html) | [Home](https://portable-linux-apps.github.io)\n | --- | --- |" >> ./am-scripts/WEBPAGE/$arg.md &&
# CREATE A NEW LINE FOR THE APPLICATION'S LIST
echo "◆ $arg : $COMMENT" >> ./am-scripts/list
esac
# ADD AN EXTENSION OR AN UNIQUE PART OF THE NAME OF THE ARCHIVE
read -r -ep " ◆ ADD THE EXTENSION OR AN UNIQUE PART OF THE ARCHIVE'S NAME $(echo -e '\n EXAMPLE, "amd64.zip" OR "x64.tar" ): ')" EXTENSION
case "$EXTENSION" in
*)
sed -i s#FILENAMEEXTENSION#$EXTENSION#g ./am-scripts/$arch/$arg
esac