#!/bin/sh

HOST=YOUR_SYNERGY_SERVER

pgrep synergyc >/dev/null && exit 1

function tunnelup() {
  if netstat -tnlp 2> /dev/null | grep 127.0.0.1:24800 | grep -q ssh ; then
    return 0
  else
    return 1
  fi
}

tunnelup || ssh -f -N -L 24800:localhost:24800 $HOST 
tunnelup && synergyc -f -1 localhost > /dev/null 2>&1 &

