mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-16 15:35:42 +02:00
* chore: update repository references from uptime-industries to compute-blade-community chore: update repository references from uptime-industries to compute-blade-community for consistency and clarity across all files fix: update links in CHANGELOG.md and README.md to point to the new repository location for accurate documentation fix: update Dockerfile and systemd service file to reflect the new repository URL for proper source tracking refactor: change import paths in Go files to use the new repository name for correct package referencing * chore: Add CODEOWNERS * feat: add auto-labeling --------- Co-authored-by: Cedric Kienzler <cedric@specht-labs.de>
64 lines
1.8 KiB
Bash
64 lines
1.8 KiB
Bash
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
tmp_dir=$(mktemp -d)
|
|
trap 'rm -rf "$tmp_dir"' EXIT
|
|
|
|
# Function to detect the package suffix based on the available package manager
|
|
detect_package_suffix() {
|
|
if [ -x "$(command -v dpkg)" ]; then
|
|
echo "deb"
|
|
elif [ -x "$(command -v dnf)" ]; then
|
|
echo "rpm"
|
|
elif [ -x "$(command -v pacman)" ]; then
|
|
echo "pkg.tar.zst"
|
|
else
|
|
echo "Unsupported package manager" >> /dev/stderr
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Function to get the latest release tag from GitHub
|
|
get_latest_release() {
|
|
local repo="$1"
|
|
curl -s "https://api.github.com/repos/$repo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
|
|
}
|
|
|
|
github_repo="compute-blade-community/compute-blade-agent"
|
|
package_suffix=$(detect_package_suffix)
|
|
latest_release=$(get_latest_release "$github_repo")
|
|
|
|
# Create a temporary directory for the download
|
|
tmp_dir=$(mktemp -d)
|
|
|
|
# Construct the download URL and filename based on the detected package manager and latest release
|
|
download_url="https://github.com/$github_repo/releases/download/$latest_release/compute-blade-agent_${latest_release#v}_linux_arm64.$package_suffix"
|
|
target_file="$tmp_dir/compute-blade-agent.$package_suffix"
|
|
|
|
# Download the package
|
|
echo "Downloading $download_url"
|
|
curl -Ls -o "$target_file" "$download_url"
|
|
|
|
# Install the package
|
|
echo "Installing $target_file"
|
|
case "$package_suffix" in
|
|
deb)
|
|
sudo dpkg -i "$target_file"
|
|
;;
|
|
rpm)
|
|
sudo dnf install -y "$target_file"
|
|
;;
|
|
pkg.tar.zst)
|
|
sudo pacman -U --noconfirm "$target_file"
|
|
;;
|
|
*)
|
|
echo "Unsupported package format" >> /dev/stderr
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Enable and start the service
|
|
echo "Enabling and starting compute-blade-agent"
|
|
sudo systemctl enable compute-blade-agent --now
|