Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix(install): close data-loss re-run + no-domain abort, harden pkg/venv/docker paths (I1-I10,I12,I20,I21)

Juan Denisf2e7715479f4
diff --git a/install.sh b/install.sh
index 9c34f36b..a4676c66 100644
--- a/install.sh
+++ b/install.sh
@@ -271,32 +271,68 @@ APT_EOF
}
refresh_pkg_index() {
+ # Best-effort by design (mirrors scripts/lib/pkg.sh pkg_refresh): a failed
+ # index refresh — flaky mirror, momentary lock — must never abort the
+ # install, so every arm is guarded and the function always returns 0.
+ # The --refresh flag is dnf-only; classic yum has no such flag, so its arm
+ # is a plain makecache (same as pkg.sh).
case "$PKG_MGR" in
- apt) apt-get update -y >/dev/null 2>&1 ;;
- dnf) dnf makecache --refresh >/dev/null 2>&1 ;;
- yum) yum makecache --refresh >/dev/null 2>&1 ;;
- zypper) zypper --non-interactive refresh >/dev/null 2>&1 ;;
- pacman) pacman -Sy --noconfirm >/dev/null 2>&1 ;;
- apk) apk update >/dev/null 2>&1 ;;
+ apt) apt-get update -y >/dev/null 2>&1 || true ;;
+ dnf) dnf makecache --refresh >/dev/null 2>&1 || true ;;
+ yum) yum makecache >/dev/null 2>&1 || true ;;
+ zypper) zypper --non-interactive refresh >/dev/null 2>&1 || true ;;
+ pacman) pacman -Sy --noconfirm >/dev/null 2>&1 || true ;;
+ apk) apk update >/dev/null 2>&1 || true ;;
esac
+ return 0
}
+# Warn-and-continue package install. Output is captured so a failure can be
+# reported with the manager's last lines — and that capture carries an
+# `|| rc=$?` guard because a bare `out=$(apt-get ...)` assignment is itself
+# an abort point under `set -e`: the old body died on the assignment, before
+# it could print anything at all. Always returns 0; callers that *require* a
+# package must probe the resulting state (command -v, locate_python, ...)
+# rather than this exit code.
pkg_add() {
- local out rc
+ local out="" rc=0
case "$PKG_MGR" in
- apt) out=$(apt-get install -y "$@" 2>&1) ;;
- dnf) out=$(dnf install -y "$@" 2>&1) ;;
- yum) out=$(yum install -y "$@" 2>&1) ;;
- zypper) out=$(zypper --non-interactive install "$@" 2>&1) ;;
- pacman) out=$(pacman -S --noconfirm "$@" 2>&1) ;;
- apk) out=$(apk add "$@" 2>&1) ;;
+ apt) out=$(apt-get install -y "$@" 2>&1) || rc=$? ;;
+ dnf) out=$(dnf install -y "$@" 2>&1) || rc=$? ;;
+ yum) out=$(yum install -y "$@" 2>&1) || rc=$? ;;
+ zypper) out=$(zypper --non-interactive install "$@" 2>&1) || rc=$? ;;
+ pacman) out=$(pacman -S --noconfirm "$@" 2>&1) || rc=$? ;;
+ apk) out=$(apk add "$@" 2>&1) || rc=$? ;;
+ *) warn "No supported package manager — cannot install: $*"; return 0 ;;
esac
- rc=$?
- if [ $rc -ne 0 ]; then
+ if [ "$rc" -ne 0 ]; then
warn "Could not install: $* (exit $rc)"
- printf '%s\n' "$out" | tail -5 >&2
- return $rc
+ printf '%s\n' "$out" | tail -5 >&2 || true
fi
+ return 0
+}
+
+# ---------------------------------------------------------------------------
+# RHEL-family (Rocky/Alma/RHEL/CentOS 9): upgrade openssh + openssl TOGETHER,
+# up front, before any other dnf transaction runs.
+#
+# Rocky 9 images ship openssh linked against openssl-libs 3.0.x while the
+# updates stream carries openssl-libs 3.5.x plus a matching openssh rebuild.
+# Any later `dnf install` that pulls dependencies can transitively upgrade
+# openssl-libs; if openssh is not upgraded in the SAME transaction, every new
+# sshd fork dies with "OpenSSL version mismatch" — remote installs over SSH
+# then cut themselves off mid-run. Upgrading both together lets openssh's
+# scriptlet restart sshd against the matched libssl (KillMode=process keeps
+# the live SSH session alive). Do NOT rewrite this with --exclude=openssl
+# shapes; they fail on python3-libs symbol requirements. Best-effort: a box
+# without the updates repo (or already current) is a clean no-op.
+# ---------------------------------------------------------------------------
+upgrade_rhel_crypto_stack() {
+ [ "$OS_FAMILY" = "rhel" ] || return 0
+ command -v dnf &>/dev/null || return 0
+ step "Upgrading openssh/openssl together (avoids sshd 'OpenSSL version mismatch')..."
+ dnf upgrade -y openssh openssh-server openssh-clients openssl openssl-libs openssl-devel 2>/dev/null || true
+ return 0
}
# ---------------------------------------------------------------------------
@@ -338,16 +374,36 @@ ver_in_range() {
printf '%s\n%s' "$1" "$PYTHON_MAX" | sort -C -V
}
+# True when <python> can actually create virtual environments. Debian/Ubuntu
+# minimal images split the venv module (ensurepip) into pythonX.Y-venv, so an
+# otherwise-valid interpreter still dies much later at `python -m venv` with
+# "ensurepip is not available" — probe up front instead. (I8)
+py_venv_ok() {
+ "$1" -m venv --help >/dev/null 2>&1
+}
+
locate_python() {
# Prefer an explicit minor version, newest first, then bare python3. This
# mirrors scripts/update.sh so a box that has python3.11 (Debian 12) but a
- # too-new/too-old default python3 is still recognized. Sets PYTHON_BIN and
- # returns 0 on success; returns 1 (without aborting) when nothing fits.
+ # too-new/too-old default python3 is still recognized. A candidate must
+ # also be venv-capable (py_venv_ok); on Debian-family boxes the missing
+ # pythonX.Y-venv package is installed on demand before the candidate is
+ # given up on. Sets PYTHON_BIN and returns 0 on success; returns 1
+ # (without aborting) when nothing fits.
local c v
for c in python3.12 python3.11 python3; do
if command -v "$c" &>/dev/null; then
v=$("$c" -c 'import sys;print(".".join(map(str,sys.version_info[:2])))' 2>/dev/null || true)
if [ -n "$v" ] && ver_in_range "$v"; then
+ if ! py_venv_ok "$c" && [ "$OS_FAMILY" = "debian" ]; then
+ step "Installing python${v}-venv (the venv module is missing)..."
+ pkg_add "python${v}-venv"
+ py_venv_ok "$c" || pkg_add python3-venv
+ fi
+ if ! py_venv_ok "$c"; then
+ warn "$c (Python $v) cannot create virtualenvs (no venv/ensurepip) — skipping it."
+ continue
+ fi
PYTHON_BIN="$c"
good "Using $c (Python $v)"
return 0
@@ -382,31 +438,37 @@ provision_python() {
# Prefer the distro's own package over a source compile. Debian 12 ships
# python3.11; Ubuntu 24.04 ships python3.12 (older Ubuntu falls back to the
# deadsnakes PPA); Fedora/RHEL provide 3.12 or 3.11 in their repos. A slow,
- # fragile source build is now strictly the last resort.
+ # fragile source build is now strictly the last resort. pkg_add is
+ # warn-and-continue (always returns 0), so each attempt is followed by a
+ # state probe (command -v) to decide whether the next fallback is needed.
if [ "$OS_FAMILY" = "debian" ]; then
if [ "${ID:-}" = "ubuntu" ]; then
- if ! pkg_add python3.12 python3.12-venv python3.12-dev; then
+ pkg_add python3.12 python3.12-venv python3.12-dev
+ if ! command -v python3.12 &>/dev/null; then
step "Adding deadsnakes PPA for Python 3.12..."
pkg_add software-properties-common
- add-apt-repository -y ppa:deadsnakes/ppa
+ add-apt-repository -y ppa:deadsnakes/ppa || true
refresh_pkg_index
pkg_add python3.12 python3.12-venv python3.12-dev
fi
else
# Debian (and Debian-like): python3.11 lives in the main repo.
refresh_pkg_index
- pkg_add python3.11 python3.11-venv python3.11-dev || \
- pkg_add python3.12 python3.12-venv python3.12-dev || true
+ pkg_add python3.11 python3.11-venv python3.11-dev
+ command -v python3.11 &>/dev/null || \
+ pkg_add python3.12 python3.12-venv python3.12-dev
fi
elif [ "$OS_FAMILY" = "fedora" ] || [ "$OS_FAMILY" = "rhel" ]; then
- pkg_add python3.12 python3.12-devel || pkg_add python3.11 python3.11-devel || true
+ pkg_add python3.12 python3.12-devel
+ command -v python3.12 &>/dev/null || pkg_add python3.11 python3.11-devel
elif [ "$OS_FAMILY" = "suse" ]; then
- pkg_add python311 python311-devel || pkg_add python312 python312-devel || true
+ pkg_add python311 python311-devel
+ command -v python3.11 &>/dev/null || pkg_add python312 python312-devel
elif [ "$OS_FAMILY" = "arch" ]; then
# Rolling release — `python` is already 3.11+.
- pkg_add python || true
+ pkg_add python
elif [ "$OS_FAMILY" = "alpine" ]; then
- pkg_add python3 python3-dev || true
+ pkg_add python3 python3-dev
fi
# Did a distro package give us something usable?
@@ -436,6 +498,22 @@ provision_python() {
# ---------------------------------------------------------------------------
# Docker engine + compose plugin
# ---------------------------------------------------------------------------
+# Add Docker's upstream .repo file, handling both config-manager generations:
+# classic dnf4 uses `--add-repo URL`, while dnf5 (Fedora 41+) removed that
+# flag in favour of `addrepo --from-repofile=URL`. Warn-and-continue: when
+# neither works the docker-ce install below fails too (also non-fatally). (I10)
+docker_repo_add() {
+ local url="$1"
+ if dnf config-manager --add-repo "$url" >/dev/null 2>&1; then
+ return 0
+ fi
+ if dnf config-manager addrepo --from-repofile="$url" >/dev/null 2>&1; then
+ return 0
+ fi
+ warn "Could not add the Docker repository ($url)."
+ return 0
+}
+
provision_docker() {
phase "Docker"
@@ -448,12 +526,12 @@ provision_docker() {
case "$OS_FAMILY" in
fedora)
pkg_add dnf-plugins-core
- dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
+ docker_repo_add https://download.docker.com/linux/fedora/docker-ce.repo
pkg_add docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-buildx-plugin
;;
rhel)
pkg_add dnf-plugins-core
- dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
+ docker_repo_add https://download.docker.com/linux/rhel/docker-ce.repo
pkg_add docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-buildx-plugin
;;
suse)
@@ -488,8 +566,21 @@ ensure_compose_plugin() {
return
fi
step "Installing Docker Compose plugin..."
+ # Fallback chain (I9): when Docker came from the distro repo (docker.io),
+ # Docker's own repo was never configured, so 'docker-compose-plugin' does
+ # not exist there — Ubuntu ships the same plugin as 'docker-compose-v2'.
+ # Probe after each attempt; if neither lands, warn and continue (the box
+ # may have compose v1, or the operator can add it later).
pkg_add docker-compose-plugin
- good "Docker Compose plugin installed."
+ if ! docker compose version &>/dev/null; then
+ pkg_add docker-compose-v2
+ fi
+ if docker compose version &>/dev/null; then
+ good "Docker Compose plugin installed."
+ else
+ warn "Could not install the Docker Compose plugin — 'docker compose' is unavailable."
+ warn "Managed app deployments need it; install docker-compose-plugin or docker-compose-v2 manually."
+ fi
}
# ---------------------------------------------------------------------------
@@ -539,6 +630,47 @@ provision_node() {
good "Node.js $(node --version) installed."
}
+# ---------------------------------------------------------------------------
+# Live-state carry: keep .env + backend/instance/ across a slot rewrite
+# ---------------------------------------------------------------------------
+# fetch_release and sync_source both rebuild $FIRST_SLOT with an rm -rf. On a
+# re-run over an existing install that tree holds irreplaceable state: the
+# generated .env (SECRET_KEY / JWT_SECRET_KEY / SERVERKIT_ENCRYPTION_KEY —
+# losing that key orphans every encrypted secret) and backend/instance/ (the
+# SQLite database). Copy them aside before the rewrite and restore them after,
+# mirroring scripts/update.sh's deploy_source carry-forward. Both helpers are
+# best-effort and always return 0 — preservation must never abort an install.
+stash_live_state() {
+ # Echoes a stash directory holding the live state, or nothing when there
+ # is nothing to preserve (fresh install) or no stash could be created.
+ local src="$1" stash
+ if [ ! -f "$src/.env" ] && [ ! -d "$src/backend/instance" ]; then
+ return 0
+ fi
+ stash="$(mktemp -d 2>/dev/null || true)"
+ [ -n "$stash" ] || return 0
+ cp -a "$src/.env" "$stash/.env" 2>/dev/null || true
+ cp -a "$src/backend/instance" "$stash/instance" 2>/dev/null || true
+ printf '%s' "$stash"
+ return 0
+}
+
+restore_live_state() {
+ local stash="$1" dest="$2"
+ [ -n "$stash" ] || return 0
+ if [ -f "$stash/.env" ]; then
+ cp -a "$stash/.env" "$dest/.env" 2>/dev/null || true
+ fi
+ if [ -d "$stash/instance" ]; then
+ mkdir -p "$dest/backend" 2>/dev/null || true
+ rm -rf "$dest/backend/instance" 2>/dev/null || true
+ cp -a "$stash/instance" "$dest/backend/instance" 2>/dev/null || true
+ fi
+ rm -rf "$stash" 2>/dev/null || true
+ good "Preserved the existing .env and database across the rewrite."
+ return 0
+}
+
# ---------------------------------------------------------------------------
# Release tarball path
# ---------------------------------------------------------------------------
@@ -608,9 +740,19 @@ fetch_release() {
[ -d "$unpacked" ] || halt "Release tarball layout is unrecognized (expected serverkit/ or opt/serverkit/)."
ensure_install_layout
+
+ # A re-run over a live install must never destroy its secrets or database
+ # (the old bare rm -rf below did exactly that). Stash them, rewrite,
+ # restore. (I4)
+ local live_dir stash
+ live_dir="$(readlink -f "$INSTALL_DIR" 2>/dev/null || echo "$FIRST_SLOT")"
+ [ -d "$live_dir" ] || live_dir="$FIRST_SLOT"
+ stash="$(stash_live_state "$live_dir")"
+
rm -rf "$FIRST_SLOT"
cp -a "$unpacked" "$FIRST_SLOT"
rm -rf "$tmp_dir"
+ restore_live_state "$stash" "$FIRST_SLOT"
[ -L "$INSTALL_DIR" ] || ln -s "$FIRST_SLOT" "$INSTALL_DIR"
@@ -625,6 +767,16 @@ fetch_release() {
sync_source() {
phase "Source Code"
+ # Source installs clone with git, but minimal images don't guarantee it
+ # and the preflight never checked — install it on demand, and halt only
+ # if that fails too (a source install cannot proceed without git). (I7)
+ if ! command -v git &>/dev/null; then
+ step "Installing git..."
+ pkg_add git
+ command -v git &>/dev/null || \
+ halt "git is required for a source install but could not be installed."
+ fi
+
ensure_install_layout
if [ -d "$FIRST_SLOT/.git" ]; then
@@ -637,8 +789,14 @@ sync_source() {
fi
else
step "Cloning ServerKit..."
+ # Same live-state carry as fetch_release: the non-git tree replaced
+ # here may still be a live install (e.g. one installed from a release
+ # tarball) holding the generated .env and the database. (I4)
+ local stash
+ stash="$(stash_live_state "$FIRST_SLOT")"
rm -rf "$FIRST_SLOT"
git clone --depth 1 "https://github.com/${GITHUB_REPO}.git" "$FIRST_SLOT"
+ restore_live_state "$stash" "$FIRST_SLOT"
cd "$FIRST_SLOT"
fi
[ -L "$INSTALL_DIR" ] || ln -sfn "$FIRST_SLOT" "$INSTALL_DIR"
@@ -687,6 +845,18 @@ build_virtualenv() {
# If the release shipped a pre-built venv at the expected path, use it.
if [ "$INSTALL_FROM_RELEASE" = "1" ] && [ -f "$FIRST_SLOT/venv/bin/activate" ] && [ -x "$FIRST_SLOT/venv/bin/python" ]; then
step "Using pre-built virtual environment from release..."
+ # In the default layout $INSTALL_DIR is a symlink to $FIRST_SLOT, so
+ # $VENV_DIR *is* $FIRST_SLOT/venv — the rm -rf below would delete the
+ # very venv it is about to "copy", and the cp would then fail. When
+ # source and destination resolve to the same directory the venv is
+ # already in place; verify and keep it. (I3)
+ local src_venv dst_venv
+ src_venv="$(readlink -f "$FIRST_SLOT/venv" 2>/dev/null || echo "$FIRST_SLOT/venv")"
+ dst_venv="$(readlink -f "$VENV_DIR" 2>/dev/null || echo "$VENV_DIR")"
+ if [ "$src_venv" = "$dst_venv" ]; then
+ good "Virtual environment already in place from the release."
+ return
+ fi
rm -rf "$VENV_DIR"
cp -a "$FIRST_SLOT/venv" "$VENV_DIR"
good "Virtual environment installed from release."
@@ -839,9 +1009,12 @@ configure_firewall() {
step "Opening HTTP/HTTPS (80, 443) via $backend..."
firewall_open "$backend" 80/tcp 443/tcp
if [ "${FW_DRY_RUN:-0}" != "1" ] && command -v state_set >/dev/null 2>&1; then
- state_set firewall_backend "$backend"
- state_append firewall_ports 80/tcp
- state_append firewall_ports 443/tcp
+ # Best-effort, exactly like update.sh's ensure_firewall: failing to
+ # RECORD the opened ports must not abort an install whose firewall
+ # work already succeeded. (I21)
+ state_set firewall_backend "$backend" || true
+ state_append firewall_ports 80/tcp || true
+ state_append firewall_ports 443/tcp || true
fi
good "Firewall configured ($backend): 80/tcp and 443/tcp open."
}
@@ -960,18 +1133,28 @@ choose_ssl_mode() {
# Install the nginx config matching the chosen SSL mode.
# ---------------------------------------------------------------------------
install_nginx_config_for_mode() {
+ # Dirs are overridable so the unit tests can exercise this against
+ # fixtures (same pattern as harden_global_tls / update.sh's NGINX_DIR).
+ local nginx_dir="${SERVERKIT_NGINX_DIR:-/etc/nginx}"
+ local config_dir="${SERVERKIT_CONFIG_DIR:-/etc/serverkit}"
if [ "$SSL_MODE" = "secure" ]; then
sed -i "s|/etc/letsencrypt/live/YOUR_DOMAIN/|/etc/letsencrypt/live/$PANEL_DOMAIN/|g" \
- /etc/nginx/sites-available/serverkit.conf
- ln -sf /etc/nginx/sites-available/serverkit.conf /etc/nginx/sites-enabled/serverkit.conf
+ "$nginx_dir/sites-available/serverkit.conf"
+ ln -sf "$nginx_dir/sites-available/serverkit.conf" "$nginx_dir/sites-enabled/serverkit.conf"
else
- ln -sf /etc/nginx/sites-available/serverkit-insecure.conf /etc/nginx/sites-enabled/serverkit.conf
+ ln -sf "$nginx_dir/sites-available/serverkit-insecure.conf" "$nginx_dir/sites-enabled/serverkit.conf"
fi
- mkdir -p /etc/serverkit
- printf '%s\n' "$SSL_MODE" > /etc/serverkit/ssl-mode
+ mkdir -p "$config_dir"
+ printf '%s\n' "$SSL_MODE" > "$config_dir/ssl-mode"
# Persist the domain so update.sh can re-apply the cert path on upgrades
- # without depending on the (commented-out) .env public URL.
- [ -n "$PANEL_DOMAIN" ] && printf '%s\n' "$PANEL_DOMAIN" > /etc/serverkit/panel-domain
+ # without depending on the (commented-out) .env public URL. An empty
+ # domain (the default no-domain install) is simply not persisted — and as
+ # the LAST statement of the function this must be an `if`, not a
+ # `[ -n ] && ...` list: the list form returned 1 on an empty domain and
+ # set -e killed every no-domain install right here. (I1)
+ if [ -n "$PANEL_DOMAIN" ]; then
+ printf '%s\n' "$PANEL_DOMAIN" > "$config_dir/panel-domain"
+ fi
}
# Point the static-frontend `root` at the real install dir. The shipped nginx
@@ -1184,10 +1367,26 @@ await_health() {
snapshot_existing() {
local active
active="$(readlink -f "$INSTALL_DIR" 2>/dev/null || echo "$INSTALL_DIR")"
- if [ -d "$active" ] && [ ! -d "$active.backup" ]; then
+ [ -d "$active" ] || return 0
+ if [ ! -d "$active.backup" ]; then
step "Backing up the existing installation..."
cp -a "$active" "$active.backup"
good "Backup saved to $active.backup"
+ return 0
+ fi
+ # A .backup left by an earlier run is what revert_install restores — a
+ # stale one would silently roll the box back to a months-old tree.
+ # Refresh it: build the new copy first and swap only on success, so a
+ # failed copy never costs us the backup we already have. (I20)
+ step "Refreshing the existing installation backup..."
+ rm -rf "$active.backup.new" 2>/dev/null || true
+ if cp -a "$active" "$active.backup.new" 2>/dev/null; then
+ rm -rf "$active.backup"
+ mv "$active.backup.new" "$active.backup"
+ good "Backup refreshed at $active.backup"
+ else
+ rm -rf "$active.backup.new" 2>/dev/null || true
+ warn "Could not refresh $active.backup — keeping the previous backup."
fi
}
@@ -1250,28 +1449,54 @@ ping_telemetry() {
# Ask for a panel domain when running interactively
# ---------------------------------------------------------------------------
prompt_for_domain() {
- [ -z "$PANEL_DOMAIN" ] && [ -t 0 ] || return 0
+ # Nothing to ask when a domain is already set, or when there is no
+ # interactive stdin to ask on (curl | bash). SERVERKIT_FORCE_PROMPT=1
+ # lets the unit tests drive the prompt from a pipe.
+ [ -z "$PANEL_DOMAIN" ] || return 0
+ if [ ! -t 0 ] && [ "${SERVERKIT_FORCE_PROMPT:-0}" != "1" ]; then
+ return 0
+ fi
printf '\n'
printf '%sEnter your panel domain (e.g. panel.example.com)%s\n' "$BLD" "$RST"
printf 'Leave blank to access via IP (no SSL attempt)\n'
printf '%sTip:%s set PANEL_DOMAIN=... in the environment to skip this prompt\n' "$BLD" "$RST"
printf ' set SERVERKIT_SKIP_SSL=1 to disable HTTPS entirely\n'
printf '> '
- read -r PANEL_DOMAIN
+ read -r PANEL_DOMAIN || true
PANEL_DOMAIN=$(printf '%s' "$PANEL_DOMAIN" | tr -d ' ')
- [ -n "$PANEL_DOMAIN" ] && PANEL_PORT="80"
+ # A blank answer (plain Enter) is the documented default — and as the
+ # LAST statement of the function this must be an `if`, not a
+ # `[ -n ] && ...` list: the list form returned 1 on a blank answer and
+ # set -e killed every interactive no-domain install right here. (I2)
+ if [ -n "$PANEL_DOMAIN" ]; then
+ PANEL_PORT="80"
+ fi
}
# ---------------------------------------------------------------------------
# Orchestration
# ---------------------------------------------------------------------------
+# Decide whether a fresh install should default to a release tarball. An
+# EXISTING install must never flip to release mode by default: fetch_release
+# rewrites the whole slot. The old check tested $INSTALL_DIR/backend/src — a
+# path that never existed (the tree is backend/app) — so every re-run over a
+# live install picked release mode and rm -rf'd it, .env and database
+# included. Probe the real tree and the generated .env instead. (I4)
+should_default_to_release() {
+ [ "$BUILD_FROM_SOURCE" != "1" ] || return 1
+ [ -z "${SERVERKIT_VERSION:-}" ] || return 1
+ [ ! -d "$INSTALL_DIR/backend/app" ] || return 1
+ [ ! -f "$INSTALL_DIR/.env" ] || return 1
+ return 0
+}
+
main() {
STARTED_AT=$(date +%s)
masthead
- # Default to a release install unless a source tree is already present or
+ # Default to a release install unless an install is already present or
# the caller forced a source build / pinned a version.
- if [ "$BUILD_FROM_SOURCE" != "1" ] && [ ! -d "$INSTALL_DIR/backend/src" ] && [ -z "${SERVERKIT_VERSION:-}" ]; then
+ if should_default_to_release; then
INSTALL_FROM_RELEASE=1
fi
@@ -1283,6 +1508,10 @@ main() {
prompt_for_domain
snapshot_existing
+ # RHEL 9 family: keep sshd alive across the dnf work below (see the
+ # function's comment for the full openssl/openssh mismatch story).
+ upgrade_rhel_crypto_stack
+
provision_docker
ensure_compose_plugin
provision_node
diff --git a/scripts/test/test_install.sh b/scripts/test/test_install.sh
index a6c4a419..e0129d84 100644
--- a/scripts/test/test_install.sh
+++ b/scripts/test/test_install.sh
@@ -309,6 +309,407 @@ else
ok "docker-compose.yml is frontend-only and routes /api to the host backend (backend:host-gateway)"
fi
+# --------------------------------------------------------------------------
+# T13 — I1: the default no-domain install must survive install_nginx_config_
+# for_mode. `[ -n "$PANEL_DOMAIN" ] && printf ...` as the function's LAST
+# statement returned 1 on an empty domain and set -e killed every curl-pipe
+# install at the nginx phase (shipped broken since v1.6.25).
+# --------------------------------------------------------------------------
+t="$WORK/t13"; mkdir -p "$t/nginx/sites-available" "$t/nginx/sites-enabled" "$t/cfg"
+printf 'server { listen 80; }\n' > "$t/nginx/sites-available/serverkit-insecure.conf"
+printf 'ssl_certificate /etc/letsencrypt/live/YOUR_DOMAIN/fullchain.pem;\n' \
+ > "$t/nginx/sites-available/serverkit.conf"
+if ( set -Eeuo pipefail
+ SERVERKIT_NGINX_DIR="$t/nginx" SERVERKIT_CONFIG_DIR="$t/cfg" \
+ PANEL_DOMAIN="" SSL_MODE=insecure install_nginx_config_for_mode ) >/dev/null 2>&1; then
+ if [ "$(cat "$t/cfg/ssl-mode")" = "insecure" ] && [ ! -f "$t/cfg/panel-domain" ]; then
+ ok "install_nginx_config_for_mode survives an empty PANEL_DOMAIN (the v1.6.25 no-domain abort)"
+ else
+ bad "install_nginx_config_for_mode wrote the wrong mode/domain state for a no-domain install"
+ fi
+else
+ bad "install_nginx_config_for_mode DIED with an empty PANEL_DOMAIN under set -e (I1 regression)"
+fi
+if ( set -Eeuo pipefail
+ SERVERKIT_NGINX_DIR="$t/nginx" SERVERKIT_CONFIG_DIR="$t/cfg" \
+ PANEL_DOMAIN="panel.example.com" SSL_MODE=secure install_nginx_config_for_mode ) >/dev/null 2>&1 \
+ && grep -q 'live/panel.example.com/' "$t/nginx/sites-available/serverkit.conf" \
+ && [ "$(cat "$t/cfg/panel-domain")" = "panel.example.com" ]; then
+ ok "install_nginx_config_for_mode (secure) applies the cert path and persists the domain"
+else
+ bad "install_nginx_config_for_mode (secure) did not apply the cert path / persist the domain"
+fi
+
+# --------------------------------------------------------------------------
+# T14 — I2: plain Enter at the interactive domain prompt must not abort.
+# Same end-of-function `[ -n ] && ...` shape as I1. SERVERKIT_FORCE_PROMPT=1
+# lets the test drive the prompt from a pipe instead of a tty.
+# --------------------------------------------------------------------------
+if printf '\n' | ( set -Eeuo pipefail
+ PANEL_DOMAIN="" SERVERKIT_FORCE_PROMPT=1 prompt_for_domain ) >/dev/null 2>&1; then
+ ok "prompt_for_domain survives a blank answer (plain Enter, the no-domain default)"
+else
+ bad "prompt_for_domain DIED on a blank answer under set -e (I2 regression)"
+fi
+res="$(printf 'panel.example.com\n' | (
+ set -Eeuo pipefail
+ PANEL_DOMAIN=""; PANEL_PORT=""; SERVERKIT_FORCE_PROMPT=1
+ prompt_for_domain >/dev/null 2>&1
+ printf '%s|%s' "$PANEL_DOMAIN" "$PANEL_PORT"
+))"
+if [ "$res" = "panel.example.com|80" ]; then
+ ok "prompt_for_domain accepts a typed domain and sets the port"
+else
+ bad "prompt_for_domain returned [$res], expected panel.example.com|80"
+fi
+
+# --------------------------------------------------------------------------
+# T15 — I4 (detection half): should_default_to_release must see an EXISTING
+# install. The old check probed backend/src (never exists — the tree is
+# backend/app), so every re-run picked release mode and fetch_release
+# rm -rf'd the live install, .env + SQLite DB included.
+# --------------------------------------------------------------------------
+t="$WORK/t15"
+mkdir -p "$t/fresh" "$t/existing/backend/app" "$t/envonly"
+printf 'SECRET_KEY=x\n' > "$t/envonly/.env"
+det_ok=1
+( set -Eeuo pipefail; INSTALL_DIR="$t/fresh"; BUILD_FROM_SOURCE=0; SERVERKIT_VERSION=""
+ should_default_to_release ) || { bad "fresh box should default to a release install"; det_ok=0; }
+( set -Eeuo pipefail; INSTALL_DIR="$t/existing"; BUILD_FROM_SOURCE=0; SERVERKIT_VERSION=""
+ should_default_to_release ) && { bad "existing backend/app tree must NOT default to release (data loss)"; det_ok=0; }
+( set -Eeuo pipefail; INSTALL_DIR="$t/envonly"; BUILD_FROM_SOURCE=0; SERVERKIT_VERSION=""
+ should_default_to_release ) && { bad "existing .env must NOT default to release (data loss)"; det_ok=0; }
+( set -Eeuo pipefail; INSTALL_DIR="$t/fresh"; BUILD_FROM_SOURCE=1; SERVERKIT_VERSION=""
+ should_default_to_release ) && { bad "BUILD_FROM_SOURCE=1 must force the source path"; det_ok=0; }
+[ "$det_ok" = "1" ] && ok "should_default_to_release detects an existing install (backend/app or .env)"
+
+# --------------------------------------------------------------------------
+# T16 — I4 (preservation half): live state survives a slot rewrite
+# byte-identical. First the helpers in isolation, then the real fetch_release
+# offline-tarball path over a symlinked blue/green layout (Linux CI; skipped
+# where symlinks are unsupported, same convention as test_update.sh T4).
+# --------------------------------------------------------------------------
+t="$WORK/t16"; mkdir -p "$t/slot/backend/instance"
+printf 'SECRET_KEY=sentinel-abc123\nSERVERKIT_ENCRYPTION_KEY=k\n' > "$t/slot/.env"
+printf 'SQLITE-SENTINEL-BYTES\n' > "$t/slot/backend/instance/serverkit.db"
+cp "$t/slot/.env" "$t/env.orig"
+cp "$t/slot/backend/instance/serverkit.db" "$t/db.orig"
+if (
+ set -Eeuo pipefail
+ stash="$(stash_live_state "$t/slot")"
+ [ -n "$stash" ]
+ rm -rf "$t/slot" # the rewrite
+ mkdir -p "$t/slot/backend" # fresh tree: no .env, no instance/
+ restore_live_state "$stash" "$t/slot"
+ cmp -s "$t/slot/.env" "$t/env.orig"
+ cmp -s "$t/slot/backend/instance/serverkit.db" "$t/db.orig"
+) >/dev/null 2>&1; then
+ ok "stash/restore_live_state carries .env + instance DB byte-identical across a rewrite"
+else
+ bad "stash/restore_live_state lost or altered the live state"
+fi
+
+t="$WORK/t16r"; slotA="$t/sk-a"; slotB="$t/sk-b"; inst="$t/sk"
+mkdir -p "$slotA/backend/instance"
+printf 'SECRET_KEY=keep-me\n' > "$slotA/.env"
+printf 'DB-SENTINEL\n' > "$slotA/backend/instance/serverkit.db"
+cp "$slotA/.env" "$t/env.orig"; cp "$slotA/backend/instance/serverkit.db" "$t/db.orig"
+ln -sfn "$slotA" "$inst" 2>/dev/null || true
+if [ ! -L "$inst" ]; then
+ skip "fetch_release live-state carry — symlinks unsupported here (runs on Linux CI)"
+else
+ stage="$t/stage"; mkdir -p "$stage/serverkit/backend/app" "$stage/serverkit/scripts"
+ printf '#!/bin/sh\n' > "$stage/serverkit/serverkit"
+ printf '9.9.9\n' > "$stage/serverkit/VERSION"
+ tar czf "$t/rel.tar.gz" -C "$stage" serverkit
+ if (
+ set -Eeuo pipefail
+ INSTALL_DIR="$inst"; DIR_A="$slotA"; DIR_B="$slotB"; FIRST_SLOT="$slotA"
+ SERVERKIT_OFFLINE_TARBALL="$t/rel.tar.gz"
+ fetch_release
+ cmp -s "$slotA/.env" "$t/env.orig"
+ cmp -s "$slotA/backend/instance/serverkit.db" "$t/db.orig"
+ [ -d "$slotA/backend/app" ]
+ ) >/dev/null 2>&1; then
+ ok "fetch_release re-run preserves .env + database byte-identical (the data-loss bug)"
+ else
+ bad "fetch_release re-run destroyed or altered .env / the database (I4 regression)"
+ fi
+fi
+
+# --------------------------------------------------------------------------
+# T17 — I20: snapshot_existing must refresh a stale .backup instead of
+# silently keeping a months-old tree (which revert_install would then
+# restore over a much newer install).
+# --------------------------------------------------------------------------
+t="$WORK/t17"; mkdir -p "$t/inst"
+printf 'v1\n' > "$t/inst/marker"
+( set -Eeuo pipefail; INSTALL_DIR="$t/inst"; snapshot_existing ) >/dev/null 2>&1
+if [ -f "$t/inst.backup/marker" ] && grep -q v1 "$t/inst.backup/marker"; then
+ ok "snapshot_existing creates the first backup"
+else
+ bad "snapshot_existing did not create a backup"
+fi
+printf 'v2\n' > "$t/inst/marker"
+( set -Eeuo pipefail; INSTALL_DIR="$t/inst"; snapshot_existing ) >/dev/null 2>&1
+if grep -q v2 "$t/inst.backup/marker" 2>/dev/null && [ ! -d "$t/inst.backup.new" ]; then
+ ok "snapshot_existing refreshes a stale .backup on re-run (no months-old rollback source)"
+else
+ bad "snapshot_existing kept the stale backup (I20 regression) or left .backup.new behind"
+fi
+
+# --------------------------------------------------------------------------
+# T18 — I3: the release-venv install must not delete its own copy source. In
+# the default layout $VENV_DIR resolves to $FIRST_SLOT/venv, so the old
+# rm -rf + cp deleted the venv then failed to copy it. Same-path → keep in
+# place; distinct path → still copies.
+# --------------------------------------------------------------------------
+t="$WORK/t18"; mkdir -p "$t/slot/venv/bin" "$t/elsewhere"
+: > "$t/slot/venv/bin/activate"
+printf '#!/bin/sh\n' > "$t/slot/venv/bin/python"; chmod +x "$t/slot/venv/bin/python"
+if (
+ set -Eeuo pipefail
+ INSTALL_FROM_RELEASE=1; FIRST_SLOT="$t/slot"; VENV_DIR="$t/slot/venv"
+ build_virtualenv
+ [ -f "$t/slot/venv/bin/activate" ]
+) >/dev/null 2>&1; then
+ ok "build_virtualenv keeps the venv when source and destination are the same directory"
+else
+ bad "build_virtualenv deleted its own venv on the same-path layout (I3 regression)"
+fi
+if (
+ set -Eeuo pipefail
+ INSTALL_FROM_RELEASE=1; FIRST_SLOT="$t/slot"; VENV_DIR="$t/elsewhere/venv"
+ build_virtualenv
+ [ -f "$t/elsewhere/venv/bin/activate" ] && [ -f "$t/slot/venv/bin/activate" ]
+) >/dev/null 2>&1; then
+ ok "build_virtualenv still copies the release venv to a distinct VENV_DIR"
+else
+ bad "build_virtualenv failed to copy the release venv to a custom VENV_DIR"
+fi
+ln -sfn "$t/slot" "$t/link" 2>/dev/null || true
+if [ ! -L "$t/link" ]; then
+ skip "build_virtualenv symlinked default layout — symlinks unsupported here (runs on Linux CI)"
+else
+ if (
+ set -Eeuo pipefail
+ INSTALL_FROM_RELEASE=1; FIRST_SLOT="$t/slot"; VENV_DIR="$t/link/venv"
+ build_virtualenv
+ [ -x "$t/slot/venv/bin/python" ]
+ ) >/dev/null 2>&1; then
+ ok "build_virtualenv survives the default symlinked layout (/opt/serverkit → slot)"
+ else
+ bad "build_virtualenv broke on the symlinked layout (I3 regression)"
+ fi
+fi
+
+# --------------------------------------------------------------------------
+# T19 — I6/I12: pkg_add promises warn-and-continue, so a failing package
+# manager must produce a warning and exit 0 — the old body died on the
+# out=$(...) assignment under set -e, printing NOTHING. refresh_pkg_index is
+# best-effort too, and its yum arm must not use the dnf-only --refresh flag.
+# --------------------------------------------------------------------------
+t="$WORK/t19"; mkdir -p "$t/bin"
+printf '#!/usr/bin/env bash\necho "E: Unable to locate package"\nexit 100\n' > "$t/bin/apt-get"
+chmod +x "$t/bin/apt-get"
+out="$( set -Eeuo pipefail; PATH="$t/bin:$PATH"; PKG_MGR=apt pkg_add nosuchpkg 2>&1 )"
+rc=$?
+if [ "$rc" -eq 0 ] && printf '%s' "$out" | grep -q 'Could not install: nosuchpkg'; then
+ ok "pkg_add warns and returns 0 when the package manager fails (errexit-immune body)"
+else
+ bad "pkg_add rc=$rc (expected 0) or printed no warning: [$out]"
+fi
+if ( set -Eeuo pipefail; PATH="$t/bin:$PATH"; PKG_MGR=apt refresh_pkg_index ) >/dev/null 2>&1; then
+ ok "refresh_pkg_index is best-effort (a failed index refresh never aborts)"
+else
+ bad "refresh_pkg_index propagated a failure under set -e (I6 regression)"
+fi
+if ! grep -qE '^[^#]*yum makecache --refresh' "$INSTALL_SH"; then
+ ok "refresh_pkg_index yum arm avoids the dnf-only --refresh flag (I12)"
+else
+ bad "the yum arm uses 'makecache --refresh' again — that flag is dnf-only (I12 regression)"
+fi
+
+# --------------------------------------------------------------------------
+# T20 — I5: the RHEL-9 upfront openssh+openssl paired upgrade (drops sshd
+# 'OpenSSL version mismatch' on Rocky 9) must run the exact paired
+# transaction, survive a failing dnf, and no-op on other families.
+# --------------------------------------------------------------------------
+t="$WORK/t20"; mkdir -p "$t/bin"
+DNF_LOG="$t/dnf.log"; : > "$DNF_LOG"
+cat > "$t/bin/dnf" <<EOF
+#!/usr/bin/env bash
+printf '%s\n' "\$*" >> "$DNF_LOG"
+exit 1
+EOF
+chmod +x "$t/bin/dnf"
+if ( set -Eeuo pipefail; PATH="$t/bin:$PATH"; OS_FAMILY=rhel upgrade_rhel_crypto_stack ) >/dev/null 2>&1 \
+ && grep -q 'upgrade -y openssh openssh-server openssh-clients openssl openssl-libs openssl-devel' "$DNF_LOG"; then
+ ok "upgrade_rhel_crypto_stack upgrades openssh+openssl in ONE transaction and survives a failing dnf"
+else
+ bad "upgrade_rhel_crypto_stack missing/wrong dnf transaction or aborted (I5 regression)"
+fi
+: > "$DNF_LOG"
+( set -Eeuo pipefail; PATH="$t/bin:$PATH"; OS_FAMILY=debian upgrade_rhel_crypto_stack ) >/dev/null 2>&1
+if [ ! -s "$DNF_LOG" ]; then
+ ok "upgrade_rhel_crypto_stack is a no-op outside the RHEL family"
+else
+ bad "upgrade_rhel_crypto_stack ran dnf on a non-RHEL family"
+fi
+
+# --------------------------------------------------------------------------
+# T21 — I7: sync_source needs git but nothing installed it. Without git and
+# with the on-demand install failing, sync_source must halt LOUDLY (clear
+# message) before ever attempting the clone. Curated PATH: a failing apt-get
+# plus a real tail; no git anywhere.
+# --------------------------------------------------------------------------
+t="$WORK/t21"; mkdir -p "$t/bin"
+printf '#!/usr/bin/env bash\nexit 1\n' > "$t/bin/apt-get"; chmod +x "$t/bin/apt-get"
+printf '#!/usr/bin/env bash\nexec %s "$@"\n' "$(command -v tail)" > "$t/bin/tail"; chmod +x "$t/bin/tail"
+out="$( set -Eeuo pipefail; PATH="$t/bin"; PKG_MGR=apt sync_source 2>&1 )"
+rc=$?
+if [ "$rc" -ne 0 ] && printf '%s' "$out" | grep -q 'git is required'; then
+ ok "sync_source installs git on demand and halts clearly when that fails (never a cryptic clone error)"
+else
+ bad "sync_source rc=$rc without the 'git is required' halt: [$out]"
+fi
+
+# --------------------------------------------------------------------------
+# T22 — I8: locate_python must reject an interpreter whose venv module is
+# broken (Debian/Ubuntu minimal without pythonX.Y-venv → 'ensurepip is not
+# available' much later), and on Debian-family it must first try to install
+# the matching pythonX.Y-venv package.
+# --------------------------------------------------------------------------
+t="$WORK/t22"; PYX="$t/py"; mkdir -p "$PYX" "$t/bin"
+mkvless() { # mkvless <name> <major.minor> — version OK, `-m venv` broken
+ {
+ printf '#!/usr/bin/env bash\n'
+ printf 'if [ "${1:-}" = "-c" ]; then printf "%s"; exit 0; fi\n' "$2"
+ printf 'if [ "${1:-}" = "-m" ]; then exit 1; fi\n'
+ printf 'exit 0\n'
+ } > "$PYX/$1"
+ chmod +x "$PYX/$1"
+}
+mkvless python3.12 3.13 # out of range — rejected before the venv probe
+mkvless python3.11 3.11 # in range but venv-less — must be rejected
+mkvless python3 3.10 # too old
+if ( set -Eeuo pipefail; PATH="$PYX:$PATH"; locate_python ) >/dev/null 2>&1; then
+ bad "locate_python accepted a venv-less interpreter (I8 regression)"
+else
+ ok "locate_python rejects an interpreter whose '-m venv' is broken"
+fi
+APT_LOG="$t/apt.log"; : > "$APT_LOG"
+cat > "$t/bin/apt-get" <<EOF
+#!/usr/bin/env bash
+printf '%s\n' "\$*" >> "$APT_LOG"
+exit 1
+EOF
+chmod +x "$t/bin/apt-get"
+( set -Eeuo pipefail; PATH="$t/bin:$PYX:$PATH"; OS_FAMILY=debian PKG_MGR=apt locate_python ) >/dev/null 2>&1
+if grep -q 'install -y python3.11-venv' "$APT_LOG"; then
+ ok "locate_python (Debian family) tries to install the matching pythonX.Y-venv package"
+else
+ bad "locate_python never attempted the python3.11-venv fallback; apt saw: $(tr '\n' ';' < "$APT_LOG")"
+fi
+
+# --------------------------------------------------------------------------
+# T23 — I9: distro-repo Docker (docker.io) has no Docker-repo
+# 'docker-compose-plugin'; ensure_compose_plugin must fall back to Ubuntu's
+# 'docker-compose-v2' and, when neither lands, warn and continue instead of
+# aborting the install.
+# --------------------------------------------------------------------------
+t="$WORK/t23"; mkdir -p "$t/bin"
+APT_LOG="$t/apt.log"; : > "$APT_LOG"
+printf '#!/usr/bin/env bash\nexit 1\n' > "$t/bin/docker"; chmod +x "$t/bin/docker"
+cat > "$t/bin/apt-get" <<EOF
+#!/usr/bin/env bash
+printf '%s\n' "\$*" >> "$APT_LOG"
+exit 100
+EOF
+chmod +x "$t/bin/apt-get"
+out="$( set -Eeuo pipefail; PATH="$t/bin:$PATH"; PKG_MGR=apt ensure_compose_plugin 2>&1 )"
+rc=$?
+if [ "$rc" -eq 0 ] && grep -q 'install -y docker-compose-plugin' "$APT_LOG" \
+ && grep -q 'install -y docker-compose-v2' "$APT_LOG" \
+ && printf '%s' "$out" | grep -q 'docker compose'; then
+ ok "ensure_compose_plugin tries plugin → docker-compose-v2 → warn-and-continue (never aborts)"
+else
+ bad "ensure_compose_plugin rc=$rc; apt saw: $(tr '\n' ';' < "$APT_LOG")"
+fi
+
+# --------------------------------------------------------------------------
+# T24 — I10: dnf5 (Fedora 41+) removed `config-manager --add-repo URL`;
+# docker_repo_add must fall back to the dnf5 `addrepo --from-repofile=` form,
+# and stay warn-and-continue when both forms fail.
+# --------------------------------------------------------------------------
+t="$WORK/t24"; mkdir -p "$t/bin"
+DNF_LOG="$t/dnf.log"; : > "$DNF_LOG"
+cat > "$t/bin/dnf" <<EOF
+#!/usr/bin/env bash
+printf '%s\n' "\$*" >> "$DNF_LOG"
+case "\$*" in
+ "config-manager --add-repo "*) exit 1 ;; # dnf5: flag removed
+ "config-manager addrepo "*) exit 0 ;;
+esac
+exit 0
+EOF
+chmod +x "$t/bin/dnf"
+if ( set -Eeuo pipefail; PATH="$t/bin:$PATH"
+ docker_repo_add https://example.invalid/docker-ce.repo ) >/dev/null 2>&1 \
+ && grep -q 'config-manager addrepo --from-repofile=https://example.invalid/docker-ce.repo' "$DNF_LOG"; then
+ ok "docker_repo_add falls back to the dnf5 addrepo syntax when --add-repo fails"
+else
+ bad "docker_repo_add never tried the dnf5 syntax; dnf saw: $(tr '\n' ';' < "$DNF_LOG")"
+fi
+printf '#!/usr/bin/env bash\nexit 1\n' > "$t/bin/dnf"; chmod +x "$t/bin/dnf"
+if ( set -Eeuo pipefail; PATH="$t/bin:$PATH"
+ docker_repo_add https://example.invalid/docker-ce.repo ) >/dev/null 2>&1; then
+ ok "docker_repo_add warns and continues when both config-manager forms fail"
+else
+ bad "docker_repo_add aborted when both config-manager forms failed (must warn-and-continue)"
+fi
+
+# --------------------------------------------------------------------------
+# T25 — I21: a failing state_set/state_append (e.g. unwritable
+# install-state.json) must not abort the firewall phase whose actual firewall
+# work already succeeded. The state file is pointed under a regular FILE so
+# state.sh's python genuinely fails; ufw is stubbed so firewall_open runs.
+# --------------------------------------------------------------------------
+if command -v python3 >/dev/null 2>&1; then
+ t="$WORK/t25"; mkdir -p "$t/bin"
+ printf '#!/usr/bin/env bash\nexit 0\n' > "$t/bin/ufw"; chmod +x "$t/bin/ufw"
+ : > "$t/blocker" # regular file — state.json can't live under it
+ out="$(
+ set -Eeuo pipefail
+ export PATH="$t/bin:$PATH"
+ export SERVERKIT_STATE_FILE="$t/blocker/state.json"
+ FIREWALL_BACKEND=ufw configure_firewall 2>&1
+ )"
+ rc=$?
+ if [ "$rc" -eq 0 ] && printf '%s' "$out" | grep -q 'Firewall configured'; then
+ ok "configure_firewall survives failing state_set/state_append (records are best-effort)"
+ else
+ bad "configure_firewall rc=$rc when state writes fail (I21 regression): [$out]"
+ fi
+else
+ skip "configure_firewall state-failure guard — python3 unavailable here"
+fi
+
+# --------------------------------------------------------------------------
+# T26 — regression guards baked into the source (same spirit as
+# test_update.sh T26): the audited failure shapes must never creep back in.
+# --------------------------------------------------------------------------
+guards_ok=1
+if grep -qE '^[^#]*backend/src' "$INSTALL_SH"; then
+ bad "install.sh probes backend/src again — that path never exists (I4 detection regression)"
+ guards_ok=0
+fi
+if ! grep -qE '^[[:space:]]*upgrade_rhel_crypto_stack$' "$INSTALL_SH"; then
+ bad "main() no longer calls upgrade_rhel_crypto_stack (I5 regression)"
+ guards_ok=0
+fi
+[ "$guards_ok" = "1" ] && ok "source guards: no backend/src probe; main runs the RHEL crypto upgrade"
+
# --------------------------------------------------------------------------
printf '\n%d passed, %d failed, %d skipped\n\n' "$PASS" "$FAIL" "$SKIP"
[ "$FAIL" -eq 0 ]