Skip to content

Instantly share code, notes, and snippets.

@alexlovelltroy
Created February 24, 2025 19:39
Show Gist options
  • Save alexlovelltroy/96bfc8bb6f59c0845617a0dc659871de to your computer and use it in GitHub Desktop.
Save alexlovelltroy/96bfc8bb6f59c0845617a0dc659871de to your computer and use it in GitHub Desktop.
One liner to install the latest OpenCHAMI RPM
#!/bin/bash
set -euo pipefail
# Set repository details (update these)
OWNER="openchami"
REPO="release"
# Fetch latest release information
echo -e "\033[1m🔍 Fetching latest release information for ${OWNER}/${REPO}...\033[0m"
API_URL="https://api.github.com/repos/${OWNER}/${REPO}/releases/latest"
release_json=$(curl -s "$API_URL")
# Print release notes
echo -e "\n\033[1m📝 Release Notes:\033[0m"
echo -e "---------------------"
echo "$release_json" | jq -r '.body'
echo -e "---------------------\n"
# Optionally import public key if available as an asset (e.g., with .asc extension)
key_url=$(echo "$release_json" | jq -r '.assets[] | select(.name | endswith(".asc")) | .browser_download_url' | head -n 1)
key_name=$(echo "$release_json" | jq -r '.assets[] | select(.name | endswith(".asc")) | .name' | head -n 1)
if [[ -n "$key_url" ]]; then
echo -e "\033[1m🔑 Downloading public key: ${key_name}...\033[0m"
curl -L -o "$key_name" "$key_url"
echo -e "\033[1m📥 Importing public key...\033[0m"
sudo rpm --import "$key_name"
else
echo -e "\033[1m⚠️ No public key asset found in the release. Ensure your RPM key is already imported.\033[0m"
fi
# Find the first asset that ends with .rpm
rpm_url=$(echo "$release_json" | jq -r '.assets[] | select(.name | endswith(".rpm")) | .browser_download_url' | head -n 1)
rpm_name=$(echo "$release_json" | jq -r '.assets[] | select(.name | endswith(".rpm")) | .name' | head -n 1)
if [[ -z "$rpm_url" ]]; then
echo -e "\033[1m❌ No RPM asset found in the latest release.\033[0m"
exit 1
fi
echo -e "\033[1m📦 Downloading RPM: ${rpm_name}...\033[0m"
curl -L -o "$rpm_name" "$rpm_url"
echo -e "\033[1m🔍 Verifying RPM signature...\033[0m"
rpm --checksig "$rpm_name"
echo -e "\033[1m🚀 Installing ${rpm_name}...\033[0m"
sudo rpm -Uvh "$rpm_name"
echo -e "\033[1m✅ Installation complete.\033[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment