#!/bin/bash
killall autossh
sleep 2
# Tunnel to cloud MongoDB on port 10203 with reverse tunnels for MongoDB on localhost:10201 and through tunnel on localhost:10202 to P1 #2
AUTOSSH_LOGLEVEL=7 AUTOSSH_POLL=5 autossh -M 20500 -f -A -N \
  -L 22443:sapsailing.com:443 \
  -L 22222:sapsailing.com:22 \
  -R 9443:localhost:9443 \
  -L 443:security-service.sapsailing.com:443 \
  -R 10201:localhost:10201 \
  -L 10203:localhost:10203 \
  -L 5673:rabbit-eu-west-3.sapsailing.com:5672 \
  -L 15673:localhost:15673 \
  -L 5675:rabbit.internal.sapsailing.com:5672 \
  -L 15675:rabbit.internal.sapsailing.com:15672 \
  -R 18122:localhost:22 \
  -L 588:email-smtp.eu-west-1.amazonaws.com:587 \
  ec2-user@paris-ssh.sapsailing.com
sleep 2
# Tunnel to other laptop P1 #2, tunneling to MongoDB running on 10202, mapping to local port 10202
AUTOSSH_LOGLEVEL=7 AUTOSSH_POLL=5 autossh -M 20502 -f -A -N \
  -L 15674:localhost:15672 \
  -L 10202:localhost:10202 \
  -R 10201:localhost:10201 \
  sailing@sap-p1-2
sleep 2
# Tunnel to localhost for TracTrac A port forwards
tractrac-A
