cleaner bootstrap #249
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_skills!249
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "docs/setup-bootstrap-adr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
scripts/bootstrap.sh (188 LOC) replaces ~1160 LOC of legacy bootstrap code. As UID 0: - check deps; resolve+validate FORGE_TOKEN (TTY prompt fallback) - create driver user with NOPASSWD sudo (idempotent) - seed /home/driver/hero/cfg/hero_cfg.toml (mode 600, driver-owned) - download lab-<os>-<arch> from forge latest release to /home/driver/hero/bin/lab (0755, driver-owned) - su - driver -c 'lab flow install --forgetoken ...' - verify clean: no /root/hero, no nu at root nutools/install_nu.sh and scripts/install.sh moved to _archive/ for one-release rollback. README + nutools/README updated to point at the new entry. skills/mod.rs + nutools/docs/server_setup.md install URLs updated to bootstrap.sh. Phase 3 of docs/plan/0001-unify-setup-bootstrap.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>- crate::user::cfg::generate_hero_nu writes a ~50-line overlay at <homedir>/nutools/shell/hero.nu: PATH prepend, ROOTDIR defaults, MYCELIUM_* from hero_cfg.toml, LIVEKIT_* from hero_livekit runtime.json. AUTO-GENERATED header; backs up hand-edited files to hero.nu.bak. - `lab user shell-init` now regenerates both init.sh (bash) and hero.nu (nu) in one pass. - nutools/modules/hero_loader.nu shrunk to a 3-line stub that sources the generated overlay. - nutools/modules/lib/{init.nu, nu.nu} archived — no longer needed by the loader. mod.nu re-export list pruned to match. Phase 6 of docs/plan/0001-unify-setup-bootstrap.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>10-phase plan to take an old VPS with legacy install_nu.sh / nu / flow state, nuke it to fresh-machine state, then exercise every P1-P8 deliverable from docs/plan/0001-unify-setup-bootstrap.md end-to-end: Phase 0: inventory baseline Phase 1: NUKE (stop procs, tear down accounts, wipe artefacts, strip shell rc, optional package removal, reboot) Phase 2: verify clean state Phase 3: bootstrap.sh fresh + idempotent + negative test Phase 4: lab flow install (host preflight, driver, template, common, doctor, status) Phase 5: user provisioning (create, login, delete) for two users Phase 6: cfg get/set + generated hero.nu overlay Phase 7: opt-in nu helpers + skill_audit relocation Phase 8: service lifecycle smoke Phase 9: lab flow uninstall (dry-run + real + re-bootstrap) Includes an acceptance matrix mapping each test back to its P1-P8 deliverable, plus recovery procedures for common mid-test failures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>- main.rs: UserCmd::Reset previously took a {name} field but user_reset() is a bulk teardown of every non-root hero user. The CLI silently ignored the supplied name. Drop the field so the surface matches the implementation; pass `lab user reset` with no arg now (anyone who passed a name gets a clap error instead of the wrong action). - user/lifecycle.rs: drop unused `user_list` import. - pod/pod_template.rs: drop unused `Context` import. - podmanager/mod.rs: remove unused `default_home` helper (and now-orphan PathBuf import). `cargo check -p lab` is clean (0 warnings, 0 errors).Three security/correctness fixes to scripts/bootstrap.sh: 1. Validate FORGE_TOKEN against /api/v1/user (always requires auth) instead of /api/v1/repos/<repo>, which silently returns HTTP 200 to anonymous requests when the repo is public — making the prior check accept any string as "valid". Plan 0002 §3.4 documented this as a known gap; closes it. 2. Stop passing FORGE_TOKEN on the command line to `lab flow install`. The previous form (`su -c "FORGE_TOKEN=… lab flow install --forgetoken \"$FORGE_TOKEN\""`) leaked the secret into both /proc/<pid>/cmdline and `ps -ef` for the duration of the run. Replaced with a driver-owned, mode-600 tmpfile that exports the env vars and execs lab; tmpfile is shredded by the EXIT trap. 3. Require `jq` in root_check_dependencies and drop the grep-based JSON parser. The fallback assumed Forgejo emits asset fields in `name` → `browser_download_url` order; the API guarantees no such order, so the parser could silently pick the wrong asset. Also drop dead `tr -d '[:space:]'` on `%{http_code}` (already digits) and merge the EXIT trap so both TMPDIR_LAB and the handoff tmpfile are cleaned on exit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>scripts/uninstall.sh — companion to scripts/bootstrap.sh. Distills the Phase 1 (NUKE) procedure from docs/plan/0002 into a runnable script so re-bootstrap doesn't require copy-pasting from a markdown doc. - Prefers `lab flow uninstall --purge-host` when lab is installed. - Falls back to manual teardown (sudoers, br-* bridges, btrfs subvolumes, /home/{driver,template,common}, provisioned hero users, /etc/hero, root shell-rc Hero block) when lab is missing or its uninstall fails. - --dry-run, --yes, --keep-host, --purge-host (default) flags. - Idempotent on every step. docs/hero_cfg_schema.md — add a "When each section is written" table making it clear that bootstrap.sh writes only [forge], and [mycelium] / [ssh] appear later via lab provisioning. Avoids confusion when a fresh driver home shows only [forge] before flow install runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>`curl | sh` installers (claude, uv, rustup) drop their binaries under ~/.local/bin or ~/.cargo/bin. lab inherits a non-login PATH via `su -c` during `flow install`, so neither directory is visible — `is_on_path` returns false and `run_cmd("uv"|"rustup", …)` fails with ENOENT. Two-part fix: - `installers/util.rs`: `is_on_path` falls back to `~/.local/bin/<bin>` so post-install verification doesn't false-negative. - `main.rs`: `augment_subprocess_path()` prepends `~/.local/bin`, `~/.cargo/bin`, and `~/hero/bin` to PATH once at startup so every `run_cmd(...)` lab spawns can exec these tools. Surfaced by ADR-0001 P3 bootstrap end-to-end test (docs/plan/0002). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>