clawdie-iso/firstboot/firstboot.sh
Sam & Claude b04414da91 refactor: Rename clawdie-shell-*.sh to shell-*.sh (remove redundant prefix)
- Rename all modules: clawdie-shell-{func}.sh → shell-{func}.sh
- Update references in firstboot.sh and installerconfig
- Update self-detection case statements in each module
- Reduces naming redundancy and improves clarity

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-24 07:20:17 +00:00

57 lines
2.7 KiB
Bash

#!/bin/sh
# Clawdie-AI Firstboot Orchestrator
# Runs once on first boot (rc.d/clawdie-firstboot, REQUIRE: NETWORKING LOGIN)
# Dispatches to clawdie-shell-*.sh modules for cloud or baremetal path
set -e
SHARE="${SHARE:-/usr/local/share/clawdie-iso}"
LOG_FILE="${LOG_FILE:-/var/log/clawdie-firstboot.log}"
PROGRESS_FILE="${PROGRESS_FILE:-/var/log/clawdie-firstboot.progress}"
RC_CONF="${RC_CONF:-/etc/rc.conf}"
log_msg() { echo "$(date '+%H:%M:%S') $1" | tee -a "$LOG_FILE"; }
# Source baked build config (TARGET, GPU_DRIVER, ASSISTANT_NAME, etc.)
. "${SHARE}/build.cfg"
# Source all modules (functions available, nothing runs yet)
. "${SHARE}/firstboot/shell-gpu.sh"
. "${SHARE}/firstboot/shell-nvidia.sh"
. "${SHARE}/firstboot/shell-pkg.sh"
. "${SHARE}/firstboot/shell-env.sh"
. "${SHARE}/firstboot/shell-system.sh"
. "${SHARE}/firstboot/shell-deploy.sh"
log_msg "[firstboot] Starting — target: ${TARGET:-baremetal}"
# ── Collect configuration ──────────────────────────────────────────────────
if [ "${TARGET:-baremetal}" = "cloud" ]; then
# Cloud: all values must be pre-baked — validate
[ -z "${ASSISTANT_NAME:-}" ] && log_msg "ERROR: ASSISTANT_NAME not baked" && exit 1
[ -z "${AGENT_DOMAIN:-}" ] && log_msg "ERROR: AGENT_DOMAIN not baked" && exit 1
[ -z "${TZ:-}" ] && log_msg "ERROR: TZ not baked" && exit 1
log_msg "[firstboot] Cloud — pre-baked config OK"
else
# Baremetal: wizard for simple inputs only
# API keys are NOT collected here — deferred to web UI on first desktop login
_dialog() { bsddialog --backtitle "Clawdie-AI Setup" "$@" 2>&1; }
ASSISTANT_NAME=$(_dialog --inputbox "Assistant name:" 8 50 "Clawdie")
AGENT_DOMAIN=$(_dialog --inputbox "Agent domain (e.g. clawdie.local):" 8 50 "clawdie.local")
TZ=$(_dialog --inputbox "Timezone (e.g. Europe/Ljubljana):" 8 50 "UTC")
fi
export ASSISTANT_NAME AGENT_DOMAIN TZ
# ── Run modules ────────────────────────────────────────────────────────────
log_msg "[firstboot] Running modules..."
clawdie_shell_gpu_detect # GPU driver → rc.conf kld_list (cloud: skips)
clawdie_shell_nvidia_detect # NVIDIA version selection (cloud + non-NVIDIA: skips)
clawdie_shell_pkg_setup # Configure pkg repos, seed offline cache
clawdie_shell_env_generate # Generate .env with secrets (API keys left blank)
clawdie_shell_system_config # hostname, rc.conf services, profile.d
clawdie_shell_deploy # Extract tarball, npm install, provision jails
log_msg "[firstboot] Complete."