Skip to content

Commit c587ca0

Browse files
authored
Update APP-MANAGER
1 parent a7924ff commit c587ca0

File tree

1 file changed

+11
-79
lines changed

1 file changed

+11
-79
lines changed

APP-MANAGER

Lines changed: 11 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
AMVERSION="6.15.1"
3+
AMVERSION="6.15.1-1"
44

55
# Determine main repository and branch
66
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
@@ -33,17 +33,6 @@ function _clean_amcachedir() {
3333
APPMANCONFIG="$CONFIGDIR/appman"
3434
export SCRIPTDIR="$(xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME")"
3535

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-
4736
# Colors
4837
RED='\033[0;31m'; LightBlue='\033[1;34m'; Green='\033[0;32m'
4938

@@ -201,40 +190,6 @@ function _use_betatester_off() {
201190
rm -f "$AMPATH"/betatester
202191
}
203192

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-
238193
###########################################
239194
# FUNCTIONS RELATED TO THE SAFE USE OF "AM"
240195
###########################################
@@ -281,25 +236,6 @@ function _online_check() {
281236
fi
282237
}
283238

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-
303239
###########################################
304240
# FUNCTIONS RELATED TO THE DATABASE OF APPS
305241
###########################################
@@ -363,12 +299,12 @@ function _check_version_if_zsync_file_exists() {
363299
function _check_version_if_version_file_exists() {
364300
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')
365301
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
369303
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')
370304
elif grep -q "://" ./"$arg"/version; then
371305
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')
372308
elif [ "$(cat ./"$arg"/version | wc -w)" == 1 ]; then
373309
APPVERSION=$(cat ./"$arg"/version | head -1)
374310
fi
@@ -717,7 +653,7 @@ function _clean_old_modules() {
717653

718654
function _use_clean() {
719655
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
721657
echo -ne " $i\r" && sleep 0.0001
722658
done
723659
_clean_amcachedir_message
@@ -858,7 +794,7 @@ function _use_sync() {
858794
}
859795

860796
function _update_all_apps() {
861-
for f in "$APPSPATH"/*/; do
797+
for f in "$APPSPATH"/*/; do
862798
cd "$f" 2>/dev/null &&
863799
if test -f ./AM-updater; then
864800
if [ -w ./AM-updater ]; then
@@ -897,7 +833,7 @@ function _use_update() {
897833
_update_github_api
898834
while [ -n "$1" ]; do
899835
case $2 in
900-
''|'--apps')
836+
''|'--apps')
901837
_clean_amcachedir
902838
_list_updatable_apps
903839
echo '-----------------------------------------------------------------------------'
@@ -923,7 +859,7 @@ function _use_update() {
923859
echo '-----------------------------------------------------------------------------'
924860
sleep 0.2
925861
exit;;
926-
*)
862+
*)
927863
if test -f "$APPSPATH"/"$2"/AM-updater; then
928864
if [ -w "$APPSPATH"/"$2"/AM-updater ]; then
929865
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() {
950886

951887
function _use_force_latest() {
952888
case $2 in
953-
'')
889+
'')
954890
echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit
955891
;;
956892
*)
@@ -960,10 +896,10 @@ function _use_force_latest() {
960896
echo " ERROR: \"$AMCLI\" cannot manage updates for \"$2\""
961897
elif ! grep -q "api.github.com" "$APPSPATH"/"$2"/AM-updater; then
962898
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
964900
echo " ERROR: \"$2\" does not redirect to a generic \"releases\""
965901
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
967903
"$AMCLIPATH" -u "$2"
968904
fi
969905
;;
@@ -985,7 +921,6 @@ function _use_module() {
985921
}
986922

987923
_am_security_check
988-
_prevent_apps_from_being_removed_by_third_parties 2> /dev/null
989924
_am_databases_check "$@"
990925

991926
case "$1" in
@@ -1034,7 +969,6 @@ case "$1" in
1034969
_online_check
1035970
_if_appman_mode_enabled
1036971
_betatester_message_on
1037-
_portable_dependences_setup
1038972
_use_module "$@"
1039973
;;
1040974
'-t'|'template')
@@ -1069,7 +1003,6 @@ case "$1" in
10691003
;;
10701004
'--force-latest')
10711005
_online_check
1072-
_portable_dependences_setup
10731006
_use_force_latest "$@"
10741007
;;
10751008
'--system')
@@ -1088,7 +1021,6 @@ case "$1" in
10881021
;;
10891022
'update'|'-u'|'-U')
10901023
_online_check
1091-
_portable_dependences_setup
10921024
_use_update "$@"
10931025
;;
10941026
'version'|'-v'|'--version')

0 commit comments

Comments
 (0)