#!/bin/bash set -euo pipefail # Anvl installer # Usage: curl -fsSL https://anvl.sh | bash # # Environment variables: # ANVL_VERSION - Version to install (default: latest) # ANVL_INSTALL_DIR - Installation directory (default: /usr/local/bin) VERSION="${ANVL_VERSION:-latest}" INSTALL_DIR="${ANVL_INSTALL_DIR:-/usr/local/bin}" DOWNLOAD_BASE="https://anvl.sh/download" VERSION_API="https://anvl.sh/version" # --- Colors --- RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' BOLD='\033[1m' NC='\033[0m' info() { echo -e "${GREEN}[INFO]${NC} $1"; } warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; } # --- Banner --- echo -e "${BOLD}" echo " _ _ " echo " / \\ _ ____ __| |" echo " / _ \\ | '_ \\ \\ / /| |" echo " / ___ \\| | | \\ V / | |" echo " /_/ \\_\\_| |_|\\_/ |_|" echo -e "${NC}" echo -e " ${BLUE}Self-hosted PaaS platform${NC}" echo "" # --- Pre-flight checks --- # Must be Linux if [[ "$(uname -s)" != "Linux" ]]; then error "Anvl only supports Linux. Detected OS: $(uname -s)" fi # Detect architecture ARCH=$(uname -m) case "$ARCH" in x86_64) ARCH="amd64" ;; aarch64|arm64) ARCH="arm64" ;; *) error "Unsupported architecture: $ARCH. Anvl supports amd64 and arm64." ;; esac # ARM64 binaries not yet available if [[ "$ARCH" == "arm64" ]]; then warn "ARM64 binaries are not yet available. Only amd64 is supported in this release." warn "Follow https://github.com/ekklosaas/anvl/issues for ARM64 support updates." error "Installation aborted: unsupported architecture arm64." fi # Must be root if [[ $EUID -ne 0 ]]; then error "This script must be run as root. Use: sudo bash install.sh" fi # Check required tools for cmd in curl; do if ! command -v "$cmd" &>/dev/null; then error "Required tool '${cmd}' is not installed. Please install it and retry." fi done # Check Docker is installed (required for running apps) if ! command -v docker &>/dev/null; then warn "Docker is not installed. Anvl requires Docker to run applications." warn "Install Docker first: https://docs.docker.com/engine/install/" echo "" fi # --- Resolve version --- if [[ "$VERSION" == "latest" ]]; then info "Fetching latest version..." if VERSION=$(curl -fsSL "$VERSION_API" 2>/dev/null | sed -E 's/.*"version":"([^"]+)".*/\1/'); then if [[ -z "$VERSION" ]]; then error "Could not determine latest version. Set ANVL_VERSION explicitly." fi info "Latest version: ${VERSION}" else error "Failed to fetch latest version from anvl.sh. Set ANVL_VERSION explicitly." fi fi info "Installing Anvl ${VERSION} for linux/${ARCH}..." echo "" # --- Ensure install directory exists --- mkdir -p "$INSTALL_DIR" # --- Download anvl binary --- ANVL_URL="${DOWNLOAD_BASE}/${VERSION}/anvl-linux-${ARCH}" info "Downloading anvl binary..." if ! curl -fsSL --progress-bar -o "${INSTALL_DIR}/anvl" "$ANVL_URL"; then error "Failed to download anvl from ${ANVL_URL}. Check that version ${VERSION} exists." fi chmod +x "${INSTALL_DIR}/anvl" info "Installed anvl to ${INSTALL_DIR}/anvl" # --- Download anvl-agent binary --- AGENT_URL="${DOWNLOAD_BASE}/${VERSION}/anvl-agent-linux-${ARCH}" info "Downloading anvl-agent binary..." if ! curl -fsSL --progress-bar -o "${INSTALL_DIR}/anvl-agent" "$AGENT_URL"; then error "Failed to download anvl-agent from ${AGENT_URL}. Check that version ${VERSION} exists." fi chmod +x "${INSTALL_DIR}/anvl-agent" info "Installed anvl-agent to ${INSTALL_DIR}/anvl-agent" echo "" # --- Verify installation --- info "Verifying installation..." if "${INSTALL_DIR}/anvl" version &>/dev/null; then INSTALLED_VERSION=$("${INSTALL_DIR}/anvl" version 2>/dev/null || echo "unknown") info "anvl version: ${INSTALLED_VERSION}" else warn "Could not verify anvl binary (may require configuration to run)." fi echo "" echo -e " ${GREEN}${BOLD}Anvl ${VERSION} installed successfully!${NC}" echo "" echo -e " ${BOLD}Quick start (recommended):${NC}" echo "" echo -e " ${BLUE}anvl setup --systemd${NC}" echo "" echo -e " This runs the setup wizard and installs Anvl as a systemd service." echo "" echo -e " ${BOLD}Other options:${NC}" echo -e " ${BLUE}anvl setup${NC} Setup without systemd" echo -e " ${BLUE}anvl setup --systemd-only${NC} Install systemd units only (config must exist)" echo "" echo -e " ${BOLD}Documentation:${NC} https://anvl.sh" echo ""