Files
gitea-migration/setup/macbook.sh
S 5f043cbb45 feat: add setup scripts (configure_env, macbook, unraid, fedora)
- configure_env.sh: interactive 50-prompt wizard with progress [N/50],
  input validation (IP, port, email, path, URL, bool, password, ssl_mode),
  conditional SSL prompts based on SSL_MODE, summary with masked passwords
- macbook.sh: Homebrew packages, envsubst, Xcode CLI tools, SSH tests
- unraid.sh: Docker verify, docker-compose + jq static binary install
- fedora.sh: Docker CE + compose plugin install, jq, docker group setup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 15:07:34 -06:00

99 lines
3.3 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 ==="
# --------------------------------------------------------------------------
# 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"