#!/bin/bash
# Initial sync: only hold the tunnel open while the sync is happening.
ssh -L 5439:localhost:5432 -N -i "$HOME/.ssh/id_wdiwtlt@jdb-mg-vm" _wdiwtlt@pufferfish.jdb-labs.com &
PID=$!
wdiwtlt --sync-only
kill "$PID"

# Launch in interactive mode for the user
wdiwtlt

# Sync again after the user finishes using the program.
ssh -L 5439:localhost:5432 -N -i "$HOME/.ssh/id_wdiwtlt@jdb-mg-vm" _wdiwtlt@pufferfish.jdb-labs.com &
PID=$!
wdiwtlt --sync-only
kill "$PID"
