IP Convention (lower = more foundational): - .1 = Gateway (warden0 bridge) - .2 = Controlplane (agent brain) - .3 = Database (PostgreSQL) - .4 = Bhyve (reserved) - .5 = CMS (Astro/Strapi) Changes: - docs/CLEAN-SLATE-REBUILD.md: Complete rebuild guide - Phase 1: Update .env to new IPs - Phase 2: Destroy existing jails - Phase 3: Rebuild from scratch with screenshots - docs/CMS-DEPLOYMENT-PLAN.md: Fix CMS IP (10.0.0.5 → 192.168.100.5) - scripts/destroy-jails.sh: Automated jail destruction Old .env had: - controlplane at .100 (wrong) - db at .2 (should be .3) - cms at .3 (should be .5) New convention aligns service importance with IP number.
86 lines
2.1 KiB
Bash
86 lines
2.1 KiB
Bash
#!/bin/sh
|
|
# Destroy all jails and prepare for clean rebuild
|
|
# Screenshot each step for documentation
|
|
|
|
set -e
|
|
|
|
PROJECT_ROOT="$(pwd)"
|
|
SCREENSHOT_DIR="${PROJECT_ROOT}/tmp/screenshots"
|
|
TIMESTAMP=$(date '+%Y%m%d-%H%M%S')
|
|
|
|
echo "=== Jail Destruction Script ==="
|
|
echo "Timestamp: $TIMESTAMP"
|
|
echo ""
|
|
|
|
# Function to screenshot
|
|
screenshot() {
|
|
local label="$1"
|
|
local file="${SCREENSHOT_DIR}/destroy-${label}-${TIMESTAMP}.txt"
|
|
script -q "$file" << 'CAPTURE'
|
|
EOF
|
|
echo "Screenshot: $file"
|
|
}
|
|
|
|
# 1. List current state
|
|
echo "=== Step 1: Current State ==="
|
|
echo "Jails:"
|
|
jls
|
|
echo ""
|
|
echo "ZFS datasets:"
|
|
zfs list -r zroot/clawdie-runtime/jails 2>/dev/null | head -20
|
|
echo ""
|
|
|
|
read -p "Continue with destruction? (yes/no): " CONFIRM
|
|
if [ "$CONFIRM" != "yes" ]; then
|
|
echo "Aborted."
|
|
exit 1
|
|
fi
|
|
|
|
# 2. Stop jails
|
|
echo ""
|
|
echo "=== Step 2: Stop Jails ==="
|
|
for jail in controlplane db; do
|
|
if bastille list | grep -q "^${jail}$"; then
|
|
echo "Stopping $jail..."
|
|
sudo bastille stop "$jail" || echo " (already stopped)"
|
|
else
|
|
echo "$jail not running"
|
|
fi
|
|
done
|
|
|
|
# 3. Destroy jails
|
|
echo ""
|
|
echo "=== Step 3: Destroy Jails ==="
|
|
for jail in controlplane db; do
|
|
if [ -d "/usr/local/bastille/jails/${jail}" ]; then
|
|
echo "Destroying $jail..."
|
|
sudo bastille destroy "$jail" || echo " (error destroying, continuing)"
|
|
else
|
|
echo "$jail already destroyed"
|
|
fi
|
|
done
|
|
|
|
# 4. Verify ZFS datasets removed
|
|
echo ""
|
|
echo "=== Step 4: Verify Cleanup ==="
|
|
echo "Remaining jail datasets:"
|
|
zfs list -r zroot/clawdie-runtime/jails 2>/dev/null || echo "No jail datasets"
|
|
|
|
echo ""
|
|
echo "Remaining bastille directories:"
|
|
ls -la /usr/local/bastille/jails/ 2>/dev/null || echo "No bastille jails"
|
|
|
|
# 5. Clean up any stale epair interfaces
|
|
echo ""
|
|
echo "=== Step 5: Clean Network ==="
|
|
echo "Stale epair interfaces:"
|
|
ifconfig | grep -E "^epair|e0a_|e0b_" || echo "None found"
|
|
|
|
echo ""
|
|
echo "=== Destruction Complete ==="
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Update .env with new IPs"
|
|
echo " 2. Run: npm run wizard (or use existing .env)"
|
|
echo " 3. Run: ansible-playbook jail-create.yaml"
|
|
echo " 4. Run: ansible-playbook controlplane-bootstrap.yaml"
|