2024-01-07 18:05:38 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
mkdir -p ~/.allpac/cache ~/.allpac/logs ~/.allpac/bin
|
2024-01-07 20:25:50 -07:00
|
|
|
touch ~/.allpac/pkg.list
|
2024-01-07 18:05:38 -07:00
|
|
|
|
|
|
|
go_version=$(go version 2>/dev/null)
|
|
|
|
required_version="go1.21.5"
|
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
echo "Checking if Go is installed..."
|
2024-01-07 18:05:38 -07:00
|
|
|
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
|
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
echo "Compatible Go version is installed!"
|
|
|
|
echo "Checking if Git is installed..."
|
|
|
|
|
2024-01-07 18:05:38 -07:00
|
|
|
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
|
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
echo "Git is installed!"
|
|
|
|
|
|
|
|
echo "Cloning AllPac Repository from Git..."
|
|
|
|
sleep 1
|
|
|
|
|
2024-01-07 18:05:38 -07:00
|
|
|
git clone https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac.git
|
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
echo "Descending into cloned repo..."
|
|
|
|
sleep 1
|
2024-01-07 18:05:38 -07:00
|
|
|
cd AllPac/cmd/ || exit
|
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
echo "Ensuring we have up to date dependencies..."
|
2024-01-07 18:05:38 -07:00
|
|
|
go mod tidy
|
2024-01-07 20:16:54 -07:00
|
|
|
sleep 1
|
2024-01-07 18:05:38 -07:00
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
echo "Building binary..."
|
2024-01-07 18:05:38 -07:00
|
|
|
go build -o ~/.allpac/bin/allpac
|
2024-01-07 20:16:54 -07:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
echo "Binary built!"
|
2024-01-07 18:05:38 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
echo "Adding AllPac to the system path..."
|
|
|
|
sleep 1
|
2024-01-07 18:05:38 -07:00
|
|
|
echo 'export PATH=$PATH:$HOME/.allpac/bin' >> "$shell_rc"
|
|
|
|
source "$shell_rc"
|
|
|
|
|
2024-01-07 18:10:01 -07:00
|
|
|
updater_url="https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/update.sh"
|
2024-01-07 20:16:54 -07:00
|
|
|
echo "Downloading updater script..."
|
2024-01-07 18:10:01 -07:00
|
|
|
wget -O ~/.allpac/bin/allpac-updater.sh "$updater_url"
|
2024-01-07 20:16:54 -07:00
|
|
|
sleep 1
|
2024-01-07 18:10:01 -07:00
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
echo "Setting updater script permissions..."
|
2024-01-07 18:10:01 -07:00
|
|
|
chmod u+rwx ~/.allpac/bin/allpac-updater.sh
|
2024-01-07 20:16:54 -07:00
|
|
|
sleep 1
|
2024-01-07 18:10:01 -07:00
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
echo "Aliasing the updater script..."
|
2024-01-07 18:10:01 -07:00
|
|
|
echo "alias allpac-update-system='~/.allpac/bin/allpac-updater.sh'" >> "$shell_rc"
|
|
|
|
source "$shell_rc"
|
|
|
|
|
2024-01-07 20:16:54 -07:00
|
|
|
echo "Cleaning up..."
|
2024-01-07 18:05:38 -07:00
|
|
|
cd ../../
|
|
|
|
rm -rf AllPac
|
|
|
|
|
|
|
|
echo "AllPac setup complete."
|