Reorganize. Add allpac installer and updater
This commit is contained in:
parent
65079ccbee
commit
0dfad72a05
68
allpac/install.sh
Normal file
68
allpac/install.sh
Normal file
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Step 1: Create directories
|
||||
mkdir -p ~/.allpac/cache ~/.allpac/logs ~/.allpac/bin
|
||||
|
||||
# Step 2: Check Go version
|
||||
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."
|
||||
|
||||
# Step 3: Ask for permission to install Go
|
||||
read -p "Do you want to install Go? [Y/n] " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
# For Arch Linux and Arch-based distributions
|
||||
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
|
||||
|
||||
# Clone the Go source code
|
||||
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"
|
||||
|
||||
# Clean up
|
||||
cd ../../
|
||||
rm -rf AllPac
|
||||
|
||||
echo "AllPac setup complete."
|
31
allpac/update.sh
Normal file
31
allpac/update.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Define the repository and binary path
|
||||
REPO_URL="https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac.git"
|
||||
BINARY_PATH="$HOME/.allpac/bin/allpac"
|
||||
|
||||
# Step 1: Clone the repository
|
||||
echo "Cloning the repository..."
|
||||
git clone "$REPO_URL" AllPacUpdate
|
||||
cd AllPacUpdate/cmd/ || { echo "Failed to enter the repository directory. Exiting."; exit 1; }
|
||||
|
||||
# Step 2: Build the new binary
|
||||
echo "Building the new binary..."
|
||||
go build -o allpac_new
|
||||
|
||||
# Step 3: Replace the old binary with the new one
|
||||
if [ -f "$BINARY_PATH" ]; then
|
||||
echo "Replacing the old binary..."
|
||||
mv allpac_new "$BINARY_PATH"
|
||||
else
|
||||
echo "Binary not found. Installing the new binary..."
|
||||
mkdir -p "$(dirname "$BINARY_PATH")"
|
||||
mv allpac_new "$BINARY_PATH"
|
||||
fi
|
||||
|
||||
# Step 4: Clean up
|
||||
echo "Cleaning up..."
|
||||
cd ../../
|
||||
rm -rf AllPacUpdate
|
||||
|
||||
echo "Update complete."
|
Loading…
Reference in New Issue
Block a user