title: Automatically establish ssh-tunnel, wait until ssh-tunnel is established, then establish normal VPN connection
body: <p>I got this script:</p>
  
  <pre><code>#!/usr/bin/env bash
  
  if [ ! "$UID" = 0 ]; then
      if [ `type -P gksu` ]; then
          SUDOAPP="gksu"
      elif [ `type -P kdesu` ]; then
          SUDOAPP="kdesu"
      else
          SUDOAPP="sudo"
      fi
  fi
  
  if [ -n "$1" ]; then
      if [ "$1" = "start" ]; then
          $SUDOAPP systemctl start openvpn@******
      elif [ "$1" = "stop" ]; then
          $SUDOAPP systemctl stop openvpn@******
      elif [ "$1" = "restart" ]; then
          $SUDOAPP systemctl restart openvpn@******
      else
          echo "Invalid command"
          exit 1
      fi
  else
      echo "Run 'start', 'stop' or 'restart' as an argument to start, stop or restart the ******"
      exit 1
  fi
  </code></pre>
  
  <p>It works fine. However I also need to establish the ssh tunnel. - Before openvpn connects to my VPN. I've got a script which does precisely that:</p>
  
  <pre><code>#!/bin/bash
  # --------------------------------------------------------
  # ******* | https://******.org | ****************************************
  # SSH Client Configuration, Linux/OSX
  # ******_*************
  # --------------------------------------------------------
  
  chmod 600 /etc/openvpn/sshtunnel.key
  while :
  do
  echo ""; echo "****** SSH Tunnel"
  ssh -i /etc/openvpn/sshtunnel.key -L ****:127.0.0.1:**** sshtunnel@**.**.**.* -p ** -N -T -v
  read -t 5 -p "Retry? (or wait 5 sec for Y)" yn
  if [[ $yn == "n" || $yn == "N" ]]; then break; fi
  done
  </code></pre>
  
  <p>How do I add this to the first script in a way as to make the openvpn part wait until the ssh client is fired up?</p>