From d2f6ad273dba0cb8557754e4f26819a9b3e86218 Mon Sep 17 00:00:00 2001 From: VetheonGames Date: Mon, 8 Jan 2024 17:53:28 -0700 Subject: [PATCH] Change how we are handle the update alias and path export to go to the right places, and be verbose about it --- allpac/install.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/allpac/install.sh b/allpac/install.sh index 956e803..80edbe4 100644 --- a/allpac/install.sh +++ b/allpac/install.sh @@ -138,17 +138,23 @@ if [[ "$SHELL" == *"bash"* ]]; then elif [[ "$SHELL" == *"zsh"* ]]; then shell_rc="$HOME/.zshrc" else - echo "Unsupported shell. Please manually add the following to your shell configuration:" - echo 'export PATH=$PATH:$HOME/.allpac/bin' + echo "Unsupported shell. Please manually add the following alias to your shell configuration:" echo "alias allpac-update-system='$HOME/.allpac/bin/allpac-updater.sh'" exit 1 fi -# Add AllPac to the system path and set up alias in the user's shell configuration file -{ - echo 'export PATH=$PATH:$HOME/.allpac/bin' - echo "alias allpac-update-system='$HOME/.allpac/bin/allpac-updater.sh'" -} >> "$shell_rc" +# Check if the alias already exists in the shell configuration file +if ! grep -q "alias allpac-update-system=" "$shell_rc"; then + # Alias not found, add it to the shell configuration file + echo "alias allpac-update-system='$HOME/.allpac/bin/allpac-updater.sh'" >> "$shell_rc" + echo "Alias added to $shell_rc" +else + echo "Alias already exists in $shell_rc" +fi + +echo "Adding AllPac to the system path for all users..." +echo 'export PATH=$PATH:$HOME/.allpac/bin' | sudo tee -a /etc/profile.d/allpac.sh > /dev/null +sudo chmod +x /etc/profile.d/allpac.sh echo "Cleaning up..." cd ../../ || exit