From a90594c8d9586fb25aee63ea0960131532a899db Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Sat, 24 Oct 2026 08:35:34 -0600 Subject: [PATCH] feat: add modular RPi4 host bootstrap --- cmd/jeannie-server/main.go | 2 +- jeannie | 6 ++++ lib/jeannie/commands.sh | 66 ++++++++++++++++++++++++++++++++++++++ lib/jeannie/pipeline.sh | 9 +++++- 4 files changed, 81 insertions(+), 2 deletions(-) diff --git a/cmd/jeannie-server/main.go b/cmd/jeannie-server/main.go index c4803a3..4ad1247 100644 --- a/cmd/jeannie-server/main.go +++ b/cmd/jeannie-server/main.go @@ -53,7 +53,7 @@ var allowedCommands = map[string]bool{ "deploy-dex": true, "deploy-matrix": true, "deploy-ai-stack": true, "deploy-office": true, "deploy-ai-tools": true, "deploy-omniroute": true, "deploy-hermes": true, - "rpi-services": true, "bootstrap-gitea-repo": true, "backup-gitea": true, + "rpi-services": true, "host-bootstrap": true, "bootstrap-gitea-repo": true, "backup-gitea": true, "backup": true, "drill-restore": true, "drill-gitea-restore": true, "drill-pihole-restore": true, "install-gitea-runner": true, "move-prometheus-stack-workers": true, "doctor-versions": true, diff --git a/jeannie b/jeannie index 5b4e9a3..4cc5809 100755 --- a/jeannie +++ b/jeannie @@ -64,6 +64,8 @@ Build And Bootstrap deploy-hermes Deploy the Hermes agent (git-install + venv + gateway service). bootstrap-gitea-repo Ensure the Gitea repo and SSH key wiring exist. rpi-services Deploy Pi-hole, Unbound, and Uptime Kuma on RPi4. + host-bootstrap rpi4 [status|plan|apply --yes] + Provision/check the physical RPi4, then bootstrap host services. ollama-setup Install/configure Ollama on the Debian host. artifact-cache {status|up|down|instructions} Manage optional Debian artifact caches. @@ -475,6 +477,10 @@ case "${1:-}" in record_change_journal "rpi-services" "$@" deploy_rpi_services ;; + host-bootstrap) + record_change_journal "host-bootstrap" "$@" + host_bootstrap_manage "${2:-}" "${3:-plan}" "${4:-}" + ;; bootstrap-gitea-repo) bootstrap_gitea_repo ;; diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index 31578af..80fee53 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -33,6 +33,72 @@ plan_homelab() { done } +host_bootstrap_manage() { + local host_target="${1:-}" + local action="${2:-plan}" + local rpi_host rpi_user rpi_key + + if [[ "${host_target}" != "rpi4" ]]; then + echo "Usage: ./jeannie host-bootstrap rpi4 [status|plan|apply --yes]" >&2 + return 2 + fi + if [[ "${action}" == "--help" || "${action}" == "help" ]]; then + echo "Usage: ./jeannie host-bootstrap rpi4 [status|plan|apply --yes]" + return 0 + fi + rpi_host="${LAB_RPI_HOST:-${LAB_RASPBERRY_HOST:-192.168.100.89}}" + rpi_user="${LAB_RPI_USER:-${LAB_RASPBERRY_USER:-jv}}" + rpi_key="${LAB_RPI_SSH_KEY_PATH:-${LAB_RASPBERRY_SSH_KEY_PATH:-${HOME}/.ssh/id_ed25519}}" + + case "${action}" in + status) + echo "== RPi4 host bootstrap status ==" + echo "target=${rpi_user}@${rpi_host} key=${rpi_key}" + if ssh -i "${rpi_key}" -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new \ + "${rpi_user}@${rpi_host}" 'set -eu; . /etc/os-release; printf "hostname=%s\\n" "$(hostname)"; printf "os=%s %s\\n" "${ID}" "${VERSION_ID}"; printf "arch=%s\\n" "$(uname -m)"; printf "kernel=%s\\n" "$(uname -r)"; command -v docker >/dev/null 2>&1 && echo docker=installed || echo docker=missing; test -d /boot && echo boot=present || echo boot=missing'; then + echo "SSH and host inspection succeeded." + else + echo "RPi4 is not reachable over SSH; OS installation cannot be completed by Jeannie yet." >&2 + return 1 + fi + ;; + plan) + cat <&2 + return 2 + fi + if [[ -z "${LAB_RPI4_OS_PROVISIONER_COMMAND:-}" ]]; then + echo "LAB_RPI4_OS_PROVISIONER_COMMAND is required for RPi4 OS installation; refusing to guess a disk or boot target." >&2 + return 2 + fi + echo "Running the configured RPi4 OS provisioner..." + bash -lc "${LAB_RPI4_OS_PROVISIONER_COMMAND}" + check_rpi_ssh + deploy_rpi_services + ;; + *) + echo "Usage: ./jeannie host-bootstrap rpi4 [status|plan|apply --yes]" >&2 + return 2 + ;; + esac +} + cluster_profile_report() { cat <