homek8s/infrastructure/networking/rosenpass/linkb-rollback-linode.sh
Lance Walters 5fc7cd4ead docs(rosenpass): commit the Link B host artifacts and the endpoint decision
Link B (rpi wg-remote 10.20.0.2 <-> linode wg0 10.20.0.1) is now under
Rosenpass too. The pieces that only existed on the hosts are committed
here with an install/diagnosis write-up, because all three are runtime
state someone will have to rebuild:

- rosenpass-upnp.{sh,service,timer} - re-assert the permanent UPnP mapping
  UDP 9999 -> 192.168.1.125 every 15 min (the router has no admin panel,
  and a dropped mapping is silent).
- linkb-rollback-{rpi,linode}.sh - the self-cancelling watchdogs; this link
  carries the only SSH path to the linode, so the rollback is local and
  staged on both ends before the far unit starts.
- linkb-verify.sh - hashes each end's PSK and compares them without
  printing key material.

Endpoint strategy recorded: the Pi's public address is residential DHCP
but provably static (IGD uptime since 2026-09-10, ~83 days on the
configured 137.118.156.124), so the linode config pins it and a moved
address is caught by the per-interface rotation-age series rather than by
a sync timer.
2026-12-03 02:46:10 -05:00

40 lines
1.5 KiB
Shell
Executable file

#!/bin/bash
# Self-cancelling rollback for the Link B rollout, Linode end (wg0 hub).
#
# Armed as a transient `systemd-run --on-active=420s` timer on the Linode before
# rosenpass is started there. It acts locally, because the only SSH path to this
# host runs over the tunnel a PSK mismatch would break.
#
# Cancelled by touching /run/rosenpass-linkb-ok on this host once rotation and
# the cluster are verified.
#
# What it restores: the static PresharedKeys of every peer in
# /etc/wireguard/wg0.conf, and stops/disables the rosenpass unit. It never
# brings the interface down.
set -u
log() { logger -t rosenpass-linkb "$*"; echo "$*"; }
# Self-cancel: the operator touches this flag after verification, so this script
# is a no-op if the run actually succeeded.
if [ -f /run/rosenpass-linkb-ok ]; then
log "watchdog fired but /run/rosenpass-linkb-ok exists - no action taken"
exit 0
fi
log "ROLLBACK triggered: Link B did not verify within the watchdog window"
systemctl disable --now rosenpass.service || log "warn: disable --now rosenpass failed"
if wg-quick strip wg0 > /run/wg0.rollback.stripped 2>/dev/null; then
if wg syncconf wg0 /run/wg0.rollback.stripped; then
log "wg0 synced from conf: static PresharedKeys restored for all peers"
else
log "ERROR: wg syncconf wg0 failed; live PSKs unchanged"
fi
else
log "ERROR: wg-quick strip wg0 failed; live PSKs unchanged"
fi
rm -f /run/wg0.rollback.stripped
log "ROLLBACK done - verify: wg show wg0 latest-handshakes (rpi peer < 180 s)"