aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/autotunnel
blob: 0a2d8d020c3f731a214026630e710d8bf55e0021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash

set -eou pipefail

if [ -z "$SERVER_ALIVE_INTERVAL" ];then
  SERVER_ALIVE_INTERVAL=45
fi

if [ -z "$SERVER_ALIVE_COUNT_MAX" ];then
  SERVER_ALIVE_COUNT_MAX=2
fi

if [ -z "$MONITORING_PORT" ];then
  MONITORING_PORT=0
fi

/usr/bin/autossh -M "$MONITORING_PORT" \
  -NCTv \
  -o ServerAliveInterval="$SERVER_ALIVE_INTERVAL" \
  -o ServerAliveCountMax="$SERVER_ALIVE_COUNT_MAX" \
  -o TCPKeepAlive=yes \
  -w "$TUN_DEVICE":"$TUN_DEVICE" \
  "$HOST"