#!/usr/bin/env bash # The Moorhold installer (SHIP-79). Run as root on a fresh Ubuntu 24.04 or 26.04, or Debian 12, server, by # hand or from cloud-init (installer/cloud-init/). It: # 1. refuses an access key on the command line or in the environment (ADR-0025: a file or a prompt); # 2. installs what is missing from the distribution's own signed archive: Docker Engine and # Compose, minisign, curl, openssl, xz; # 3. downloads the release lock and checks its minisign signature against the public key below; # 4. downloads Node and the Moorhold bundle and checks each against the sha256 the lock pins; # 5. hands over to `moorhold install`, which generates every secret, pulls every image by digest # with the access key (sent on stdin), starts and applies the stack, and prints its URL and the # one-time setup code for /setup (on a terminal; from cloud-init, only where root can read it). # # install.sh --hostname [--profile full|core] [--access-key-file ] # [--acme production|staging] [--keep-access-key-file] [--no-sample-data] # install.sh --check --hostname [--profile full|core] # # Before it asks for the access key, and before any image is pulled, a fresh install runs the # installer's checks (ALLOT-1480, `moorhold check` from the verified bundle): the system, memory for # the profile, disk and unallocated LVM space, sleep on a desktop install, ports 80 and 443, DNS, # NAT loopback and carrier-grade NAT. A blocking finding stops it there. --check runs the same checks # and stops: it installs no Docker, writes nothing outside its temporary directory and asks for no # key (when curl, minisign or xz is missing it says so and stops with exit 3, because it installs # nothing and won't run what it can't verify). On a terminal, a fresh install asks for the profile and whether # to load the sample when the flags don't say. # # On a server that already runs another release of Moorhold, the installer upgrades it (ALLOT-1513): # --hostname may be left out (the installed Stack has it), the release is unpacked beside the running # one without switching /opt/moorhold/current, and the new release's `moorhold upgrade --staged` # does the rest, switching only once the new release is up. Every run keeps this installer's release # key in /etc/moorhold/release.pub, which `sudo moorhold upgrade ` checks later releases with. # # A fresh install loads the sample, "Moorhold sample: AI Release Radar" (ALLOT-1501); --no-sample-data # leaves it out. Installing again keeps what the server has. `moorhold sample-data add|remove` changes # it later. # # The access key comes from --access-key-file (a file of mode 0600, which is deleted once the images # are pulled, unless --keep-access-key-file) or, in a terminal, from a prompt that does not echo. # Once the registry accepts it, the server keeps its own copy, root only, in # /etc/moorhold/secrets/registry-access-key (ALLOT-1502). Running the installer again, with no key # file or with one an earlier run deleted, uses that copy. `moorhold access-key set|forget` change it. # Nothing it prints holds a secret. docs/decisions/0027-signed-installer.md has the design. set -euo pipefail umask 077 # Stamped by the release (scripts/release/release-files.mjs stamp); a development copy refuses to run. MOORHOLD_VERSION="2026.10.11" RELEASE_PUBKEY="RWScfyH28xJtf1DCwDTYUUS3wlSzmrKr2426mvg+EfqIV+mqziD5q5Si" BASE_URL="https://get.moorhold.dev" # Tests only (scripts/test/installer.test.mjs): a sandbox directory every absolute path is under. P=${MOORHOLD_INSTALL_PREFIX:-} say() { printf 'moorhold-install: %s\n' "$*"; } die() { printf 'moorhold-install: %s\n' "$1" >&2 exit "${2:-1}" } KEY_ON_ARGV='refusing an access key on the command line, where other users and logs can read it; put it in a file of mode 0600 and give --access-key-file ' USAGE='usage: install.sh --hostname [--profile full|core] [--access-key-file ] [--acme production|staging] [--keep-access-key-file] [--no-sample-data] [--change-hostname] [--check]' stage() { printf '== %s\n' "$*"; } # A terminal on stdin, where the installer may ask. Tests only: MOORHOLD_INSTALL_TERMINAL=1. on_terminal() { [ -t 0 ] || [ -n "${MOORHOLD_INSTALL_TERMINAL:-}" ]; } # ── 1. Inputs ───────────────────────────────────────────────────────────────────────────────── for a in "$@"; do case "$a" in --access-key | --access-key=*) die "$KEY_ON_ARGV" 2 ;; esac if printf '%s' "$a" | grep -Eq 'mh_[0-9a-z]{8,32}_[A-Za-z0-9_-]{20,}'; then die "$KEY_ON_ARGV" 2; fi done if [ -n "${MOORHOLD_ACCESS_KEY:-}" ]; then unset MOORHOLD_ACCESS_KEY die 'refusing MOORHOLD_ACCESS_KEY from the environment, which child processes and /proc can read; put the key in a file of mode 0600 and give --access-key-file ' 2 fi HOSTNAME_ARG='' PROFILE=full PROFILE_SET='' KEY_FILE='' ACME=production ACME_SET='' KEEP='' SAMPLE='' CHECK='' CHANGE_HOSTNAME='' while [ $# -gt 0 ]; do case "$1" in --hostname) HOSTNAME_ARG=${2:-}; shift 2 || die "$USAGE" 2 ;; --profile) PROFILE=${2:-}; PROFILE_SET=1; shift 2 || die "$USAGE" 2 ;; --access-key-file) KEY_FILE=${2:-}; shift 2 || die "$USAGE" 2 ;; --acme) ACME=${2:-}; ACME_SET=1; shift 2 || die "$USAGE" 2 ;; --keep-access-key-file) KEEP=1; shift ;; --sample-data) [ "$SAMPLE" != off ] || die "$USAGE" 2; SAMPLE=on; shift ;; --no-sample-data) [ "$SAMPLE" != on ] || die "$USAGE" 2; SAMPLE=off; shift ;; --check) CHECK=1; shift ;; --change-hostname) CHANGE_HOSTNAME=1; shift ;; -h | --help) printf '%s\n' "$USAGE"; exit 0 ;; *) die "$USAGE" 2 ;; esac done # The flags that ask an installed server for a change, as given on the command line (ALLOT-1692). ASKED_CHANGE="$ACME_SET$SAMPLE$CHANGE_HOSTNAME$PROFILE_SET" # A server that runs another release already is upgraded, not installed afresh (ALLOT-1513). UPGRADE_FROM='' RUNNING='' if [ -f "$P/opt/moorhold/stack/stack.yaml" ] && [ -L "$P/opt/moorhold/current" ]; then RUNNING=$(readlink "$P/opt/moorhold/current") RUNNING=${RUNNING%/} RUNNING=${RUNNING##*/} [ "$RUNNING" = "$MOORHOLD_VERSION" ] || UPGRADE_FROM=$RUNNING fi INSTALLED='' [ ! -f "$P/opt/moorhold/stack/stack.yaml" ] || INSTALLED=1 # A server Moorhold is installed on keeps its profile unless --profile says otherwise (ALLOT-1685): # moorhold.service starts it with that profile. Unread, it is asked for, or full, as on a fresh server. UNIT="$P/etc/systemd/system/moorhold.service" if [ -n "$INSTALLED" ] && [ -z "$PROFILE_SET" ] && [ -f "$UNIT" ]; then kept=$(awk '/^ExecStart/ { for (i = 1; i < NF; i++) if ($i == "--profile") print $(i + 1) }' "$UNIT") case "$kept" in full | core) PROFILE=$kept PROFILE_SET=1 ;; esac fi if [ -n "$CHECK" ]; then # The check reads an installed Stack's hostname itself. [ -n "$HOSTNAME_ARG$INSTALLED" ] || die "$USAGE" 2 elif [ -n "$UPGRADE_FROM" ]; then [ -z "$ACME_SET$SAMPLE" ] || die "this server runs Moorhold $UPGRADE_FROM, so the installer upgrades it and keeps its settings: leave out --acme, --sample-data and --no-sample-data (moorhold sample-data add|remove changes the sample)" 2 else # Run again without --hostname on a server already on this release, as the notes' update step # does on an updated server: there's nothing to update, so it says so and exits 0 (ALLOT-1692). # An install that didn't finish, or a flag that asks for a change, needs --hostname: exit 2. if [ -z "$HOSTNAME_ARG" ] && [ -n "$RUNNING" ] && [ "$RUNNING" = "$MOORHOLD_VERSION" ]; then [ ! -e "$P/opt/moorhold/.install-unfinished" ] || die "the last install of Moorhold $MOORHOLD_VERSION here didn't finish. Run the installer again with --hostname to finish it." 2 [ -z "$ASKED_CHANGE" ] || die "Moorhold $MOORHOLD_VERSION is already installed here, so there's nothing to update. To change its settings with --profile, --acme, --sample-data, --no-sample-data or --change-hostname, run the installer with --hostname as well." 2 say "Moorhold $MOORHOLD_VERSION is already installed here, so there's nothing to update. To repair or move it, run the installer with --hostname ." exit 0 fi [ -n "$HOSTNAME_ARG" ] || die "$USAGE" 2 fi [ -z "$HOSTNAME_ARG" ] || printf '%s' "$HOSTNAME_ARG" | grep -Eq '^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$' || die 'the hostname must be lowercase letters, digits, hyphens and dots, e.g. data.yourorg.example' 2 case "$PROFILE" in full | core) ;; *) die 'the profile must be full or core' 2 ;; esac case "$ACME" in production | staging) ;; *) die 'acme must be production or staging' 2 ;; esac case "$MOORHOLD_VERSION$RELEASE_PUBKEY" in *__MOORHOLD_*) die 'this is a development copy of the installer, with no release version or signing key; download a released installer from https://moorhold.dev' ;; esac printf '%s' "$RELEASE_PUBKEY" | grep -Eq '^RW[A-Za-z0-9+/]{54}$' || die 'the installer'"'"'s release key is malformed' # On a terminal, a fresh install asks what the flags don't say (task 6.1). An upgrade keeps the # server's profile and sample; --check uses the profile given (full by default) and asks nothing. if [ -z "$CHECK$UPGRADE_FROM" ] && on_terminal; then if [ -z "$PROFILE_SET" ]; then while :; do printf 'Core needs a 16 GB machine, full needs a 32 GB machine. Which do you want? [core/full] ' >&2 IFS= read -r answer || die 'the profile must be full or core' 2 case "$answer" in full | core) PROFILE=$answer PROFILE_SET=1; break ;; esac done fi if [ -z "$SAMPLE$INSTALLED" ]; then printf 'Load the sample data, Moorhold sample: AI Release Radar? You can remove it later. [Y/n] ' >&2 IFS= read -r answer || answer='' case "$answer" in n | N | no | No | NO) SAMPLE=off ;; *) SAMPLE=on ;; esac fi fi case "$PROFILE" in full) NEED_GIB=24 ;; core) NEED_GIB=12 ;; esac # ── 2. The server ───────────────────────────────────────────────────────────────────────────── [ "$(id -u)" = 0 ] || die 'run the installer as root (sudo)' case "$(uname -m)" in x86_64) ARCH=x86_64 ;; aarch64 | arm64) ARCH=aarch64 ;; *) die "unsupported processor: $(uname -m) (x86_64 and aarch64 are supported)" ;; esac OS_ID=$(. "$P/etc/os-release" && printf '%s %s' "$ID" "$VERSION_ID") case "$OS_ID" in # Every package below (docker.io, docker-compose-v2, minisign, curl, openssl, xz-utils) is in each # system's own archive: Ubuntu 26.04 (resolute) ships docker.io 29.1, Compose 2.40 and minisign 0.12. 'ubuntu 24.04' | 'ubuntu 26.04' | 'debian 12') ;; *) die "unsupported system: $OS_ID (the installer accepts Ubuntu 24.04, Ubuntu 26.04 or Debian 12)" ;; esac MEM_KB=$(awk '/^MemTotal:/ { print $2 }' "$P/proc/meminfo") # A 32 GB server reports about 31 GiB; the need is the components' limits plus room. A server being # upgraded runs its profile already, which the upgrade keeps. # --check reports the memory with the other checks instead. if [ -z "$UPGRADE_FROM$CHECK" ] && [ "$MEM_KB" -lt $((NEED_GIB * 1024 * 1024)) ]; then die "this server has $((MEM_KB / 1024 / 1024)) GiB of memory; the $PROFILE profile needs $NEED_GIB GiB (choose a 32 GB server, or --profile core on 16 GB)" fi WORK="$P/run/moorhold-install" mkdir -p "$WORK" chmod 0700 "$WORK" DL="$WORK/download" rm -rf "$DL" mkdir -m 0700 "$DL" PROMPTED='' CHECK_COPY='' cleanup() { rm -rf "$DL" if [ -n "$PROMPTED" ]; then rm -f "$PROMPTED"; fi if [ -n "$CHECK_COPY" ]; then rm -rf "$CHECK_COPY"; fi } trap cleanup EXIT KEPT="$P/etc/moorhold/secrets/registry-access-key" # Where the key comes from is settled here, before any download; the prompt itself waits until # the checks have passed (ALLOT-1480). ASK_KEY='' ask_for_key() { PROMPTED="$WORK/access-key" printf 'Moorhold access key (from account.moorhold.dev; not shown): ' >&2 IFS= read -rs key printf '\n' >&2 printf '%s\n' "$key" >"$PROMPTED" unset key KEY_FILE=$PROMPTED } if [ -n "$CHECK" ]; then : # The check asks for no key and reads none. elif [ -n "$KEY_FILE" ] && [ ! -e "$KEY_FILE" ] && [ ! -L "$KEY_FILE" ]; then # An earlier run deleted the file it was given. With a kept key, `moorhold install` says so and # uses it; otherwise a terminal is asked for the key, as a first install is. if [ ! -f "$KEPT" ]; then on_terminal || die "the access key file $KEY_FILE does not exist; save your key to it again, or run the installer in a terminal to be asked for it" 2 say "the access key file $KEY_FILE isn't there any more" ASK_KEY=1 fi elif [ -z "$KEY_FILE" ] && [ -f "$KEPT" ]; then say 'using the access key this server kept' elif [ -z "$KEY_FILE" ]; then on_terminal || die 'no access key: give --access-key-file (a file of mode 0600), or run the installer in a terminal to be asked for it' 2 ASK_KEY=1 fi if [ -z "$CHECK" ] && [ -n "$KEY_FILE" ] && { [ -e "$KEY_FILE" ] || [ -L "$KEY_FILE" ]; }; then [ ! -L "$KEY_FILE" ] || die "the access key file $KEY_FILE is a symbolic link; give the file itself" 2 [ -f "$KEY_FILE" ] || die "the access key file $KEY_FILE is not a regular file" 2 fi # The packages each tool comes in, from the system's own archive. missing_packages() { for tool in "$@"; do case "$tool" in docker) command -v docker >/dev/null 2>&1 || printf ' docker.io' ;; compose) docker compose version >/dev/null 2>&1 || printf ' docker-compose-v2' ;; xz) command -v xz >/dev/null 2>&1 || printf ' xz-utils' ;; curl) command -v curl >/dev/null 2>&1 || printf ' curl ca-certificates' ;; *) command -v "$tool" >/dev/null 2>&1 || printf ' %s' "$tool" ;; esac done } APT_UPDATED='' apt_install() { export DEBIAN_FRONTEND=noninteractive [ -n "$APT_UPDATED" ] || apt-get update -q APT_UPDATED=1 # shellcheck disable=SC2086 # one word per package apt-get install -y -q --no-install-recommends $1 } # ── 3. The signed release lock ──────────────────────────────────────────────────────────────── stage 'Checking the signed release' # What downloading and checking the signature needs; Docker waits until the checks have passed. # --check installs nothing, so it says what's missing and stops (exit 3). missing=$(missing_packages minisign curl xz) if [ -n "$missing" ] && [ -n "$CHECK" ]; then die "the check needs${missing} to download and verify the release, and this server doesn't have it. Install it with: sudo apt-get install${missing}, then run the check again" 3 elif [ -n "$missing" ]; then say "installing${missing} from the system's own archive, to check the signature of what it downloads" apt_install "$missing" fi fetch() { curl -fsSL --proto '=https' --tlsv1.2 --retry 3 -o "$2" "$1"; } say "checking the signature of Moorhold $MOORHOLD_VERSION" fetch "$BASE_URL/$MOORHOLD_VERSION/release.lock" "$DL/release.lock" fetch "$BASE_URL/$MOORHOLD_VERSION/release.lock.minisig" "$DL/release.lock.minisig" minisign -V -q -P "$RELEASE_PUBKEY" -m "$DL/release.lock" -x "$DL/release.lock.minisig" >/dev/null 2>&1 || die "the release lock's signature does not verify: stop, do not install, and tell hello@moorhold.dev" [ "$(head -n 1 "$DL/release.lock")" = 'moorhold-release 1' ] || die 'the release lock is not one this installer reads' [ "$(awk '$1 == "version" { print $2 }' "$DL/release.lock")" = "$MOORHOLD_VERSION" ] || die "the release lock is not for $MOORHOLD_VERSION" # The key `sudo moorhold upgrade` checks later releases against (ALLOT-1513): public, root's, 0644, # as a minisign public key file (`minisign -V -p`, ALLOT-1444's checks read it so). --check doesn't. if [ -z "$CHECK" ]; then mkdir -p "$P/etc/moorhold" printf 'untrusted comment: Moorhold release key, written by the installer for %s\n%s\n' \ "$MOORHOLD_VERSION" "$RELEASE_PUBKEY" >"$P/etc/moorhold/release.pub.new" chmod 0644 "$P/etc/moorhold/release.pub.new" mv "$P/etc/moorhold/release.pub.new" "$P/etc/moorhold/release.pub" fi NODE_URL=$(awk -v a="$ARCH" '$1 == "node" && $2 == a { print $3 }' "$DL/release.lock") NODE_SHA=$(awk -v a="$ARCH" '$1 == "node" && $2 == a { print $4 }' "$DL/release.lock") BUNDLE_URL=$(awk '$1 == "bundle" { print $2 }' "$DL/release.lock") BUNDLE_SHA=$(awk '$1 == "bundle" { print $3 }' "$DL/release.lock") [ -n "$NODE_URL" ] && [ -n "$BUNDLE_URL" ] || die "the release lock has no Node or bundle for $ARCH" # ── 4. Node and the bundle, pinned by sha256 ────────────────────────────────────────────────── pinned() { fetch "$1" "$DL/$3" printf '%s %s\n' "$2" "$DL/$3" | sha256sum -c --quiet - >/dev/null 2>&1 || die "$3 does not match the sha256 the signed lock pins: stop, do not install, and tell hello@moorhold.dev" } say 'downloading Node and Moorhold, checked against the signed lock' pinned "$NODE_URL" "$NODE_SHA" node.tar.xz pinned "$BUNDLE_URL" "$BUNDLE_SHA" moorhold.tar.gz # ── 4a. --check: the checks from the verified bundle, in the temporary directory, then stop ──── # Not under /run: Ubuntu mounts it noexec, so Node can't run from there (ALLOT-1684). Hardened # servers often make /tmp and /var/tmp noexec too, so the copy goes in /var/lib, and is removed on exit. if [ -n "$CHECK" ]; then C="$P/var/lib/moorhold-install-check" rm -rf "$C" mkdir -p "$P/var/lib" mkdir -m 0700 "$C" CHECK_COPY="$C" mkdir -p "$C/node" "$C/app" tar --no-same-owner -xJf "$DL/node.tar.xz" -C "$C/node" --strip-components=1 tar --no-same-owner -xzf "$DL/moorhold.tar.gz" -C "$C/app" set -- check --profile "$PROFILE" --home "$P/opt/moorhold" [ -z "$HOSTNAME_ARG" ] || set -- "$@" --hostname "$HOSTNAME_ARG" cd "$C/app" status=0 "$C/node/bin/node" apps/cli/src/main.ts "$@" || status=$? cd / exit "$status" fi REL="$P/opt/moorhold/releases/$MOORHOLD_VERSION" rm -rf "$REL.new" mkdir -p "$REL.new/node" "$REL.new/app" # --no-same-owner: the files belong to root (the installer), never to whichever uid built the archive, # so no later local account can rewrite code root runs. tar --no-same-owner -xJf "$DL/node.tar.xz" -C "$REL.new/node" --strip-components=1 tar --no-same-owner -xzf "$DL/moorhold.tar.gz" -C "$REL.new/app" cp "$DL/release.lock" "$DL/release.lock.minisig" "$REL.new/" # Readable by every uid, writable by root only: the installer's umask (077) would otherwise leave # the code unreadable to the non-root containers that mount it (the sample supplier is uid 1000). chmod -R u+rwX,go+rX,go-w "$REL.new" chmod 0755 "$REL.new" rm -rf "$REL" mv "$REL.new" "$REL" # ── 4b. The checks, before the key prompt and before anything is pulled (ALLOT-1480) ────────── # A fresh install only: an installed server runs Moorhold already (its front holds the ports), and an # upgrade has its own checks. A blocking finding stops the install here. PREFLIGHT='' if [ -z "$UPGRADE_FROM$INSTALLED" ]; then (cd "$REL/app" && "$REL/node/bin/node" apps/cli/src/main.ts check --before-key-prompt \ --hostname "$HOSTNAME_ARG" --profile "$PROFILE" --home "$P/opt/moorhold") || exit 1 PREFLIGHT=1 fi [ -z "$ASK_KEY" ] || ask_for_key stage 'Installing Docker and its tools' say "installing what is missing from the system's own archive" missing=$(missing_packages docker compose openssl) [ -z "$missing" ] || apt_install "$missing" if command -v systemctl >/dev/null 2>&1; then systemctl enable --now docker >/dev/null; fi # ── 5a. An upgrade: the new release's CLI takes over, and switches `current` once it is up ───── if [ -n "$UPGRADE_FROM" ]; then say "upgrading Moorhold $UPGRADE_FROM to $MOORHOLD_VERSION" set -- upgrade --staged "$P/opt/moorhold/releases/$MOORHOLD_VERSION" \ --home "$P/opt/moorhold" --secrets-dir "$P/etc/moorhold/secrets" --runtime-dir "$P/run/moorhold" [ -z "$HOSTNAME_ARG" ] || set -- "$@" --hostname "$HOSTNAME_ARG" [ -z "$PROFILE_SET" ] || set -- "$@" --profile "$PROFILE" # No key file: the upgrade uses the key this server kept (ALLOT-1502). [ -z "$KEY_FILE" ] || set -- "$@" --access-key-file "$KEY_FILE" [ -z "$KEEP" ] || set -- "$@" --keep-access-key-file cd "$REL/app" umask 022 "$REL/node/bin/node" apps/cli/src/main.ts "$@" exit $? fi ln -sfn "$REL" "$P/opt/moorhold/current" # `moorhold` on the PATH, for what an operator runs later (`moorhold relay ...`, ADR-0032; # `moorhold sample-data ...`): the current release's CLI with the release's own Node. mkdir -p "$P/usr/local/bin" # Without root, the release's Node can't be reached (the umask above leaves /opt/moorhold 0700): it # says to use sudo rather than leave the shell's "Permission denied" (ALLOT-1615). The same text # is WRAPPER in apps/cli/src/upgrade.ts, which an upgrade writes. cat >"$P/usr/local/bin/moorhold.new" <<'WRAPPER' #!/bin/sh # Written by the Moorhold installer: the current release's CLI. node=/opt/moorhold/current/node/bin/node if [ ! -x "$node" ] && [ "$(id -u)" -ne 0 ]; then printf 'Run it with sudo: sudo moorhold %s\n' "${*:-}" >&2 exit 1 fi exec "$node" /opt/moorhold/current/app/apps/cli/src/main.ts "$@" WRAPPER chmod 0755 "$P/usr/local/bin/moorhold.new" mv "$P/usr/local/bin/moorhold.new" "$P/usr/local/bin/moorhold" # ── 5. The install itself ───────────────────────────────────────────────────────────────────── say "starting moorhold install (profile $PROFILE)" set -- install --lock "$REL/release.lock" --hostname "$HOSTNAME_ARG" --profile "$PROFILE" # No key file: `moorhold install` uses the key this server kept (ALLOT-1502). [ -z "$KEY_FILE" ] || set -- "$@" --access-key-file "$KEY_FILE" set -- "$@" --acme "$ACME" \ --home "$P/opt/moorhold" --secrets-dir "$P/etc/moorhold/secrets" --runtime-dir "$P/run/moorhold" # The memory read above: the Stack records DataHub's and OpenSearch's limits sized for it, once # (ALLOT-1494); installing again keeps what the Stack has. set -- "$@" --host-memory-kib "$MEM_KB" # The network check ran with the others, before the key prompt. [ -z "$PREFLIGHT" ] || set -- "$@" --no-network-check [ -z "$KEEP" ] || set -- "$@" --keep-access-key-file # A new hostname for an installed Moorhold, agreed to without a terminal (ALLOT-1480). [ -z "$CHANGE_HOSTNAME" ] || set -- "$@" --change-hostname # A key the prompt wrote, rather than a file the operator gave. [ -z "$PROMPTED" ] || set -- "$@" --access-key-prompted # The sample: on for a fresh install, kept as it is on a reinstall, unless a flag says (ALLOT-1501). case "$SAMPLE" in on) set -- "$@" --sample-data ;; off) set -- "$@" --no-sample-data ;; esac cd "$REL/app" # `moorhold install` sets the mode of every secret it writes (0600 files, 0700 directories) itself; # what else it writes (the Stack, the project, the code) is read by non-root containers. umask 022 "$REL/node/bin/node" apps/cli/src/main.ts "$@" # ── 6. Start at boot (ALLOT-1556, ALLOT-1621) ───────────────────────────────────────────────── # The stack's boot secrets live on a tmpfs (/run/moorhold), so after a reboot nothing runs, the # backup schedule included, until `moorhold start` writes them again. moorhold.service runs it at # boot. The CLI writes and enables it (apps/cli/src/boot-unit.ts), as every upgrade does, so the # unit's text has one source. "$REL/node/bin/node" apps/cli/src/main.ts start-at-boot --profile "$PROFILE" --systemd-dir "$P/etc/systemd/system" # ── 7. The ending: where the setup code is, and where to use it (task 6.3) ───────────────────── printf 'To read your setup code: sudo cat /etc/moorhold/secrets/MOORHOLD_SETUP_CODE\n' printf 'Open https://%s/setup\n' "$HOSTNAME_ARG"