Skip to content

refactor(installer): merge both init scripts into a single cloud-init bootstrap - #31

Merged
feryardiant merged 10 commits into
refine-installerfrom
unified-init
Oct 1, 2026
Merged

feryardiant merged 10 commits into
refine-installerfrom
unified-init

Conversation

@feryardiant

@feryardiant feryardiant commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Merges scripts/init.sh and scripts/init-lxc.sh into one self-contained
bootstrap script that runs either as cloud-init user-data on first boot or via
curl … | bash, replacing the divergent duplicate flows.

Goals

  • Single file, no repo checkout required; works as user-data and piped
  • Auto-detected (lxc/vps) profile with --profile/PROFILE override
  • One shared step flow; only package lists differ between profiles
  • Fail-fast visible errors, idempotent reruns, --dry-run, TTY-aware output

Constraints

  • Ubuntu/apt only; no server stack (nginx/php/db/node) — historical scripts stay retired
  • Enforced by a preflight requiring os-release ID=ubuntu: other distros
    fail fast with one clear line before the banner (dry-run previews anywhere)
  • Self-contained: no lib.sh, no clone step, bash 3.2-compatible constructs
  • Must never disable SSH password auth without installed authorized_keys (lockout guard)

Review focus

  • Privilege model: sudo -v once + quoted heredoc passed through bash -c "$FLOW" with explicit env values
  • adopt-or-create user logic, sudoers/authorized_keys handling, > truncation for rerun safety
  • Profile detection precedence (--profile > PROFILE > detect) and dry-run guarantees (never calls sudo)

Verification

  • Stubbed CI suite init_test.sh (50 assertions): CLI, profile precedence,
    dry-run sequence with a sudo tripwire, step-error and sudo-failure paths,
    protocol line atomicity under chatty commands (failing output is replayed
    below the status with the exact command and its call-site line), a bash 3.2
    parse gate, and the adoption self-copy guard; non-dry-run fixtures are
    skipped when the suite runs as root
  • Distro preflight verified on real hosts: Fedora 44 and Alpine 3.23
    reject with init.sh: requires Ubuntu (os-release ID=ubuntu) and rc=1
    before the banner (macOS too, where os-release is absent), while
    --dry-run previews fully on all of them; a fresh Ubuntu host passes
    silently, builds git 2.55.0 from the PPA, and reruns idempotently
  • Piped doors re-checked: usage() stays on the USAGE heredoc so
    cat init.sh | bash -s -- --help exits 0 and prints Usage:
  • Real execution in an OrbStack Ubuntu VM: full fresh-host run, idempotent
    rerun (sudoers/vimrc counts stable), all three doors (dry-run, root,
    non-root via sudo -v → sudo env), non-tty sudo -v failure loud with
    zero steps executed, sshd lockout guard (no keys → password auth kept,
    sshd -T passwordauthentication yes) and keys-installed hardening flip
    (passwordauthentication no), adoption of the existing uid-1000 user,
    container auto-detection (lxc), systemctl restart sshd unit alias

Related

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: eb6ad970-8a2c-4c33-8c46-f618f0a14b87

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@feryardiant feryardiant moved this to 🏗 In progress in Dev Configs Oct 1, 2026
@feryardiant feryardiant self-assigned this Oct 1, 2026
- replay failing command output under the step status with the exact
  command and its call-site line (no more `"$@" failed (line 10)`),
  keeping protocol lines atomic for plain run commands too
- parse under bash 3.2: a case inside the FLOW command substitution is
  a known 3.2 parser bug, so msg_end now uses if/else
- skip copying authorized_keys onto itself when the adopted user is
  the invoking sudo user (cp same-file exits 1)
- skip the suite's non-dry-run fixtures when running as root
- normalize one-line if/case/||-{} bodies to repo style
- print an indented hint when the suite skips its non-dry-run fixtures
  as root instead of silently running 18 fewer assertions
- one assignment per line for the FLOW color constants (repo style)
- preflight os-release ID=ubuntu before the banner so non-Ubuntu hosts
  get one clear line instead of a cryptic step-1 failure; skipped under
  dry-run (previews work anywhere); OS_RELEASE seam points the suite at
  fixture files
- add ppa:git-core/ppa behind software-properties-common with -y and an
  explicit apt refresh (lib.sh convention); ship openssh-server in both
  package sets so sshd hardening works on minimal images
- expand the default vimrc (completeopt, backspace, visual reindent,
  center-on-scroll/search, buffer tabs, ALT+J/K line moves) + typo fixes
- keep usage() on the USAGE heredoc: deriving it from the header broke
  the piped doors ($0 is bash there, so sed failed with rc=1)
- build FLOW with read -d '' instead of $(cat ...): bash 3.2 mis-lexes
  unbalanced quotes in command-substitution heredocs (the vimrc's
  ':m '>+1 marks made /bin/bash -n fail at EOF)
- reject empty --profile= and --profile "" like a bare --profile instead
  of silently auto-detecting
- tests: piped --help/unknown flag, empty profile values, guard reject
  and dry-run skip, add-apt-repository fixture stubs -- init suite 50,
  battery 182/182
@feryardiant
feryardiant marked this pull request as ready for review October 1, 2026 20:39
@feryardiant
feryardiant merged commit 8edaf84 into refine-installer Oct 1, 2026
2 checks passed
@feryardiant
feryardiant deleted the unified-init branch October 1, 2026 20:42
@feryardiant

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@feryardiant feryardiant linked an issue Oct 1, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

feat(installer): refine installer

1 participant