Installers/allpac/install.sh

71 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
mkdir -p ~/.allpac/cache ~/.allpac/logs ~/.allpac/bin
go_version=$(go version 2>/dev/null)
required_version="go1.21.5"
if [[ "$go_version" != *"$required_version"* ]]; then
echo "Required Go version is not installed."
read -p "Do you want to install Go? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo pacman -Sy go
else
echo "Go not installed. Exiting."
exit 1
fi
fi
if ! command -v git &>/dev/null; then
echo "Git is not installed."
read -p "Do you want to install Git? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo pacman -S git
else
echo "Git not installed. Exiting."
exit 1
fi
fi
git clone https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac.git
cd AllPac/cmd/ || exit
go mod tidy
go build -o ~/.allpac/bin/allpac
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 'export PATH=$PATH:$HOME/.allpac/bin' >> "$shell_rc"
source "$shell_rc"
updater_url="https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/update.sh"
wget -O ~/.allpac/bin/allpac-updater.sh "$updater_url"
chmod u+rwx ~/.allpac/bin/allpac-updater.sh
echo "alias allpac-update-system='~/.allpac/bin/allpac-updater.sh'" >> "$shell_rc"
source "$shell_rc"
cd ../../
rm -rf AllPac
echo "AllPac setup complete."