Gateway: fallback routes per host, for the laptop's VPN address
Gateway / check (push) Successful in 9s
Gateway / image (push) Successful in 22s

This commit is contained in:
gib committed 2026-11-01 13:20:02 -05:00
1 parent f46c803ad4
commit 42b6a4920c
8 files changed
+151 -20

No files matched your search

+8 -3
View File
@@ -13,12 +13,15 @@ GATEWAY_SSH="${GATEWAY_SSH:-junior.gib}"
GATEWAY_RUNTIME="${GATEWAY_RUNTIME:-podman}"
GATEWAY_CONTAINER="${GATEWAY_CONTAINER:-wristcode-gateway}"
# label | SSH host, or "local" for the machine running this script | public T3 URL
# label | SSH host, or "local" for the machine running this script | public T3 URLs
# A host can list several URLs, space separated, preferred first. The gateway falls back to the
# next one when a route does not answer, such as the laptop's VPN route when it is away from home.
HOSTS=(
"Desktop|local|https://t3desktop.gbrown.org"
"Mac mini|mac.gib|https://t3mac.gbrown.org"
"server-gib|server.gib|https://t3sr.gbrown.org"
"LittleMan|junior.gib|https://t3jr.gbrown.org"
"Laptop|laptop.gib|https://t3laptop.gbrown.org https://t3laptopvpn.gbrown.org"
)
# Prints a pairing credential. Runs on the T3 host. The CLI is not on PATH in non-login shells,
@@ -36,7 +39,9 @@ done
'
renew() {
local label="$1" ssh_host="$2" url="$3" credential
local label="$1" ssh_host="$2" url alternates alternate credential alt_args=""
read -r url alternates <<<"$3"
for alternate in $alternates; do alt_args+=" --alt-url '$alternate'"; done
if [ "$ssh_host" = "local" ]; then
credential="$(bash -c "$MINT")"
else
@@ -48,7 +53,7 @@ renew() {
fi
# The credential travels on stdin, not on a command line other processes could read.
ssh -o BatchMode=yes "$GATEWAY_SSH" \
"read -r credential && $GATEWAY_RUNTIME exec $GATEWAY_CONTAINER wristcode host add '$url' \"\$credential\" --label '$label'" \
"read -r credential && $GATEWAY_RUNTIME exec $GATEWAY_CONTAINER wristcode host add '$url' \"\$credential\" --label '$label'$alt_args" \
<<<"$credential"
}