Change up the way we handle adding ourselves to the system path

This commit is contained in:
VetheonGames 2024-01-08 16:26:09 -07:00
parent 054331cb5a
commit 0f41bb28ea

View File

@ -1,6 +1,6 @@
#!/bin/bash
mkdir -p ~/.allpac/cache ~/.allpac/logs ~/.allpac/bin
mkdir -p "$HOME/.allpac/cache" "$HOME/.allpac/logs" "$HOME/.allpac/bin"
echo "We are about to write a new pkg.list"
echo "Do you want us to proceed?"
@ -114,30 +114,6 @@ sleep 2
echo "Binary built!"
shell_rc=""
case $SHELL in
*/bash)
shell_rc="$HOME/.bashrc"
;;
*/zsh)
shell_rc="$HOME/.zshrc"
;;
*)
echo "Unsupported shell. Please manually add ~/.allpac/bin to your PATH."
exit 1
;;
esac
echo "Adding AllPac to the system path..."
sleep 2
if ! grep -qF 'export PATH=$PATH:$HOME/.allpac/bin' "$shell_rc"; then
echo 'export PATH=$PATH:$HOME/.allpac/bin' >> "$shell_rc"
fi
echo "Ensuring GOCACHE is set..."
if ! grep -qF 'export GOCACHE' "$shell_rc"; then
echo 'export GOCACHE=$HOME/.cache/go-build' >> "$shell_rc"
fi
updater_url="https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/update.sh"
echo "Downloading updater script..."
wget -O ~/.allpac/bin/allpac-updater.sh "$updater_url" || { echo "Failed to download updater script. Exiting."; exit 1; }
@ -147,11 +123,16 @@ echo "Setting updater script permissions..."
chmod u+rwx ~/.allpac/bin/allpac-updater.sh
sleep 2
echo "Aliasing the updater script..."
echo "alias allpac-update-system='~/.allpac/bin/allpac-updater.sh'" >> "$shell_rc"
echo "Creating a script in /etc/profile.d/ to add AllPac to the system path and set up alias for all users..."
{
echo 'export PATH=$PATH:$HOME/.allpac/bin'
echo "alias allpac-update-system='$HOME/.allpac/bin/allpac-updater.sh'"
} | sudo tee -a /etc/profile.d/allpac.sh > /dev/null
echo "Making '/etc/profile.d/allpac.sh' executable..."
sudo chmod +x /etc/profile.d/allpac.sh
echo "Cleaning up..."
cd ../../ || exit
rm -rf AllPac
echo "AllPac setup complete. Please restart your shell or source your shell configuration file to apply changes."
echo "AllPac setup complete. Please re-login (or restart the shell) to apply the changes."