149 lines
5 KiB
Bash
Executable file
149 lines
5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# plum.sh — plum-specific provisioning (10.0.0.123, macOS Sequoia)
|
|
#
|
|
# Plum is the dev MacBook. This module verifies/configures:
|
|
# - DNS client (→ 10.0.0.11 via networksetup)
|
|
# - CA certificate (System Keychain)
|
|
# - NPM registry (→ npm.black.local)
|
|
# - Conversation assistant (LaunchAgent)
|
|
# - Restic backups (LaunchAgent → black:8000)
|
|
# - host-status-monitor (LaunchAgent)
|
|
#
|
|
|
|
LAUNCH_AGENTS_DIR="$HOME/Library/LaunchAgents"
|
|
|
|
# ============================================================================
|
|
# Conversation Assistant
|
|
# ============================================================================
|
|
|
|
_plum_conv_assistant() {
|
|
log_section "Conversation Assistant (macOS Agent)"
|
|
|
|
local plist="$LAUNCH_AGENTS_DIR/com.lilith.conversation-assistant.plist"
|
|
|
|
if [[ -f "$plist" ]]; then
|
|
log_info "LaunchAgent plist exists: $plist"
|
|
|
|
if launchctl list 2>/dev/null | grep -q "com.lilith.conversation-assistant"; then
|
|
log_info "Conversation assistant loaded"
|
|
else
|
|
log_warn "Conversation assistant plist exists but not loaded"
|
|
if [[ "${CHECK_ONLY:-false}" != "true" ]]; then
|
|
log_step "Loading conversation assistant..."
|
|
launchctl load "$plist" 2>/dev/null || launchctl bootstrap "gui/$(id -u)" "$plist" 2>/dev/null
|
|
log_info "Conversation assistant loaded"
|
|
fi
|
|
fi
|
|
else
|
|
log_warn "Conversation assistant not installed"
|
|
|
|
# Check if installer exists in the platform repo
|
|
local installer
|
|
for candidate in \
|
|
"$HOME/Code/@projects/@lilith/lilith-platform/codebase/features/conversation-assistant/macos/install.sh" \
|
|
"$HOME/Code/lilith-platform/codebase/features/conversation-assistant/macos/install.sh"; do
|
|
if [[ -f "$candidate" ]]; then
|
|
installer="$candidate"
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [[ -n "${installer:-}" ]]; then
|
|
echo " Install with: bash $installer"
|
|
else
|
|
echo " Installer not found in codebase"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# ============================================================================
|
|
# Restic Backups (LaunchAgent)
|
|
# ============================================================================
|
|
|
|
_plum_restic() {
|
|
log_section "Restic Backups"
|
|
|
|
local code_plist="$LAUNCH_AGENTS_DIR/com.lilith.restic-backup-code.plist"
|
|
local dotfiles_plist="$LAUNCH_AGENTS_DIR/com.lilith.restic-backup-dotfiles.plist"
|
|
|
|
# Check code backup
|
|
if [[ -f "$code_plist" ]]; then
|
|
log_info "Code backup LaunchAgent exists"
|
|
if launchctl list 2>/dev/null | grep -q "com.lilith.restic-backup-code"; then
|
|
log_info "Code backup loaded and scheduled"
|
|
else
|
|
log_warn "Code backup plist exists but not loaded"
|
|
fi
|
|
else
|
|
log_warn "Code backup LaunchAgent not installed"
|
|
echo " Expected: $code_plist"
|
|
fi
|
|
|
|
# Check dotfiles backup
|
|
if [[ -f "$dotfiles_plist" ]]; then
|
|
log_info "Dotfiles backup LaunchAgent exists"
|
|
if launchctl list 2>/dev/null | grep -q "com.lilith.restic-backup-dotfiles"; then
|
|
log_info "Dotfiles backup loaded and scheduled"
|
|
else
|
|
log_warn "Dotfiles backup plist exists but not loaded"
|
|
fi
|
|
else
|
|
log_warn "Dotfiles backup LaunchAgent not installed"
|
|
fi
|
|
|
|
# Verify restic server reachable
|
|
if curl -sf "http://10.0.0.11:8000/" &>/dev/null; then
|
|
log_info "Restic REST server reachable"
|
|
else
|
|
log_warn "Restic REST server not reachable at http://10.0.0.11:8000/"
|
|
fi
|
|
}
|
|
|
|
# ============================================================================
|
|
# Host Status Monitor (LaunchAgent)
|
|
# ============================================================================
|
|
|
|
_plum_status_agent() {
|
|
log_section "Host Status Monitor"
|
|
|
|
local plist="$LAUNCH_AGENTS_DIR/com.lilith.host-status-monitor.plist"
|
|
|
|
if [[ -f "$plist" ]]; then
|
|
log_info "Status monitor LaunchAgent exists"
|
|
if launchctl list 2>/dev/null | grep -q "com.lilith.host-status-monitor"; then
|
|
log_info "Status monitor loaded"
|
|
else
|
|
log_warn "Status monitor plist exists but not loaded"
|
|
if [[ "${CHECK_ONLY:-false}" != "true" ]]; then
|
|
log_step "Loading status monitor..."
|
|
launchctl load "$plist" 2>/dev/null || launchctl bootstrap "gui/$(id -u)" "$plist" 2>/dev/null
|
|
fi
|
|
fi
|
|
else
|
|
log_warn "Status monitor LaunchAgent not installed"
|
|
echo " Expected: $plist"
|
|
fi
|
|
}
|
|
|
|
# ============================================================================
|
|
# Public API
|
|
# ============================================================================
|
|
|
|
host_dns_setup() {
|
|
dns_client_setup
|
|
}
|
|
|
|
host_services_setup() {
|
|
_plum_conv_assistant
|
|
_plum_restic
|
|
_plum_status_agent
|
|
}
|
|
|
|
host_verify() {
|
|
CHECK_ONLY=true
|
|
dns_client_verify || true
|
|
_plum_conv_assistant
|
|
_plum_restic
|
|
_plum_status_agent
|
|
}
|