#!/bin/sh # ============================================================================= # FermiHDI HD — fetch the installer and check this host # ============================================================================= # curl -fsSL https://downloads.fermihdi.io/install.sh | sh # # Downloads the installer archive, verifies it against its published SHA-256, # unpacks it into the current directory, and runs the read-only host inventory # so you can see what this machine can run before anything is decided. # # It changes nothing on the host, needs no root, and does not install packages. # The only step that changes a host is fermihdi-prepare --apply, which this # does not run and will not run for you. # ============================================================================= set -eu VERSION="${FERMIHDI_VERSION:-2.0.2}" BASE_URL="${FERMIHDI_BASE_URL:-https://downloads.fermihdi.io}" ARCHIVE="fermihdi-hd-install-${VERSION}.tar.gz" DEST="${FERMIHDI_DEST:-$(pwd)}" say() { printf '%s\n' "$*"; } warn() { printf ' ! %s\n' "$*" >&2; } die() { printf '\nerror: %s\n' "$*" >&2; exit 1; } # --- what this script itself needs ------------------------------------------- for tool in curl tar sha256sum; do command -v "$tool" >/dev/null 2>&1 || { [ "$tool" = sha256sum ] && command -v shasum >/dev/null 2>&1 && continue die "$tool is required and was not found." } done sha256() { command -v sha256sum >/dev/null 2>&1 && sha256sum "$1" | cut -d' ' -f1 || shasum -a 256 "$1" | cut -d' ' -f1; } say "" say "FermiHDI HD installer ${VERSION}" say "─────────────────────────────────────────────────────────────" # --- fetch -------------------------------------------------------------------- TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT INT TERM say " fetching ${ARCHIVE}" curl -fsSL "${BASE_URL}/${ARCHIVE}" -o "${TMP}/${ARCHIVE}" \ || die "could not download ${BASE_URL}/${ARCHIVE}" # The checksum is published beside the archive. A download that does not match # it is not unpacked: a truncated tarball that extracts far enough to look right # is worse than one that fails here. if curl -fsSL "${BASE_URL}/${ARCHIVE}.sha256" -o "${TMP}/sum" 2>/dev/null; then want="$(cut -d' ' -f1 < "${TMP}/sum")" got="$(sha256 "${TMP}/${ARCHIVE}")" [ "$want" = "$got" ] || die "checksum mismatch — expected ${want}, got ${got}" say " checksum ok" else warn "no published checksum found; continuing unverified" fi # --- unpack ------------------------------------------------------------------- DIR="${DEST}/fermihdi-hd-install-${VERSION}" [ -e "$DIR" ] && die "${DIR} already exists — move it aside or set FERMIHDI_DEST" tar xzf "${TMP}/${ARCHIVE}" -C "$DEST" say " unpacked into ${DIR}" # --- check this host ---------------------------------------------------------- say "" say "Checking this host" say "─────────────────────────────────────────────────────────────" missing="" for tool in python3 docker lsblk lscpu ip findmnt; do command -v "$tool" >/dev/null 2>&1 || missing="${missing} ${tool}" done python3 -c 'import yaml' >/dev/null 2>&1 || missing="${missing} python3-yaml" if [ -n "$missing" ]; then warn "not installed:${missing}" warn "python3 with PyYAML is needed by validate-cluster and fermihdi-prepare;" warn "docker by the deploy step. The inventory below runs without them." say "" fi if [ -x "${DIR}/fermihdi-discover" ]; then "${DIR}/fermihdi-discover" || warn "the inventory exited non-zero" else die "fermihdi-discover missing from the archive" fi # --- what to do with that ----------------------------------------------------- say "" say "Next" say "─────────────────────────────────────────────────────────────" say " cd ${DIR}" say "" say " ./fermihdi-configure decide what this host runs" say " ./validate-cluster cluster.yaml check that decision" say " sudo ./fermihdi-prepare cluster.yaml show what it would change" say " sudo ./fermihdi-prepare cluster.yaml --apply" say "" say " ADMIN_GUIDE.md explains all of it, including what the numbers above mean" say " for sizing. The full manual is published rather than packaged:" say " ${BASE_URL}/${VERSION}/web/ , or /pdf/ for one printable file." say ""