Ship install/update scripts in the migrate image; no repo clone on hosts
release gate / check (push) Failing after 6m45s
release / smoke (push) Successful in 10m18s
release / publish (push) Failing after 9m55s

This commit is contained in:
2026-10-30 12:03:07 -06:00
parent fc9b6c2c42
commit 1dfd41986c
8 changed files with 101 additions and 81 deletions
+29 -32
View File
@@ -3,10 +3,10 @@
# Install Superbrain into a federated "core" suite host (REGISTRY mode).
#
# For operators running their own copy of the federated suite. On the
# CORE HOST, as root:
# CORE HOST, as root — no clone, no copying files around; this script and
# the deploy files ship inside the migrate image at /deploy:
#
# git clone <this-repo> /tmp/superbrain-repo
# sudo bash /tmp/superbrain-repo/deploy/federated/install.sh
# sudo bash -c "$(docker run --rm --pull always federatedcomputer/superbrain-migrate cat /deploy/install.sh)"
#
# No source is built or stored on the host: the three release images
# (federatedcomputer/superbrain-{app,web,migrate}, one shared version tag,
@@ -18,7 +18,7 @@
# 1. Preflights the suite (installapp, functions.sh, /etc/federated, the
# core docker network, Authelia — REQUIRED because the core tier is
# Authelia-only — and the fcore SMTP credential for notification mail).
# 2. Gets the deploy files from a repo clone (or $SUPERBRAIN_SRC).
# 2. Gets the deploy files from the migrate image (or $SUPERBRAIN_SRC).
# 3. Installs the suite integration: /federated/lib/superbrain.sh,
# /federated/services/superbrain/{service,upgrade/pre}, with fixed-IP
# collision checks and SUPERBRAIN_*_IP overrides.
@@ -29,21 +29,21 @@
# 5. Verifies and prints first-login steps.
#
# Environment overrides:
# SUPERBRAIN_REPO git URL to clone (default: this repo's origin)
# SUPERBRAIN_REF branch/tag to clone (default: main)
# SUPERBRAIN_VERSION release whose deploy files to use (default: latest;
# the service file inside it pins the image version)
# SUPERBRAIN_SRC local repo checkout to take the deploy files from
# instead of the image (development)
# SUPERBRAIN_WEB_IP / SUPERBRAIN_APP_IP / SUPERBRAIN_MIGRATE_IP
# fixed core-network IPs (default .93/.94/.95 — the
# installer refuses if they are already allocated)
# SKIP_VERIFY=1 skip the post-install HTTPS probe
#
# Updates after install: sudo bash <repo>/deploy/federated/update.sh
# (syncs the service file's VERSION, then runs the house upgrade flow).
# Updates after install: update.sh from the same image (syncs the service
# file's VERSION, then runs the house upgrade flow).
#
set -euo pipefail
REPO_DEFAULT="https://gitea.federated.computer/Federated_Computer/brain.git"
CLONE=/tmp/superbrain-install-src
IMAGE="federatedcomputer/superbrain-migrate:${SUPERBRAIN_VERSION:-latest}"
LIB_DST=/federated/lib/superbrain.sh
SVC_DST_DIR=/federated/services/superbrain
@@ -56,7 +56,7 @@ warn() { printf '\033[1;33mwarning:\033[0m %s\n' "$*" >&2; }
die() { printf '\033[1;31merror:\033[0m %s\n' "$*" >&2; exit 1; }
# --- 0. Preflights -----------------------------------------------------------
[ "$(id -u)" = 0 ] || die "run as root on the core host (sudo bash $0)"
[ "$(id -u)" = 0 ] || die "run as root on the core host"
[ -x /federated/bin/installapp ] || die "/federated/bin/installapp missing — this does not look like a federated suite host"
[ -f /federated/lib/functions.sh ] || die "/federated/lib/functions.sh missing"
[ -f /etc/federated ] || die "/etc/federated missing"
@@ -87,27 +87,25 @@ ip_taken() { # $1 = ip
}
for ip in "$WEB_IP" "$APP_IP" "$MIGRATE_IP"; do
if ip_taken "$ip"; then
die "IP $ip is already allocated on this host. Pick free addresses and re-run with e.g.:
sudo SUPERBRAIN_WEB_IP=192.168.0.193 SUPERBRAIN_APP_IP=192.168.0.194 SUPERBRAIN_MIGRATE_IP=192.168.0.195 bash $0"
die "IP $ip is already allocated on this host. Pick free addresses and re-run with them in the environment, e.g.:
sudo SUPERBRAIN_WEB_IP=192.168.0.193 SUPERBRAIN_APP_IP=192.168.0.194 SUPERBRAIN_MIGRATE_IP=192.168.0.195 bash -c \"\$(docker run --rm $IMAGE cat /deploy/install.sh)\""
fi
done
# --- 2. Get the deploy files ----------------------------------------------------
if [ -n "${SUPERBRAIN_SRC:-}" ]; then
SRC="$SUPERBRAIN_SRC"
[ -f "$SRC/deploy/federated/lib-superbrain.sh" ] || die "SUPERBRAIN_SRC=$SRC lacks deploy/federated files"
DEPLOY="$SUPERBRAIN_SRC/deploy/federated"
[ -f "$DEPLOY/lib-superbrain.sh" ] || die "SUPERBRAIN_SRC=$SUPERBRAIN_SRC lacks deploy/federated files"
else
command -v git >/dev/null || die "git not found (or set SUPERBRAIN_SRC=/path/to/repo)"
REPO="${SUPERBRAIN_REPO:-$REPO_DEFAULT}"
REF="${SUPERBRAIN_REF:-main}"
say "Cloning $REPO ($REF) for the deploy files"
rm -rf "$CLONE"
git clone --depth 1 --branch "$REF" "$REPO" "$CLONE" \
|| die "git clone failed — check repository access/credentials"
SRC="$CLONE"
say "Pulling $IMAGE for the deploy files"
docker pull -q "$IMAGE" >/dev/null || die "could not pull $IMAGE — does the release exist on Docker Hub?"
DEPLOY=$(mktemp -d)
trap 'rm -rf "$DEPLOY"' EXIT
docker run --rm "$IMAGE" tar -C /deploy -c . | tar -x -C "$DEPLOY" \
|| die "could not extract /deploy from $IMAGE"
fi
for f in deploy/federated/lib-superbrain.sh deploy/federated/service deploy/federated/upgrade-pre; do
[ -e "$SRC/$f" ] || die "source is missing $f — wrong repo/ref?"
for f in lib-superbrain.sh service upgrade-pre; do
[ -e "$DEPLOY/$f" ] || die "deploy files are missing $f — wrong image/version?"
done
# --- 3. Install the suite integration files --------------------------------------
@@ -116,11 +114,11 @@ if [ -f "$LIB_DST" ]; then
cp -a "$LIB_DST" "$LIB_DST.bak-$(date +%Y%m%d-%H%M%S)"
warn "backed up an existing $LIB_DST"
fi
cp "$SRC/deploy/federated/lib-superbrain.sh" "$LIB_DST"
cp "$DEPLOY/lib-superbrain.sh" "$LIB_DST"
mkdir -p "$SVC_DST_DIR/upgrade"
[ -f "$SVC_DST_DIR/service" ] && cp -a "$SVC_DST_DIR/service" "$SVC_DST_DIR/service.bak-$(date +%Y%m%d-%H%M%S)"
cp "$SRC/deploy/federated/service" "$SVC_DST_DIR/service"
cp "$SRC/deploy/federated/upgrade-pre" "$SVC_DST_DIR/upgrade/pre"
cp "$DEPLOY/service" "$SVC_DST_DIR/service"
cp "$DEPLOY/upgrade-pre" "$SVC_DST_DIR/upgrade/pre"
chmod 755 "$SVC_DST_DIR/upgrade/pre"
# Apply IP overrides (defaults match the shipped files, so this is a no-op
@@ -190,8 +188,7 @@ $(say "Superbrain installed (registry mode, version $WANT_VERSION)")
Other users are provisioned upstream (Superpanel -> LDAP -> Authelia) and
appear in Superbrain on their first SSO login.
Updates: bump VERSION in $SVC_DST_DIR/service (or sync it from a repo
clone) and run /federated/bin/upgrade superbrain — or one command:
git clone <repo> /tmp/superbrain-repo
sudo bash /tmp/superbrain-repo/deploy/federated/update.sh [git-ref]
Updates: bump VERSION in $SVC_DST_DIR/service and run
/federated/bin/upgrade superbrain — or one command (default: latest):
sudo bash -c "\\$(docker run --rm --pull always federatedcomputer/superbrain-migrate cat /deploy/update.sh)" update.sh [version]
EOF