From 75d5228bc8e2c53bb632a6853b3cc785307d266a Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:58:08 +0200 Subject: [PATCH 01/16] Update install.am: removed an obsolete command used to fix an old issue --- modules/install.am | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/install.am b/modules/install.am index 5b035ac01..c87043059 100644 --- a/modules/install.am +++ b/modules/install.am @@ -190,7 +190,6 @@ while [ -n "$1" ]; do echo -e " 💀 ERROR DURING INSTALLATION, REMOVED $(echo '"'$arg'"' | tr a-z A-Z)!" $AMCLIPATH -R $LATESTDIR 1> /dev/null else - chown -R $currentuser $AMPATH/.cache/about 2> /dev/null for metapackage in $(echo "$METAPACKAGES"); do if grep -q "$metapackage" ./$arg 2> /dev/null; then metascript=$(cd $APPSPATH && ls -td * | head -1) From 58c0065177781724d247167c973fe68d14199e6f Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:22:15 +0200 Subject: [PATCH 02/16] INSTALL update: enable multiuser permissions / refactoring --- INSTALL | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/INSTALL b/INSTALL index 26573a2f2..79959708e 100644 --- a/INSTALL +++ b/INSTALL @@ -1,13 +1,13 @@ #!/bin/sh -# CREATING THE MAIN FOLDER FOR "AM" +# CREATING THE MAIN DIRECTORY FOR "AM" mkdir -p /opt/am/.cache /opt/am/modules -cd /opt/am +cd /opt/am || exit # CREATE THE SCRIPT NEEDED TO UNINSTALL "AM" rm -R -f /opt/am/remove -echo "#!/bin/sh -rm -R -f /usr/local/bin/am /opt/am /etc/bash_completion.d/am-completion.sh" >> /opt/am/remove +echo '#!/bin/sh +rm -R -f /usr/local/bin/am /opt/am /etc/bash_completion.d/am-completion.sh' >> /opt/am/remove chmod a+x /opt/am/remove # DOWNLOAD THE MAIN SCRIPT @@ -25,9 +25,9 @@ wget -q "https://raw.githubusercontent.com/ivan-hc/AM-application-manager/main/p MODULES=$(wget -q https://api.github.com/repos/ivan-hc/AM/contents/modules -O - | grep download_url | cut -d '"' -f 4) for module in $MODULES; do for v in $module; do - cd /opt/am/modules + cd /opt/am/modules || exit mkdir tmp - cd tmp + cd tmp || exit wget -q "$v" cd .. mv tmp/*.am ./ @@ -36,16 +36,15 @@ for module in $MODULES; do done done -# ENABLE NON-ROOT PERMISSIONS TO THE MAIN FOLDER FOR THE CURRENT USER -currentuser=$(who | awk '{print $1}') -chown -R $currentuser /opt/am 2> /dev/null +# ENABLE NON-ROOT PERMISSIONS TO THE MAIN DIRECTORY FOR THE CURRENT USER +chown -R "$USER" /opt/am 2> /dev/null +find /opt/am -exec chmod 777 {} \; 2> /dev/null # ADD THE BASH COMPLETION SCRIPT -echo '#!/usr/bin/env bash' >> /opt/am/am-completion.sh; echo 'complete -W "$(cat /opt/am/list 2>/dev/null)" am' >> /opt/am/am-completion.sh +echo '#!/usr/bin/env bash +complete -W "$(cat /opt/am/list 2>/dev/null)" am' >> /opt/am/am-completion.sh chmod a+x /opt/am/am-completion.sh -rm -R -f /opt/am/remove; echo '#!/bin/sh' >> /opt/am/remove -echo 'rm -R -f /usr/local/bin/am /opt/am /etc/bash_completion.d/am-completion.sh' >> /opt/am/remove -chmod a+x /opt/am/remove; chown -R $currentuser /opt/am/remove 2>/dev/null + if test -f /etc/bash_completion.d; then mv /opt/am/am-completion.sh /etc/bash_completion.d/ else From dfdb966df8b5e89ccc02fc8c80b429503ff3d851 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:26:41 +0200 Subject: [PATCH 03/16] Update APP-MANAGER: enable multiuser support in "AM" --- APP-MANAGER | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 09789ee99..5c5827a06 100644 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -116,23 +116,8 @@ function _online_check(){ export AMCATALOGUEMARKDOWNS="https://raw.githubusercontent.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/main/apps" export AMCATALOGUEICONS="https://raw.githubusercontent.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/main/icons" -# Determine system architecture and current user +# Determine system architecture export arch="$HOSTTYPE" -export currentuser="$USER" -if [ "$AMCLI" == am ]; then - ampathowner=$(ls -ld /opt/am | awk 'NR==1 {print $3}') - if [ "$ampathowner" != "$currentuser" ]; then - echo ' 💀 ERROR: you are not the owner of /opt/am, so you cannot use "AM"' - echo '--------------------------------------------------------------------------' - echo ' The user that have installed "AM" on this system is "'"$ampathowner"'"' - echo ' you are only allowed to use the installed apps, not to manage them.' - echo '--------------------------------------------------------------------------' - echo ' Please, contact "'"$ampathowner"'" to change the ownership of /opt/am or' - echo ' consider using "AppMan" instead, see https://github.com/ivan-hc/AppMan' - echo '--------------------------------------------------------------------------' - exit - fi -fi if [[ -f "$AMPATH"/new-repo.txt ]]; then AMREPO=$(<"$AMPATH/new-repo.txt") # Utilizing command substitution with < for more efficient file reading From 80c9a95c6306cbd4b35cdbb7c8116be1cd2ccae1 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:45:05 +0200 Subject: [PATCH 04/16] Update install.am: "AM", allows all users to update/manage installed apps --- modules/install.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/install.am b/modules/install.am index c87043059..b19b7218b 100644 --- a/modules/install.am +++ b/modules/install.am @@ -16,7 +16,7 @@ while [ -n "$1" ]; do esac if [ $AMCLI == am ] 2>/dev/null; then - $SUDOCOMMAND echo "" 2>/dev/null + $SUDOCOMMAND echo -ne "\r" if ! $SUDOCOMMAND -n true 2>/dev/null; then exit fi @@ -160,7 +160,8 @@ while [ -n "$1" ]; do $SUDOCOMMAND ./$arg echo -ne " Configuring $(echo '"'$arg'"' | tr a-z A-Z)...\r" && echo -ne " \r" && - $SUDOCOMMAND chown -R $currentuser $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) 2> /dev/null + $SUDOCOMMAND chown -R "$USER" $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) 2> /dev/null + $SUDOCOMMAND find $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) -exec chmod 777 {} \; 2> /dev/null if test -f $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/AM-updater; then mkdir $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer 2> /dev/null && wget -q $APPSDB/$arg -O $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer/$arg From 9633b8e1da4201c8b41c619e571154ce2556a7b3 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 23 Apr 2024 22:25:16 +0200 Subject: [PATCH 05/16] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 41df4b645..06c94df67 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Initially the two projects traveled in parallel to each other, until version 5, #### To be more detailed, here is an overview of how apps are installed by "AM" and "AppMan" Where `$PROGRAM` is the application we're going to install: -- "AM" (ie the `am` command) installs programs system-wide. "AM" requires the `sudo` privileges but only to install and remove the app, all the other commands can be executed as a normal user. This allows multiple users of the same system to be able to use the same installed applications, **while the general use of "AM" (installing, updating, consulting lists...) will only be permitted to the system administrator/owner of the /opt/am directory and all the directories managed by "AM", and to the user "root"**. This is what an installation script installs with "AM": +- "AM" (ie the `am` command) installs programs and works at system level (i.e. for all the users). "AM" requires the `sudo` privileges but only to install and remove the app, all the other commands can be executed as a normal user. This allows multiple users of the same system to be able to use the same installed applications. This is what an installation script installs with "AM": /opt/$PROGRAM/ /opt/$PROGRAM/$PROGRAM @@ -101,8 +101,6 @@ If the distro is immutable instead, the path of the launcher (the last line abov /usr/local/share/applications/AM-$PROGRAM.desktop Since version 5.1 the installation process have introduced a check to find read-only filesystems (`grep "[[:space:]]ro[[:space:],]" /proc/mounts`), if there are mountpoints like this, your distro may be an immutable one, so an `/usr/local/share/applications` directory will be created and the installation script will be patched to redirect the installation of launchers in that path to solve the issue. -**NOTE: Non-privileged users who wish to use "AM" on multi-account systems will be advised to contact the administrator to change ownership of /opt/am or to consider using "AppMan".** - - "AppMan" (ie the `appman` command) instead does not need root privileges to work, it allows you to choose where to install your applications into your `$HOME` directory. AppMan is also usable as a portable app (i.e. you can download and place it wherever you want) and it is able to update itself, anywhere! At first start it will ask you where to install the apps and it will create the directory for you (the configuration file is in `~/.config/appman`). For example, suppose you want install everything in "Applicazioni" (the italian of "applications"), this is the structure of what an installation scripts installs with "AppMan" instead: ~/Applicazioni/$PROGRAM/ From 61e0f3c641d776293eccbc42dddc67e24752bd8a Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 00:42:54 +0200 Subject: [PATCH 06/16] Update install.am: allow privileges on installed apps if in "sudo" group See https://github.com/ivan-hc/AM/issues/466#issuecomment-2073453702 --- modules/install.am | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/install.am b/modules/install.am index b19b7218b..e1b805c6d 100644 --- a/modules/install.am +++ b/modules/install.am @@ -160,18 +160,24 @@ while [ -n "$1" ]; do $SUDOCOMMAND ./$arg echo -ne " Configuring $(echo '"'$arg'"' | tr a-z A-Z)...\r" && echo -ne " \r" && - $SUDOCOMMAND chown -R "$USER" $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) 2> /dev/null - $SUDOCOMMAND find $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) -exec chmod 777 {} \; 2> /dev/null + if test -f $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/AM-updater; then - mkdir $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer 2> /dev/null && - wget -q $APPSDB/$arg -O $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer/$arg - fi && + $SUDOCOMMAND mkdir $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer 2> /dev/null && + $SUDOCOMMAND wget -q $APPSDB/$arg -O $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer/$arg + fi + if test -d $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons; then find $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons/* -xtype l -delete 2> /dev/null if [ -z "$(ls -A $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons)" ]; then - wget -q "$AMCATALOGUEICONS"/$arg.png -O $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons/$arg + $SUDOCOMMAND wget -q "$AMCATALOGUEICONS"/$arg.png -O $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons/$arg fi - fi && + fi + + if [ "$AMCLI" == am ]; then + $SUDOCOMMAND chown -R :sudo $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) 2> /dev/null + $SUDOCOMMAND find $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) -exec chmod 775 {} \; 2> /dev/null + fi + if [ $AMCLI == appman ] 2>/dev/null; then sed -i "s#Icon=/opt#Icon=$HOME/$APPSDIR#g" "$DATADIR"/applications/AM*.desktop 2> /dev/null sed -i "s#Exec=$arg#Exec=$HOME/.local/bin/$arg#g" "$DATADIR"/applications/AM*.desktop 2> /dev/null From 5a5830d110ae8ae8362651607dead37ce3315da4 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Tue, 23 Apr 2024 18:43:53 -0400 Subject: [PATCH 07/16] Update deadbeef-appimage --- programs/x86_64/deadbeef-appimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/x86_64/deadbeef-appimage b/programs/x86_64/deadbeef-appimage index 9b9df8dc5..e4b684105 100644 --- a/programs/x86_64/deadbeef-appimage +++ b/programs/x86_64/deadbeef-appimage @@ -30,7 +30,7 @@ ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM cat >> /opt/"$APP"/AM-updater << 'EOF' #!/bin/sh -APP=deadbeef-devel-appimage +APP=deadbeef-appimage REPO="Samueru-sama/DeaDBeef-AppImage" version0=$(cat /opt/$APP/version) version=$(wget -q https://api.github.com/repos/$REPO/releases -O - | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) From c7c7e3dc331dfbb30633251ee5b938ed00b6303d Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 01:25:19 +0200 Subject: [PATCH 08/16] Update INSTALL: let "sudo" users own/manage the "AM" remover script --- INSTALL | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 79959708e..1d6451b70 100644 --- a/INSTALL +++ b/INSTALL @@ -36,10 +36,13 @@ for module in $MODULES; do done done -# ENABLE NON-ROOT PERMISSIONS TO THE MAIN DIRECTORY FOR THE CURRENT USER +# ENABLE NON-ROOT PERMISSIONS TO THE MAIN DIRECTORY FOR ALL USERS chown -R "$USER" /opt/am 2> /dev/null find /opt/am -exec chmod 777 {} \; 2> /dev/null +# ALLOW PERMISSIONS ONLY TO THE CORE FILES AND DIRECTORIES OF "AM", FOR ALL USERS OF "SUDO" GROUP +chown -R :sudo /opt/am/remove 2> /dev/null && chmod 775 /opt/am/remove 2> /dev/null + # ADD THE BASH COMPLETION SCRIPT echo '#!/usr/bin/env bash complete -W "$(cat /opt/am/list 2>/dev/null)" am' >> /opt/am/am-completion.sh From d62fe7211c2dd00dc34f3e7835ad9fa82fc352d9 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 01:59:44 +0200 Subject: [PATCH 09/16] Update INSTALL: add one main admin as owner of /opt/am --- INSTALL | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/INSTALL b/INSTALL index 1d6451b70..02a863a74 100644 --- a/INSTALL +++ b/INSTALL @@ -36,12 +36,14 @@ for module in $MODULES; do done done -# ENABLE NON-ROOT PERMISSIONS TO THE MAIN DIRECTORY FOR ALL USERS -chown -R "$USER" /opt/am 2> /dev/null +# ENABLE PERMISSIONS TO THE MAIN DIRECTORY FOR ALL USERS +currentuser=$(who | awk '{print $1}') +chown -R $currentuser /opt/am 2> /dev/null +chown -R :sudo /opt/am 2> /dev/null find /opt/am -exec chmod 777 {} \; 2> /dev/null - -# ALLOW PERMISSIONS ONLY TO THE CORE FILES AND DIRECTORIES OF "AM", FOR ALL USERS OF "SUDO" GROUP -chown -R :sudo /opt/am/remove 2> /dev/null && chmod 775 /opt/am/remove 2> /dev/null +chmod 775 /opt/am/APP-MANAGER 2> /dev/null +chmod 775 /opt/am/remove 2> /dev/null +chmod 775 /opt/am/modules 2> /dev/null # ADD THE BASH COMPLETION SCRIPT echo '#!/usr/bin/env bash From 3bb99506d0f18e3d414786f67fcc389e5d7a7819 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 02:12:03 +0200 Subject: [PATCH 10/16] Update APP-MANAGER: add a new "$APPMANAGER" variable the URL to APP-MANAGER --- APP-MANAGER | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 5c5827a06..ffe7f4f73 100644 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -136,6 +136,8 @@ else LIBSLISTDB="$AMREPO/programs/libs-list" fi +export APPMANAGER="$AMREPO/APP-MANAGER" + # To implement future application database changes if [ -f "$AMPATH/neodb" ]; then if grep -q "://" "$AMPATH/neodb"; then @@ -384,7 +386,7 @@ function use_appman() { echo -e "Please run '${RED}alias am=/opt/am/appman\033[0m' to made 'AM' act exactly like 'AppMan' for\nthe current session or save this command to your '"'~/.bashrc'"' file to make the\nchanges permanent. Visit ${LightBlue}https://github.com/ivan-hc/appman\033[0m for more!" else _appman - wget -q "$AMREPO"/APP-MANAGER -O /opt/am/appman && chmod a+x /opt/am/appman + wget -q "$APPMANAGER" -O /opt/am/appman && chmod a+x /opt/am/appman echo -e "Please run '${RED}alias am=/opt/am/appman\033[0m' to made 'AM' act exactly like 'AppMan' for\nthe current session or save this command to your '"'~/.bashrc'"' file to make the\nchanges permanent." fi } From ac7d21eba2c2cd45782d78a6a4673a5c62f4a4bb Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 02:15:34 +0200 Subject: [PATCH 11/16] Update APP-MANAGER: one step back --- APP-MANAGER | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index ffe7f4f73..5c5827a06 100644 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -136,8 +136,6 @@ else LIBSLISTDB="$AMREPO/programs/libs-list" fi -export APPMANAGER="$AMREPO/APP-MANAGER" - # To implement future application database changes if [ -f "$AMPATH/neodb" ]; then if grep -q "://" "$AMPATH/neodb"; then @@ -386,7 +384,7 @@ function use_appman() { echo -e "Please run '${RED}alias am=/opt/am/appman\033[0m' to made 'AM' act exactly like 'AppMan' for\nthe current session or save this command to your '"'~/.bashrc'"' file to make the\nchanges permanent. Visit ${LightBlue}https://github.com/ivan-hc/appman\033[0m for more!" else _appman - wget -q "$APPMANAGER" -O /opt/am/appman && chmod a+x /opt/am/appman + wget -q "$AMREPO"/APP-MANAGER -O /opt/am/appman && chmod a+x /opt/am/appman echo -e "Please run '${RED}alias am=/opt/am/appman\033[0m' to made 'AM' act exactly like 'AppMan' for\nthe current session or save this command to your '"'~/.bashrc'"' file to make the\nchanges permanent." fi } From bcec94dc1e554c8399a1703053414e2649b8074a Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 02:38:54 +0200 Subject: [PATCH 12/16] Update INSTALL: restore permissions to the working ones https://github.com/ivan-hc/AM/issues/466#issuecomment-2073719085 --- INSTALL | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/INSTALL b/INSTALL index 02a863a74..79959708e 100644 --- a/INSTALL +++ b/INSTALL @@ -36,14 +36,9 @@ for module in $MODULES; do done done -# ENABLE PERMISSIONS TO THE MAIN DIRECTORY FOR ALL USERS -currentuser=$(who | awk '{print $1}') -chown -R $currentuser /opt/am 2> /dev/null -chown -R :sudo /opt/am 2> /dev/null +# ENABLE NON-ROOT PERMISSIONS TO THE MAIN DIRECTORY FOR THE CURRENT USER +chown -R "$USER" /opt/am 2> /dev/null find /opt/am -exec chmod 777 {} \; 2> /dev/null -chmod 775 /opt/am/APP-MANAGER 2> /dev/null -chmod 775 /opt/am/remove 2> /dev/null -chmod 775 /opt/am/modules 2> /dev/null # ADD THE BASH COMPLETION SCRIPT echo '#!/usr/bin/env bash From ef3d13b221d216c98358e4a0653d74b752200b1d Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 03:06:25 +0200 Subject: [PATCH 13/16] Update INSTALL: restore / refactoring --- INSTALL | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index 79959708e..492841981 100644 --- a/INSTALL +++ b/INSTALL @@ -25,9 +25,9 @@ wget -q "https://raw.githubusercontent.com/ivan-hc/AM-application-manager/main/p MODULES=$(wget -q https://api.github.com/repos/ivan-hc/AM/contents/modules -O - | grep download_url | cut -d '"' -f 4) for module in $MODULES; do for v in $module; do - cd /opt/am/modules || exit + cd /opt/am/modules || tmp mkdir tmp - cd tmp || exit + cd tmp || tmp wget -q "$v" cd .. mv tmp/*.am ./ @@ -37,8 +37,8 @@ for module in $MODULES; do done # ENABLE NON-ROOT PERMISSIONS TO THE MAIN DIRECTORY FOR THE CURRENT USER -chown -R "$USER" /opt/am 2> /dev/null -find /opt/am -exec chmod 777 {} \; 2> /dev/null +currentuser=$(who | awk '{print $1}') +chown -R $currentuser /opt/am 2> /dev/null # ADD THE BASH COMPLETION SCRIPT echo '#!/usr/bin/env bash From 0337b71d1e40d566ff2bbc6f255fe26cbf0d298e Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 03:08:53 +0200 Subject: [PATCH 14/16] Update APP-MANAGER: allow "AM" usage to one main administrator... ...other privileged/unprivileged users of the system can rely on "AppMan" instead --- APP-MANAGER | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 5c5827a06..09789ee99 100644 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -116,8 +116,23 @@ function _online_check(){ export AMCATALOGUEMARKDOWNS="https://raw.githubusercontent.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/main/apps" export AMCATALOGUEICONS="https://raw.githubusercontent.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/main/icons" -# Determine system architecture +# Determine system architecture and current user export arch="$HOSTTYPE" +export currentuser="$USER" +if [ "$AMCLI" == am ]; then + ampathowner=$(ls -ld /opt/am | awk 'NR==1 {print $3}') + if [ "$ampathowner" != "$currentuser" ]; then + echo ' 💀 ERROR: you are not the owner of /opt/am, so you cannot use "AM"' + echo '--------------------------------------------------------------------------' + echo ' The user that have installed "AM" on this system is "'"$ampathowner"'"' + echo ' you are only allowed to use the installed apps, not to manage them.' + echo '--------------------------------------------------------------------------' + echo ' Please, contact "'"$ampathowner"'" to change the ownership of /opt/am or' + echo ' consider using "AppMan" instead, see https://github.com/ivan-hc/AppMan' + echo '--------------------------------------------------------------------------' + exit + fi +fi if [[ -f "$AMPATH"/new-repo.txt ]]; then AMREPO=$(<"$AMPATH/new-repo.txt") # Utilizing command substitution with < for more efficient file reading From 832f77685efa42d8f11a3e40b8f97fc5ed065baa Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 03:10:40 +0200 Subject: [PATCH 15/16] Update install.am --- modules/install.am | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/modules/install.am b/modules/install.am index e1b805c6d..c87043059 100644 --- a/modules/install.am +++ b/modules/install.am @@ -16,7 +16,7 @@ while [ -n "$1" ]; do esac if [ $AMCLI == am ] 2>/dev/null; then - $SUDOCOMMAND echo -ne "\r" + $SUDOCOMMAND echo "" 2>/dev/null if ! $SUDOCOMMAND -n true 2>/dev/null; then exit fi @@ -160,24 +160,17 @@ while [ -n "$1" ]; do $SUDOCOMMAND ./$arg echo -ne " Configuring $(echo '"'$arg'"' | tr a-z A-Z)...\r" && echo -ne " \r" && - + $SUDOCOMMAND chown -R $currentuser $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) 2> /dev/null if test -f $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/AM-updater; then - $SUDOCOMMAND mkdir $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer 2> /dev/null && - $SUDOCOMMAND wget -q $APPSDB/$arg -O $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer/$arg - fi - + mkdir $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer 2> /dev/null && + wget -q $APPSDB/$arg -O $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/.am-installer/$arg + fi && if test -d $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons; then find $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons/* -xtype l -delete 2> /dev/null if [ -z "$(ls -A $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons)" ]; then - $SUDOCOMMAND wget -q "$AMCATALOGUEICONS"/$arg.png -O $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons/$arg + wget -q "$AMCATALOGUEICONS"/$arg.png -O $APPSPATH/$(cd $APPSPATH && ls -td * | head -1)/icons/$arg fi - fi - - if [ "$AMCLI" == am ]; then - $SUDOCOMMAND chown -R :sudo $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) 2> /dev/null - $SUDOCOMMAND find $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) -exec chmod 775 {} \; 2> /dev/null - fi - + fi && if [ $AMCLI == appman ] 2>/dev/null; then sed -i "s#Icon=/opt#Icon=$HOME/$APPSDIR#g" "$DATADIR"/applications/AM*.desktop 2> /dev/null sed -i "s#Exec=$arg#Exec=$HOME/.local/bin/$arg#g" "$DATADIR"/applications/AM*.desktop 2> /dev/null From e8ab02e330ec0a86c776fe5c8a80b30ac807556c Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 24 Apr 2024 03:11:54 +0200 Subject: [PATCH 16/16] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 06c94df67..41df4b645 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Initially the two projects traveled in parallel to each other, until version 5, #### To be more detailed, here is an overview of how apps are installed by "AM" and "AppMan" Where `$PROGRAM` is the application we're going to install: -- "AM" (ie the `am` command) installs programs and works at system level (i.e. for all the users). "AM" requires the `sudo` privileges but only to install and remove the app, all the other commands can be executed as a normal user. This allows multiple users of the same system to be able to use the same installed applications. This is what an installation script installs with "AM": +- "AM" (ie the `am` command) installs programs system-wide. "AM" requires the `sudo` privileges but only to install and remove the app, all the other commands can be executed as a normal user. This allows multiple users of the same system to be able to use the same installed applications, **while the general use of "AM" (installing, updating, consulting lists...) will only be permitted to the system administrator/owner of the /opt/am directory and all the directories managed by "AM", and to the user "root"**. This is what an installation script installs with "AM": /opt/$PROGRAM/ /opt/$PROGRAM/$PROGRAM @@ -101,6 +101,8 @@ If the distro is immutable instead, the path of the launcher (the last line abov /usr/local/share/applications/AM-$PROGRAM.desktop Since version 5.1 the installation process have introduced a check to find read-only filesystems (`grep "[[:space:]]ro[[:space:],]" /proc/mounts`), if there are mountpoints like this, your distro may be an immutable one, so an `/usr/local/share/applications` directory will be created and the installation script will be patched to redirect the installation of launchers in that path to solve the issue. +**NOTE: Non-privileged users who wish to use "AM" on multi-account systems will be advised to contact the administrator to change ownership of /opt/am or to consider using "AppMan".** + - "AppMan" (ie the `appman` command) instead does not need root privileges to work, it allows you to choose where to install your applications into your `$HOME` directory. AppMan is also usable as a portable app (i.e. you can download and place it wherever you want) and it is able to update itself, anywhere! At first start it will ask you where to install the apps and it will create the directory for you (the configuration file is in `~/.config/appman`). For example, suppose you want install everything in "Applicazioni" (the italian of "applications"), this is the structure of what an installation scripts installs with "AppMan" instead: ~/Applicazioni/$PROGRAM/