#!/bin/bash # ALTR Sidecar Repository Setup Script # This script configures your system to install ALTR Sidecar via DNF/YUM # Usage: curl -fsSL https://rpm-sidecar.altr.com/setup.sh | sudo bash set -euo pipefail # Configuration REPO_URL="https://rpm-sidecar.altr.com" REPO_NAME="altr-sidecar" GPG_KEY_URL="$REPO_URL/GPG-KEY-ALTR" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Logging functions log_info() { echo -e "${BLUE}[INFO]${NC} $1" } log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" } log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" } log_error() { echo -e "${RED}[ERROR]${NC} $1" } # Check if running as root if [[ $EUID -ne 0 ]]; then log_error "This script must be run as root (use sudo)" exit 1 fi # Detect OS and version if [ -f /etc/os-release ]; then . /etc/os-release OS=$NAME VERSION=$VERSION_ID else log_error "Cannot detect OS version" exit 1 fi log_info "Detected OS: $OS $VERSION" # Check if this is a supported OS case "$OS" in "Rocky Linux"|"Red Hat Enterprise Linux"|"CentOS Linux"|"AlmaLinux"|"Fedora") log_info "Supported OS detected" ;; *) log_warning "OS not officially tested. Proceeding anyway..." ;; esac # Check for DNF/YUM if command -v dnf &> /dev/null; then PKG_MGR="dnf" elif command -v yum &> /dev/null; then PKG_MGR="yum" else log_error "Neither DNF nor YUM package manager found" exit 1 fi log_info "Using package manager: $PKG_MGR" # Check for Podman (required dependency) if ! command -v podman &> /dev/null; then log_warning "Podman not found. Installing Podman..." $PKG_MGR install -y podman # Enable podman socket for systemd systemctl enable --now podman.socket log_success "Podman installed and enabled" else log_info "Podman already installed" fi # Create repository file REPO_FILE="/etc/yum.repos.d/$REPO_NAME.repo" log_info "Creating repository configuration: $REPO_FILE" cat > "$REPO_FILE" << EOF [altr-sidecar] name=ALTR Sidecar Repository baseurl=$REPO_URL enabled=1 gpgcheck=1 gpgkey=$GPG_KEY_URL priority=1 skip_if_unavailable=0 metadata_expire=300 EOF log_success "Repository configuration created" # Download and import GPG key log_info "Downloading and importing GPG key..." GPG_KEY_FILE="/tmp/GPG-KEY-ALTR" if curl -fsSL "$GPG_KEY_URL" -o "$GPG_KEY_FILE"; then # Import to RPM database rpm --import "$GPG_KEY_FILE" log_success "GPG key imported successfully" # Clean up rm -f "$GPG_KEY_FILE" else log_error "Failed to download GPG key from $GPG_KEY_URL" exit 1 fi # Test repository access log_info "Testing repository access..." if $PKG_MGR makecache --repo=altr-sidecar &> /dev/null; then log_success "Repository access verified" else log_error "Failed to access repository. Check your internet connection and firewall settings." exit 1 fi # Check if packages are available log_info "Checking available packages..." if $PKG_MGR list available altr-sidecar --repo=altr-sidecar &> /dev/null; then AVAILABLE_VERSION=$($PKG_MGR list available altr-sidecar --repo=altr-sidecar 2>/dev/null | grep altr-sidecar | awk '{print $2}' | head -1) log_success "ALTR Sidecar package available (version: $AVAILABLE_VERSION)" else log_warning "ALTR Sidecar package not found in repository" fi echo "" echo "╔══════════════════════════════════════════════════════════════════════════════╗" echo "║ SETUP COMPLETE ║" echo "╚══════════════════════════════════════════════════════════════════════════════╝" echo "" log_success "ALTR Sidecar repository has been configured successfully!" echo "" echo "Next steps:" echo " 1. Install ALTR Sidecar:" echo " sudo $PKG_MGR install altr-sidecar" echo "" echo " 2. Configure the sidecar (edit the configuration file):" echo " sudo nano /etc/opt/altr-sidecar/config.env" echo "" echo " 3. Start the sidecar service:" echo " sudo systemctl daemon-reload" echo " sudo systemctl start altr-sidecar" echo "" echo " 4. Check service status:" echo " sudo systemctl status altr-sidecar" echo "" echo "For detailed installation and configuration instructions, visit:" echo "https://docs.altr.com/sidecar/installation" echo "" echo "For support and troubleshooting:" echo "https://docs.altr.com/sidecar/troubleshooting"