Files
jcoffey-dev c9245077fa Phase 2: the console and the webmail on the host
--console host and --webmail host install them without containers, from
their releases' tarballs (inbuxa-admin #106, inbuxa-webmail #68), each
checked against a checksum pinned in internal/release.

- The console is files: unpacked into <dir>/console, root-owned and
  readable, and pointed at the server the way its image's entrypoint does
  (the api-base-url meta tag). The managed Caddy serves the directory,
  mounted read-only, or the operator's web server does from the
  configuration --proxy snippets writes; both with the image's rules (app
  routes fall back to index.html, hashed assets cached for good, index.html
  never). With --local or --proxy none nothing would serve it, and the
  plan says so.
- The webmail is the /app its image runs, in <dir>/webmail, owned by root,
  under inbuxa-webmail.service as its own user on the installer's own Node
  (now 26, as its image) in /opt/inbuxa/node, on 127.0.0.1:8080, with the
  container's environment in <dir>/webmail.env. It can't write its own
  files, which is what its IMMUTABLE setting checks. The unit is
  ProtectSystem=strict. A server in a container is reached at its loopback
  port and sees it at the project network's gateway, which is what gets
  exempted from the auto-ban.
- Both unpack beside the old copy and swap only when complete; a re-run
  skips an unchanged release and restarts the webmail only when what it
  reads at start changed. A webmail moved back into a container gives its
  port back first. status and export report them as host.

With all three on the host and --proxy snippets, no container runtime is
installed. The release pins are empty until those releases exist, and the
host shapes say so; INBUXA_CONSOLE_TARBALL and INBUXA_WEBMAIL_TARBALL (and
CONSOLE_TARBALL=, WEBMAIL_TARBALL= in e2e/vm/run.sh) install a local
tarball meanwhile.

Also: the "using docker" line no longer prints when nothing runs in a
container; Verify takes the plan's options and checks a host console by
its files.

Tests: plan (console host needs a web server; host front ends wait for
their releases; the webmail wants the installer's own Node), compose
(console files, the webmail unit, Caddy on the host's network, the
gateway exemption, nginx serving the directory), apply (api-base-url
replaced or inserted, the webmail's environment, unpack's swap and
marker). e2e: webmail-host.sh 18/18 (signing in included), all-host.sh
17/17 (no runtime, behind nginx), both with tarballs taken out of the
current images as the release jobs will; install-local, install-host,
install-public, proxy-snippets, interface, status-export and topology
pass unchanged.
2026-10-12 11:26:03 -07:00

59 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# SPDX-FileCopyrightText: 2026 Coffey Labs LLC
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# Build the installer, copy it into the lab machine, and run a case there.
#
# e2e/vm/run.sh e2e/cases/containers.sh rewind, then run that case
# KEEP=1 e2e/vm/run.sh e2e/cases/hosts.sh run it on the machine as it is
#
# The rewind is the point: every case starts on an identical machine, so a
# failure is the installer's and not the last run's leftovers.
set -euo pipefail
CASE="${1:?usage: run.sh e2e/cases/<case>.sh}"
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
. "$(dirname "$0")/lib.sh"
DISTRO="${DISTRO:-debian13}"
LAB="${LAB:-$HOME/.cache/inbuxa-lab/$DISTRO}"
MEM="${MEM:-4096}"; VCPUS="${VCPUS:-2}"; SSH_PORT="${SSH_PORT:-$(distro_port "$DISTRO")}"
DISK="$LAB/lab.qcow2"; CLEAN="$LAB/lab-clean.qcow2"; SEED="$LAB/seed.iso"
LOG="$LAB/console.log"; PIDFILE="$LAB/qemu.pid"
[ -f "$ROOT/$CASE" ] || { echo "no such case: $CASE" >&2; exit 1; }
[ "${KEEP:-}" = 1 ] || "$(dirname "$0")/reset.sh"
vm_running || { echo "the lab is not up -- run e2e/vm/up.sh" >&2; exit 1; }
echo "==> building the installer"
(cd "$ROOT" && GOOS=linux GOARCH=amd64 go build -o "$LAB/inbuxa" ./cmd/inbuxa)
# An upgrade case needs the installer as it was, too: OLD_REF builds that
# commit as /tmp/inbuxa-old.
if [ -n "${OLD_REF:-}" ]; then
echo "==> building the installer at $OLD_REF"
OLD_SRC="$(mktemp -d)"
(cd "$ROOT" && git archive "$OLD_REF" | tar -x -C "$OLD_SRC")
(cd "$OLD_SRC" && GOOS=linux GOARCH=amd64 go build -o "$LAB/inbuxa-old" ./cmd/inbuxa)
rm -rf "$OLD_SRC"
fi
echo "==> copying it in"
vm_scp "$LAB/inbuxa" [email protected]:/tmp/inbuxa >/dev/null
# A server build to install instead of the release (INBUXA_SERVER_BINARY in
# the case), for testing a server change before it is released.
if [ -n "${SERVER_BINARY:-}" ]; then
vm_scp "$SERVER_BINARY" [email protected]:/tmp/inbuxa-server-test >/dev/null
vm_ssh 'chmod +x /tmp/inbuxa-server-test'
fi
# The console's and the webmail's release tarballs, the same way, for host
# installs of them before a release carries them (INBUXA_CONSOLE_TARBALL and
# INBUXA_WEBMAIL_TARBALL in the case).
[ -z "${CONSOLE_TARBALL:-}" ] || vm_scp "$CONSOLE_TARBALL" [email protected]:/tmp/inbuxa-console-test.tar.gz >/dev/null
[ -z "${WEBMAIL_TARBALL:-}" ] || vm_scp "$WEBMAIL_TARBALL" [email protected]:/tmp/inbuxa-webmail-test.tar.gz >/dev/null
[ -z "${OLD_REF:-}" ] || vm_scp "$LAB/inbuxa-old" [email protected]:/tmp/inbuxa-old >/dev/null
vm_scp "$ROOT/$CASE" [email protected]:/tmp/case.sh >/dev/null
vm_ssh 'chmod +x /tmp/inbuxa /tmp/case.sh; [ ! -f /tmp/inbuxa-old ] || chmod +x /tmp/inbuxa-old'
echo "==> running $(basename "$CASE")"
vm_ssh 'sudo -E bash /tmp/case.sh'