#!/usr/bin/env bash
set -euo pipefail
CONFIG="$HOME/.ssh/bestweb_tunnel_config.conf"
HOST="bestweb-bastion"

if [ ! -f "$CONFIG" ]; then
  echo "Missing SSH config at $CONFIG" >&2
  exit 1
fi

ssh -F "$CONFIG" "$HOST" -N &
TUNNEL_PID=$!
echo "$TUNNEL_PID" > /tmp/bestweb_tunnel.pid

echo "BestWeb tunnel started (PID $TUNNEL_PID). Forwarding local 8765 -> remote 10.0.0.12:8765."
