#!/bin/bash # SPDX-FileCopyrightText: Copyright (C) 2025 Akshat Kotpalliwar (alias IntegerAlex) # SPDX-License-Identifier: GPL-3.0-only set -e BINARY_NAME="rig" INSTALL_DIR="$HOME/.local/bin" RELEASE_URL="https://github.com/IntegerAlex/rig/releases/latest" echo "Installing rig - Opinionated system setup tool..." echo "Repository: IntegerAlex/rig" echo "Install directory: $HOME/.local/bin" # Detect architecture ARCH=$(uname -m) case $ARCH in x86_64) ARCH="x86_64" ;; aarch64|arm64) ARCH="aarch64" ;; *) echo "❌ Unsupported architecture: $ARCH" echo "rig currently supports x86_64 and aarch64 architectures" exit 1 ;; esac # Detect OS - only support Linux OS=$(uname -s | tr '[:upper:]' '[:lower:]') if [ "$OS" != "linux" ]; then echo "❌ Unsupported operating system: $OS" echo "rig is designed for Linux systems only" exit 1 fi echo "✅ Detected: Linux $ARCH" # Check if running on Debian-based system (has apt) if ! command -v apt-get &> /dev/null; then echo "❌ This installer requires a Debian-based Linux distribution (Ubuntu, Debian, etc.)" echo "apt-get command not found. Please install rig manually from:" echo "https://github.com/IntegerAlex/rig/releases" exit 1 fi echo "✅ Debian-based system detected" # Get latest release tag echo "📦 Fetching latest release..." LATEST_TAG=$(curl -s "https://api.github.com/repos/IntegerAlex/rig/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') if [ -z "$LATEST_TAG" ]; then echo "❌ Error: Could not fetch latest release tag" echo "Please check your internet connection and try again" exit 1 fi echo "📋 Latest release: $LATEST_TAG" # Construct download URL ASSET_NAME="rig" DOWNLOAD_URL="https://github.com/IntegerAlex/rig/releases/download/$LATEST_TAG/$ASSET_NAME" echo "⬇️ Downloading from: $DOWNLOAD_URL" # Create install directory if it doesn't exist mkdir -p "$INSTALL_DIR" # Download binary TEMP_FILE=$(mktemp) if curl -L -f -o "$TEMP_FILE" "$DOWNLOAD_URL"; then echo "✅ Download successful" else echo "❌ Error: Failed to download binary" echo "Tried URL: $DOWNLOAD_URL" echo "Available releases: https://github.com/IntegerAlex/rig/releases" rm -f "$TEMP_FILE" exit 1 fi # Make binary executable chmod +x "$TEMP_FILE" # Install to target directory INSTALL_PATH="$INSTALL_DIR/$BINARY_NAME" mv "$TEMP_FILE" "$INSTALL_PATH" echo "✅ Installed to: $INSTALL_PATH" # Add to PATH for current session and run rig if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then echo "" echo "⚠️ Adding $INSTALL_DIR to PATH for this session..." export PATH="$INSTALL_DIR:$PATH" echo "" echo "💡 For permanent PATH setup, add this to your ~/.bashrc or ~/.zshrc:" echo " export PATH=\$HOME/.local/bin:\$PATH" echo " Then run: source ~/.bashrc (or source ~/.zshrc)" fi echo "" echo "🎉 Installation complete!" echo "" # Check if we can access the terminal (even when stdin is piped) if [ -t 1 ] && [ -c /dev/tty ] 2>/dev/null; then echo "🚀 Running rig..." echo "" # Execute rig automatically - redirect stdin from /dev/tty to allow interactive prompts "$INSTALL_PATH" < /dev/tty else echo "📖 To run rig, execute:" echo " rig" echo "" echo "📚 rig is an opinionated system setup tool for Linux" echo " It helps you install essential development tools with a beautiful UI" fi