1
1
#! /usr/bin/env bash
2
2
3
- AMVERSION=" 6.15.1"
3
+ AMVERSION=" 6.15.1-1 "
4
4
5
5
# Determine main repository and branch
6
6
AMREPO=" https://raw.githubusercontent.com/ivan-hc/AM/main"
@@ -33,17 +33,6 @@ function _clean_amcachedir() {
33
33
APPMANCONFIG=" $CONFIGDIR /appman"
34
34
export SCRIPTDIR=" $( xdg-user-dir DESKTOP 2> /dev/null || echo " $HOME " ) "
35
35
36
- # Determine sytem package manager
37
- function _system_package_manager_check() {
38
- for cmd in dnf pacman emerge zypper apt-get apk; do
39
- if command -v $cmd & > /dev/null; then
40
- osPKGman=" $cmd "
41
- return
42
- fi
43
- done
44
- osPKGman=" "
45
- }
46
-
47
36
# Colors
48
37
RED=' \033[0;31m' ; LightBlue=' \033[1;34m' ; Green=' \033[0;32m'
49
38
@@ -201,40 +190,6 @@ function _use_betatester_off() {
201
190
rm -f " $AMPATH " /betatester
202
191
}
203
192
204
- # ##############################
205
- # DOWNLOAD PORTABLE DEPENDENCES
206
- # ##############################
207
-
208
- function _jq_installer() {
209
- if ! command -v jq 1> /dev/null; then
210
- _system_package_manager_check
211
- if [[ -z " $osPKGman " ]]; then
212
- echo -e " ${RED} 💀 ERROR!\033[0m Missing essential command ${Green} jq\033[0m\n"
213
- read -r -p " Do you wish to install it using $AMCLI (Y,n)? " yn
214
- case $yn in
215
- ' N' |' n' )
216
- echo -e " \n The \" jq\" command is essential for parsing JSON files on sites"
217
- echo " for example api.github.com, to list the URLs of apps to download."
218
- echo -e " You need to install it at least via your package manager to use \" $AMCLI \" .\n\n Missing essential command ${RED} jq\033[0m, aborted!" ; exit
219
- ;;
220
- ' Y' |' y' |* )
221
- _clean_amcachedir
222
- echo " "
223
- source " $AMPATH " /modules/install.am -i jq 2>&1 | grep " INSTALLED"
224
- echo " "
225
- ;;
226
- esac
227
- else
228
- echo -e " ${RED} 💀 ERROR!\033[0m Missing essential command ${Green} jq\033[0m\n"
229
- echo " Install it from your system package manager and retry!" ; exit
230
- fi
231
- fi
232
- }
233
-
234
- function _portable_dependences_setup() {
235
- _jq_installer
236
- }
237
-
238
193
# ##########################################
239
194
# FUNCTIONS RELATED TO THE SAFE USE OF "AM"
240
195
# ##########################################
@@ -281,25 +236,6 @@ function _online_check() {
281
236
fi
282
237
}
283
238
284
- # ######################
285
- # SECURE INSTALLED APPS
286
- # ######################
287
-
288
- function _prevent_apps_from_being_removed_by_third_parties() {
289
- # Add a security layer to scripts named "remove" of installed apps to prevent file removal by non-privileged users
290
- if [ " $AMCLI " == am ] 2> /dev/null; then
291
- for r in /opt/* /; do
292
- if test -f " $r " /remove; then
293
- if ! grep -q ' "$SUDO_COMMAND"' " $r " /remove 2> /dev/null; then
294
- if [[ " $r " != " /opt/am/" ]]; then
295
- sed -i ' 1 a if [ -z "$SUDO_COMMAND" ]; then echo "Permission denied"; exit 1; fi' " $r " /remove 2> /dev/null
296
- fi
297
- fi
298
- fi
299
- done
300
- fi
301
- }
302
-
303
239
# ##########################################
304
240
# FUNCTIONS RELATED TO THE DATABASE OF APPS
305
241
# ##########################################
@@ -363,12 +299,12 @@ function _check_version_if_zsync_file_exists() {
363
299
function _check_version_if_version_file_exists() {
364
300
APPVERSION=$( cat " $APPSPATH " /" $arg " /version | head -1 | sed ' s:.*/::' | sed " s/$arch //g; s/amd64//g; s/x86-64//g; s/x64//g;" | tr ' -' ' \n' | tr ' _' ' \n' | grep -vi " appimage\|$arg \|?\|tar." | grep " [0-9]" | head -1 | sed ' s/^v//g' )
365
301
if [ -z " $APPVERSION " ]; then
366
- if grep -q " /v[0-9]*" ./" $arg " /version; then
367
- APPVERSION=$( cat " $APPSPATH " /" $arg " /version | tr ' /' ' \n' | grep " ^v[0-9]" | head -1 | sed ' s/^v//g' )
368
- elif grep -q " download$" ./" $arg " /version; then
302
+ if grep -q " download$" ./" $arg " /version; then
369
303
APPVERSION=$( cat " $APPSPATH " /" $arg " /version | tr ' /' ' \n' | sed " s/$arch //g; s/amd64//g; s/x86-64//g; s/x64//g;" | tr ' _' ' \n' | grep -vi " appimage\|$arg \|?\|tar." | grep " [0-9]" | tail -1 | sed ' s/^v//g' )
370
304
elif grep -q " ://" ./" $arg " /version; then
371
305
APPVERSION=$( cat ./" $arg " /version | tr ' /' ' \n' | grep -Eo " ([0-9]{1,}\.)+[0-9]{1,}" | head -1)
306
+ elif grep -q " /v[0-9]*" ./" $arg " /version; then
307
+ APPVERSION=$( cat " $APPSPATH " /" $arg " /version | tr ' /' ' \n' | grep " ^v[0-9]" | head -1 | sed ' s/^v//g' )
372
308
elif [ " $( cat ./" $arg " /version | wc -w) " == 1 ]; then
373
309
APPVERSION=$( cat ./" $arg " /version | head -1)
374
310
fi
@@ -717,7 +653,7 @@ function _clean_old_modules() {
717
653
718
654
function _use_clean() {
719
655
echo -e " \n Cleaning temporary files and folders...\n" && sleep 0.1 &&
720
- for i in {100..000}; do
656
+ for i in {100..000}; do
721
657
echo -ne " $i \r" && sleep 0.0001
722
658
done
723
659
_clean_amcachedir_message
@@ -858,7 +794,7 @@ function _use_sync() {
858
794
}
859
795
860
796
function _update_all_apps() {
861
- for f in " $APPSPATH " /* /; do
797
+ for f in " $APPSPATH " /* /; do
862
798
cd " $f " 2> /dev/null &&
863
799
if test -f ./AM-updater; then
864
800
if [ -w ./AM-updater ]; then
@@ -897,7 +833,7 @@ function _use_update() {
897
833
_update_github_api
898
834
while [ -n " $1 " ]; do
899
835
case $2 in
900
- ' ' |' --apps' )
836
+ ' ' |' --apps' )
901
837
_clean_amcachedir
902
838
_list_updatable_apps
903
839
echo ' -----------------------------------------------------------------------------'
@@ -923,7 +859,7 @@ function _use_update() {
923
859
echo ' -----------------------------------------------------------------------------'
924
860
sleep 0.2
925
861
exit ;;
926
- * )
862
+ * )
927
863
if test -f " $APPSPATH " /" $2 " /AM-updater; then
928
864
if [ -w " $APPSPATH " /" $2 " /AM-updater ]; then
929
865
start=$( date +%s) ; " $APPSPATH " /" $2 " /AM-updater > /dev/null 2>&1 | echo -ne " UPDATING $( echo " $2 " | tr ' [:lower:]' ' [:upper:]' ) \r" ; end=$( date +%s)
@@ -950,7 +886,7 @@ function _use_update() {
950
886
951
887
function _use_force_latest() {
952
888
case $2 in
953
- ' ' )
889
+ ' ' )
954
890
echo " USAGE: $AMCLI $1 [ARGUMENT]" ; exit
955
891
;;
956
892
* )
@@ -960,10 +896,10 @@ function _use_force_latest() {
960
896
echo " ERROR: \" $AMCLI \" cannot manage updates for \" $2 \" "
961
897
elif ! grep -q " api.github.com" " $APPSPATH " /" $2 " /AM-updater; then
962
898
echo " ERROR: \" $2 \" source is not on Github"
963
- elif ! grep -q " /releases | jq " " $APPSPATH " /" $2 " /AM-updater; then
899
+ elif ! grep -q " /releases | " " $APPSPATH " /" $2 " /AM-updater; then
964
900
echo " ERROR: \" $2 \" does not redirect to a generic \" releases\" "
965
901
else
966
- sed -i ' s#/releases | jq #/releases/latest | jq #g' " $APPSPATH " /" $2 " /AM-updater
902
+ sed -i ' s#/releases | #/releases/latest | #g' " $APPSPATH " /" $2 " /AM-updater
967
903
" $AMCLIPATH " -u " $2 "
968
904
fi
969
905
;;
@@ -985,7 +921,6 @@ function _use_module() {
985
921
}
986
922
987
923
_am_security_check
988
- _prevent_apps_from_being_removed_by_third_parties 2> /dev/null
989
924
_am_databases_check " $@ "
990
925
991
926
case " $1 " in
@@ -1034,7 +969,6 @@ case "$1" in
1034
969
_online_check
1035
970
_if_appman_mode_enabled
1036
971
_betatester_message_on
1037
- _portable_dependences_setup
1038
972
_use_module " $@ "
1039
973
;;
1040
974
' -t' |' template' )
@@ -1069,7 +1003,6 @@ case "$1" in
1069
1003
;;
1070
1004
' --force-latest' )
1071
1005
_online_check
1072
- _portable_dependences_setup
1073
1006
_use_force_latest " $@ "
1074
1007
;;
1075
1008
' --system' )
@@ -1088,7 +1021,6 @@ case "$1" in
1088
1021
;;
1089
1022
' update' |' -u' |' -U' )
1090
1023
_online_check
1091
- _portable_dependences_setup
1092
1024
_use_update " $@ "
1093
1025
;;
1094
1026
' version' |' -v' |' --version' )
0 commit comments