Installers/allpac/update.sh

49 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
2024-01-07 18:22:59 -07:00
# Define the repository, binary path, and version URL
REPO_URL="https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac.git"
BINARY_PATH="$HOME/.allpac/bin/allpac"
2024-01-07 18:22:59 -07:00
VERSION_URL="https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac/raw/branch/main/.version"
2024-01-07 18:22:59 -07:00
# Step 1: Check the current version of AllPac
local_version=$(allpac version 2>/dev/null)
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; }
2024-01-07 18:22:59 -07:00
echo "Ensuring we have up to date depends..."
go mod tidy
echo "Building the new binary..."
go build -o allpac_new
2024-01-07 18:22:59 -07:00
# 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
2024-01-07 18:22:59 -07:00
# Step 5: Clean up
echo "Cleaning up..."
cd ../../
rm -rf AllPacUpdate
echo "Update complete."