Skip to content

Latest commit

 

History

History
133 lines (103 loc) · 7.02 KB

install.md

File metadata and controls

133 lines (103 loc) · 7.02 KB

install.sh

Revision: 1 Last modified: 2026-12-04T17:48:16Z

Overview

A ~90-line forwarder, not an installer in its own right. It exists for one reason: many tools are installed with curl -fsSL .../install.sh | bash, and that convention must keep working while scripts/setup.sh stays the single implementation of the install (docs/guides/setup_script.md).

Run it when:

  • you want the one-line curl … | bash install, or
  • you already have a checkout and want to reach bootstrap mode by its published entry-point name.

Do not look for install logic here. Everything it does is locate setup.sh, then run that setup.sh with HELIX_SETUP_INTERNAL_MODE=bootstrap in its environment.

Prerequisites

  • bash (uses BASH_SOURCE, arrays, trap).
  • curl or wget — required only on the download path (no setup.sh beside the script). Neither present → exit 66.
  • git and whatever setup.sh itself needs; this script adds no requirements of its own.
  • Env vars (NAMES only):
    • HELIX_SETUP_BASE_URL — directory URL serving setup.sh. Default https://raw.githubusercontent.com/HelixDevelopment/HelixConstitution/main/scripts. file:// URLs work, which is how the tests and mirrors drive it.
    • HELIX_INSTALL_NO_RUN=1 — load the file (functions defined, traps set) and execute nothing. This is the test seam; it is checked at the last line, before the forwarder is called.
    • HELIX_SETUP_INTERNAL_MODE — set by this script to bootstrap, not by you.

Usage examples

# Conventional one-liner (downloads setup.sh from HELIX_SETUP_BASE_URL, then runs it)
curl -fsSL https://raw.githubusercontent.com/HelixDevelopment/HelixConstitution/main/scripts/install.sh | bash

# Same, forwarding flags to setup.sh
curl -fsSL https://raw.githubusercontent.com/HelixDevelopment/HelixConstitution/main/scripts/install.sh \
  | bash -s -- --dry-run

# From a checkout: uses the setup.sh sitting next to this file — no download at all
bash scripts/install.sh --dry-run

# Point at a mirror or a local directory instead of GitHub raw
HELIX_SETUP_BASE_URL=file:///srv/mirror/scripts bash scripts/install.sh --dry-run

What you should see: whatever setup.sh prints. This script adds no banner, no progress line and no summary. On the download path it prints nothing itself on success — the first output you see comes from setup.sh.

There is no --help: flags are passed through verbatim to setup.sh. bash scripts/setup.sh --help is the place to read them (docs/scripts/setup.md).

Exit codes

Pass-through plus its own three:

Code Meaning
0 setup.sh succeeded
1 setup.sh failed
2 setup.sh usage error
3 setup.sh blocked on a precondition
5 setup.sh verification failed (including a failing hook installer)
64 The entry sentinel is missing — a truncated download of install.sh itself. Nothing was run.
66 Neither curl nor wget is available, and no local setup.sh was found
67 The setup.sh download failed, is empty, is incomplete, or does not parse
130 / 143 INT / TERM reached this script and was forwarded to the child

The 0/1/2/3/5 rows are setup.sh's own contract (docs/scripts/setup.md); this script returns the child's status unmodified.

Edge cases

  • Truncated install.sh. Everything lives in functions and the last line calls the entry point with a sentinel argument (__HELIX_INSTALL_RUN__). A cut file either fails to parse or never reaches the call, so a partial download executes nothing and exits 64 if it does reach hi_forward_main without the sentinel.
  • No setup.sh beside the script. Falls to the download path. The download must satisfy three checks before anything runs: non-empty, last line literally # __HELIX_SETUP_SH_END__, and bash -n parses. Any failure → exit 67, temp directory removed.
  • $0 is a bare shell name. A stdin-fed shell may report bash, sh, dash, -bash or -sh. Those are blanked so a file literally named bash in the current directory is never mistaken for this script.
  • The private temp directory (${TMPDIR:-/tmp}/helix-setup.XXXXXX) is removed on every exit path including signals: the signal trap signals the child (only when it is a plain pid greater than 1), waits, cleans, then exits.
  • INT / TERM. Forwarded to the running setup.sh — the child is started in the background and waited so a signal can reach it. The signal handler disables further INT/TERM while it works.
  • Piped input left unread. When this script arrived on a pipe (not a terminal, not a file), the unread remainder of stdin is drained with a 2-second timeout so the writing curl is not left with a broken pipe.
  • timeout absent. The stdin drain is skipped; nothing else changes.

Internal behaviour

  1. If an argument list arrives without the sentinel __HELIX_INSTALL_RUN__, print a refusal and return 64.
  2. Install INT→130 and TERM→143 traps.
  3. Normalise $BASH_SOURCE: blank it when it looks like a bare shell name; otherwise resolve its directory.
  4. Local path — if <that dir>/setup.sh exists, run it as a waited-for child with HELIX_SETUP_INTERNAL_MODE=bootstrap, stdin from /dev/null, and return its status.
  5. Download path — resolve HELIX_SETUP_BASE_URL (trailing slash stripped), mktemp -d, then curl -fsSL --retry 2 --connect-timeout 15 or wget -q -O into <tmp>/setup.sh.
  6. Validate the download (non-empty, end marker, bash -n); on failure clean up and return 67.
  7. Run the downloaded script through the same child/wait path, clean up, return the child's status.
  8. Drain unread stdin when this script came in on a pipe and timeout exists; exit with the forwarded status.

Related scripts

  • scripts/setup.sh — the implementation. Two modes: hook mode (run inside an installed checkout) and bootstrap mode (this script always selects bootstrap).
  • scripts/update.sh — updates a constitution checkout and every submodule, rebase-based. Different job.
  • scripts/install_constitution.sh — the richer installer (upstream table, agent wiring, backups, --restore). If you want flags like --upstream, --agent, --dry-run with a printed plan, that is the script; install.sh only ever reaches setup.sh.
  • docs/scripts/setup.md, docs/scripts/install_constitution.md, docs/guides/setup_script.md.

Last verified

2026-12-04, in this checkout — script presence, parse cleanliness and the flag/exit-code contract read from source; the script was not executed (it runs an installer):

$ bash -n scripts/install.sh && echo PARSE-OK
PARSE-OK

$ grep -c 'HELIX_SETUP_INTERNAL_MODE=bootstrap' scripts/install.sh
1

A reader can reproduce the parse check with the bash -n line above. Reproducing a real run requires network access to HELIX_SETUP_BASE_URL (or a checkout containing setup.sh) and installs into a project — treat it as a mutating command and run it only where you intend to install.