homelab/scripts/day0bootstrap.sh
nathan e16f98a183 feat(bootstrap)!: introduce unified bootstrap system with modular libraries
BREAKING CHANGE: day0bootstrap.sh deprecated in favor of bootstrap.sh

- Add scripts/bootstrap.sh (488 lines): Unified entrypoint supporting multiple hardware types (Proxmox/Docker VMs/Pi)
- Create scripts/lib/ modular library system:
  - detection.sh: OS/hardware/container detection (362 lines)
  - fingerprint.sh: System fingerprinting and inventory (494 lines)
  - network.sh: IP configuration and VLAN placement (356 lines)
  - proxmox.sh: PVE post-install automation (453 lines)
  - validation.sh: Comprehensive pre-flight checks (510 lines)
- Add validation tools: validate-node.sh, onboarding.sh, pi_init.sh
- Deprecate scripts/day0bootstrap.sh with graceful redirect wrapper
- Document architecture in scripts/README.md (495 lines) and PROXMOX-COMPARISON.md
- Update SOP-002 with new bootstrap workflow
- Add nodes/watchtower/compose.yaml (Raspberry Pi 5 stack)

Migration: Existing day0bootstrap.sh users automatically redirected to new system after 5-second warning. No manual intervention required.

Ref: Infrastructure automation modernization per active-tasks.md
2026-04-12 22:48:19 -04:00

114 lines
3.7 KiB
Bash

#!/bin/bash
# ==============================================================================
# DEPRECATED: day0bootstrap.sh
# ==============================================================================
# ⚠️ DEPRECATION NOTICE
# This script is deprecated and will be removed in a future release.
# Please use the unified bootstrap.sh script instead:
#
# ./bootstrap.sh --hardware-type pi
#
# This wrapper will redirect to bootstrap.sh with appropriate flags.
# ==============================================================================
set -euo pipefail
# Show deprecation warning
echo "=======================================" >&2
echo "⚠️ DEPRECATION WARNING" >&2
echo "=======================================" >&2
echo "day0bootstrap.sh is deprecated!" >&2
echo "" >&2
echo "Please use: ./bootstrap.sh" >&2
echo "" >&2
echo "Redirecting to bootstrap.sh in 5 seconds..." >&2
echo "Press Ctrl+C to cancel" >&2
echo "=======================================" >&2
sleep 5
# Redirect to unified bootstrap
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "${SCRIPT_DIR}/bootstrap.sh" --hardware-type pi "$@"
# ==============================================================================
# LEGACY CODE BELOW (no longer executed)
# ==============================================================================
exit 0
# --- 1. SET STATIC IP (Netplan) ---
echo "[⚙] Configuring Static IP to 10.0.0.200..."
# Fix permissions on existing netplan files
sudo chmod 600 /lib/netplan/*.yaml 2>/dev/null || true
# Find the active physical interface
INTERFACE=$(ip -o link show | awk -F': ' '$2 != "lo" {print $2}' | head -n1)
sudo mkdir -p /etc/netplan
sudo cat <<EOF > /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
$INTERFACE:
addresses:
- 10.0.0.200/24
nameservers:
addresses: [10.0.0.2, 8.8.8.8]
routes:
- to: default
via: 10.0.0.1
EOF
# Fix permissions so Netplan doesn't complain
sudo chmod 600 /etc/netplan/01-netcfg.yaml
echo "[✓] Netplan config created. Applying now..."
sudo netplan apply
echo "[⚙] Waiting for network to stabilize..."
sleep 3
# Verify network connectivity
if ! ping -c 1 8.8.8.8 &>/dev/null; then
echo "[!] Warning: Network may not be ready yet, but continuing..."
fi
# --- 2. INSTALL DOCKER ---
echo "[⚙] Installing Docker (using Debian Bookworm repo for Trixie compatibility)..."
# Remove any existing Docker repository configurations
sudo rm -f /etc/apt/sources.list.d/docker.list
sudo rm -f /etc/apt/sources.list.d/docker*.list
sudo apt-get update -qq
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg --yes
# Manually set to 'bookworm' because 'trixie' doesn't exist on Docker's servers yet
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update -qq
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Allow current user to run docker without sudo
sudo usermod -aG docker $USER
echo "[✓] Docker installed."
# --- 3. INSTALL ANSIBLE ---
echo "[⚙] Installing Ansible..."
# On Debian, we don't use the Ubuntu PPA. We install from the default repos.
sudo apt-get install -y ansible
echo "[✓] Ansible installed."
echo "=========================================="
echo "BOOTSTRAP COMPLETE"
echo "IP: 10.0.0.200 (Connection will drop shortly)"
echo "Docker & Ansible: Ready"
echo "=========================================="