#!/bin/sh
# Establish a persistent SSH reverse tunnel from Omega13 to the VPS.
# Each agent gets its own port on the VPS, forwarded directly to its container
# on the Omega13 Docker network. One SSH connection, one -R flag per agent.
set -e

exec autossh -M 0 -N \
  -i /run/tunnel/id_ed25519 \
  -o "UserKnownHostsFile=/run/tunnel/known_hosts" \
  -o "StrictHostKeyChecking=yes" \
  -o "ServerAliveInterval=30" \
  -o "ServerAliveCountMax=3" \
  -o "ExitOnForwardFailure=yes" \
  -R 0.0.0.0:50001:dobby:80 \
  -R 0.0.0.0:50002:gemma:80 \
  -R 0.0.0.0:50003:gunnar:80 \
  -R 0.0.0.0:50005:rind:80 \
  -R 0.0.0.0:50006:abyssinthia:80 \
  -R 0.0.0.0:50007:gerhard:80 \
  tunnel@glitch.university
