Files
gitea-migration/setup/macbook.sh
S 720197bb10 feat: add OS compatibility checks before running platform-specific logic
- 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>
2026-02-26 19:00:13 -06:00

104 lines
3.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# =============================================================================
# setup/macbook.sh — Install prerequisites on MacBook (runs locally)
# =============================================================================
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
source "${SCRIPT_DIR}/../lib/common.sh"
log_info "=== MacBook Setup ==="
# --------------------------------------------------------------------------
# OS check — this script uses Homebrew, launchctl, Xcode tools (macOS only)
# --------------------------------------------------------------------------
require_local_os "Darwin" "macbook.sh must run on macOS — detected a non-macOS system"
# --------------------------------------------------------------------------
# Homebrew
# --------------------------------------------------------------------------
if ! command -v brew &>/dev/null; then
log_error "Homebrew is not installed."
log_error "Install it manually: /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
log_error "Then re-run this script."
exit 1
fi
log_success "Homebrew found"
# --------------------------------------------------------------------------
# Brew packages
# --------------------------------------------------------------------------
BREW_PACKAGES=(jq curl gettext shellcheck gh)
for pkg in "${BREW_PACKAGES[@]}"; do
if brew list "$pkg" &>/dev/null; then
log_success "$pkg already installed"
else
log_info "Installing $pkg..."
brew install "$pkg"
log_success "$pkg installed"
fi
done
# --------------------------------------------------------------------------
# Verify built-in tools
# --------------------------------------------------------------------------
BUILTINS=(ssh git scp)
for tool in "${BUILTINS[@]}"; do
if command -v "$tool" &>/dev/null; then
log_success "$tool found"
else
log_error "$tool not found — this should be built into macOS"
exit 1
fi
done
# Verify envsubst specifically (comes from gettext)
if command -v envsubst &>/dev/null; then
log_success "envsubst found (from gettext)"
else
log_error "envsubst not found. Try: brew link --force gettext"
exit 1
fi
# --------------------------------------------------------------------------
# Xcode Command Line Tools
# --------------------------------------------------------------------------
if xcode-select -p &>/dev/null; then
log_success "Xcode Command Line Tools found"
else
log_info "Installing Xcode Command Line Tools..."
xcode-select --install
log_warn "Xcode CLI Tools installation started. Wait for it to finish, then re-run this script."
exit 0
fi
# --------------------------------------------------------------------------
# Network access check (if .env exists)
# --------------------------------------------------------------------------
if [[ -f "${SCRIPT_DIR}/../.env" ]]; then
load_env
if [[ -n "${UNRAID_IP:-}" ]]; then
if ssh_check UNRAID; then
log_success "SSH to Unraid ($UNRAID_IP) OK"
else
log_warn "Cannot SSH to Unraid ($UNRAID_IP) — check SSH config"
fi
fi
if [[ -n "${FEDORA_IP:-}" ]]; then
if ssh_check FEDORA; then
log_success "SSH to Fedora ($FEDORA_IP) OK"
else
log_warn "Cannot SSH to Fedora ($FEDORA_IP) — check SSH config"
fi
fi
else
log_info "No .env file — skipping network checks. Run setup/configure_env.sh first."
fi
# --------------------------------------------------------------------------
# Summary
# --------------------------------------------------------------------------
log_success "All MacBook prerequisites satisfied"