#!/bin/bash
killall autossh
sleep 2
# With no Internet, tokyo-ssh.sapsailing.com and rabbit-api-northeast-1.sapsailing.com and rabbit.internal.sapsailing.com are unreachable; we'll use 
# the RabbitMQ on sap-p1-2 instead. Furthermore, security-service.sapsailing.com is then not reachable, and we expect a local backup
# copy to be launched, reachable through sap-p1-1 (this host)'s NGINX on port 9443. A reverse port forward from sap-p1-2:443 to
# localhost:9443 is established for access to this security-service.sapsailing.com backup replacement.
#autossh -M 20500 -f -A -N -R 9443:localhost:9443 -R '*:8888:localhost:8888' -R 10201:localhost:10201 -L 10203:localhost:10203 -L 5673:rabbit-ap-northeast-1.sapsailing.com:5672 -L 15673:localhost:15673 -L 5675:rabbit.internal.sapsailing.com:5672 -L 15675:rabbit.internal.sapsailing.com:15672 -L 443:security-service.sapsailing.com:443 -R 18122:localhost:22 ec2-user@tokyo-ssh.sapsailing.com
# Tunnel to other laptop P1 #2, tunneling to MongoDB running on 10202, mapping to local port 10202
autossh -M 20502 -f -A -N -L 10202:localhost:10202 -R 10201:localhost:10201 sailing@sap-p1-2
sleep 2
# An additional port forward from 443 to NGINX 9443 is required to reach a local backup copy of security-service.sapsailing.com
autossh -M 20504 -f -A -N -L 443:localhost:9443 -L 5673:localhost:5672 -L 15673:localhost:15672 -L 5675:localhost:5672 -L 15675:localhost:15672 localhost
# Tunnel to localhost for TracTrac A port forwards
tractrac-A
