49 lines
1.3 KiB
Bash
49 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Define the repository, binary path, and version URL
|
|
REPO_URL="https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac.git"
|
|
BINARY_PATH="$HOME/.allpac/bin/allpac"
|
|
VERSION_URL="https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac/raw/branch/main/cmd/.version"
|
|
|
|
# Step 1: Check the current version of AllPac
|
|
local_version=$(allpac version)
|
|
echo "Current installed version: $local_version"
|
|
|
|
# Fetch the latest version from the server
|
|
latest_version=$(curl -s "$VERSION_URL")
|
|
echo "Latest available version: $latest_version"
|
|
|
|
# Compare versions
|
|
if [ "$local_version" = "$latest_version" ]; then
|
|
echo "No Need to Update."
|
|
exit 0
|
|
fi
|
|
|
|
# Step 2: 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; }
|
|
|
|
echo "Ensuring we have up to date depends..."
|
|
go mod tidy
|
|
|
|
echo "Building the new binary..."
|
|
go build -o allpac_new
|
|
|
|
# Step 4: 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 5: Clean up
|
|
echo "Cleaning up..."
|
|
cd ../../
|
|
rm -rf AllPacUpdate
|
|
|
|
echo "Update complete."
|