interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / infra / test / hub-rehearsal.sh

18 lines · 1407 bytes Raw Blame History
1#!/usr/bin/env bash
2# Dress rehearsal of infra/hub/forge-edge-apply.sh + forge-edge-rollback.sh against a COPY of the
3# hub's live /etc/nginx (certs and old backups excluded), in a throwaway ubuntu:26.04 container
4# with Ubuntu's nginx + stream module (the hub runs Ubuntu 26.04, nginx 1.28.3).
5# Reads the hub (sudo tar of /etc/nginx); changes nothing there. Run on spark:
6# taskset -c 2 nice -n 10 bash infra/test/hub-rehearsal.sh
7set -u
8INFRA=$(cd "$(dirname "$0")/.." && pwd)
9W=$(mktemp -d /tmp/forge-rehearsal.XXXXXX)
10trap 'rm -rf "$W"' EXIT
11ssh -o BatchMode=yes hub 'sudo -n tar -C /etc -cf - --exclude=nginx/certs --exclude=nginx/sitehub-backups --exclude=nginx/forge-backups nginx' > "$W/etc-nginx.tar" \
12 || { echo "could not read hub /etc/nginx"; exit 2; }
13echo "hub /etc/nginx copy: $(tar -tf "$W/etc-nginx.tar" | wc -l) entries, sha256 $(sha256sum < "$W/etc-nginx.tar" | cut -c1-16)"
14# Once the edge is live the hub copy already carries it: also fetch the first apply's backup, from
15# which the container rebuilds the pre-apply state (empty file when there is none).
16PRE=${REHEARSAL_PRE_BACKUP:-20261107T110404Z}
17ssh -o BatchMode=yes hub "sudo -n tar -C /etc/nginx/forge-backups -cf - $PRE 2>/dev/null" > "$W/pre-apply.tar" || : > "$W/pre-apply.tar"
18docker run --rm --cpuset-cpus "${REHEARSAL_CPUS:-2}" -v "$INFRA:/infra:ro" -v "$W:/w:ro" ubuntu:26.04 bash /infra/test/hub-rehearsal-inner.sh