- lib/common.sh: add require_local_os, require_remote_os, require_remote_pkg_manager - setup/macbook.sh: require macOS (Darwin) - setup/unraid.sh: require remote is Linux - setup/fedora.sh: require remote is Linux + has dnf (RPM-based) - manage_runner.sh: native runner add/remove requires macOS - run_all.sh: control plane must be macOS - preflight.sh: 3 new checks (1: local=macOS, 2: Unraid=Linux, 3: Fedora=Linux+dnf) - phase5_migrate_pipelines.sh: fix sed -i to be portable (no macOS-only syntax) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
111 lines
4.5 KiB
Bash
Executable File
111 lines
4.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# =============================================================================
|
|
# setup/fedora.sh — Install prerequisites on Fedora (runs via SSH from MacBook)
|
|
# =============================================================================
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
source "${SCRIPT_DIR}/../lib/common.sh"
|
|
|
|
load_env
|
|
require_vars FEDORA_IP FEDORA_SSH_USER FEDORA_GITEA_DATA_PATH
|
|
|
|
log_info "=== Fedora Setup ==="
|
|
|
|
# --------------------------------------------------------------------------
|
|
# OS check — must be Linux with dnf (RPM-based distro like Fedora/RHEL/CentOS)
|
|
# This script uses `dnf` for all package installs. Running it against a
|
|
# Debian/Ubuntu/Arch host would fail with confusing errors.
|
|
# --------------------------------------------------------------------------
|
|
log_info "Verifying Fedora OS..."
|
|
require_remote_os "FEDORA" "Linux" "Fedora target must be a Linux machine — check FEDORA_IP in .env"
|
|
require_remote_pkg_manager "FEDORA" "dnf" "Fedora target must have dnf (RPM-based distro) — this script won't work on Debian/Ubuntu"
|
|
|
|
# --------------------------------------------------------------------------
|
|
# SSH connectivity
|
|
# --------------------------------------------------------------------------
|
|
log_info "Testing SSH to Fedora..."
|
|
if ! ssh_check FEDORA; then
|
|
log_error "Cannot SSH to Fedora at $FEDORA_IP as $FEDORA_SSH_USER"
|
|
exit 1
|
|
fi
|
|
log_success "SSH to Fedora OK"
|
|
|
|
# --------------------------------------------------------------------------
|
|
# Docker CE
|
|
# --------------------------------------------------------------------------
|
|
if ssh_exec FEDORA "docker --version" &>/dev/null; then
|
|
log_success "Docker found on Fedora"
|
|
else
|
|
log_info "Installing Docker CE on Fedora..."
|
|
ssh_exec FEDORA "sudo dnf -y install dnf-plugins-core"
|
|
ssh_exec FEDORA "sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo"
|
|
ssh_exec FEDORA "sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin"
|
|
ssh_exec FEDORA "sudo systemctl enable --now docker"
|
|
|
|
# Add user to docker group
|
|
ssh_exec FEDORA "sudo usermod -aG docker $FEDORA_SSH_USER"
|
|
log_warn "User $FEDORA_SSH_USER added to docker group. You may need to re-login for this to take effect."
|
|
|
|
if ssh_exec FEDORA "docker --version" &>/dev/null; then
|
|
log_success "Docker CE installed on Fedora"
|
|
else
|
|
log_error "Failed to install Docker on Fedora"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# --------------------------------------------------------------------------
|
|
# docker compose plugin
|
|
# --------------------------------------------------------------------------
|
|
if ssh_exec FEDORA "docker compose version" &>/dev/null; then
|
|
log_success "docker compose (plugin) found on Fedora"
|
|
else
|
|
log_error "docker compose plugin not found. It should have been installed with docker-ce."
|
|
exit 1
|
|
fi
|
|
|
|
# --------------------------------------------------------------------------
|
|
# jq
|
|
# --------------------------------------------------------------------------
|
|
if ssh_exec FEDORA "jq --version" &>/dev/null; then
|
|
log_success "jq found on Fedora"
|
|
else
|
|
log_info "Installing jq on Fedora..."
|
|
ssh_exec FEDORA "sudo dnf -y install jq"
|
|
if ssh_exec FEDORA "jq --version" &>/dev/null; then
|
|
log_success "jq installed on Fedora"
|
|
else
|
|
log_error "Failed to install jq on Fedora"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# --------------------------------------------------------------------------
|
|
# Verify Docker works without sudo
|
|
# --------------------------------------------------------------------------
|
|
log_info "Testing Docker without sudo..."
|
|
if ssh_exec FEDORA "docker run --rm hello-world" &>/dev/null; then
|
|
log_success "Docker runs without sudo"
|
|
else
|
|
log_warn "Docker requires sudo or group membership hasn't taken effect."
|
|
log_warn "Log out and back in to Fedora, then re-run this script."
|
|
fi
|
|
|
|
# --------------------------------------------------------------------------
|
|
# Data path
|
|
# --------------------------------------------------------------------------
|
|
log_info "Verifying data path: $FEDORA_GITEA_DATA_PATH"
|
|
if ssh_exec FEDORA "mkdir -p '$FEDORA_GITEA_DATA_PATH' && touch '$FEDORA_GITEA_DATA_PATH/.write-test' && rm '$FEDORA_GITEA_DATA_PATH/.write-test'"; then
|
|
log_success "Data path exists and is writable"
|
|
else
|
|
log_error "Cannot write to $FEDORA_GITEA_DATA_PATH on Fedora"
|
|
exit 1
|
|
fi
|
|
|
|
# --------------------------------------------------------------------------
|
|
# Summary
|
|
# --------------------------------------------------------------------------
|
|
log_success "All Fedora prerequisites satisfied"
|