summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xvpn_reset_ping_loop.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/vpn_reset_ping_loop.sh b/vpn_reset_ping_loop.sh
new file mode 100755
index 0000000..7410c4b
--- /dev/null
+++ b/vpn_reset_ping_loop.sh
@@ -0,0 +1,24 @@
1#!/bin/bash
2
3ping_host="vpn-1.us-east-2.crute.me"
4fallback_ip="172.16.35.10"
5
6ping_ip=$(host $ping_host)
7if [ $? != 0 ]; then
8 >&2 echo "Host lookup failed, using fallback IP"
9 ping_ip="$fallback_ip"
10else
11 ping_ip=$(echo $ping_ip | awk '{ print $4 }')
12fi
13
14while true; do
15 echo "Loop"
16 if ! ping -n -W 5 -c 1 $ping_ip >/dev/null; then
17 echo "/usr/sbin/ipsec restart"
18
19 for conn in $(awk '/^conn [^%]/ { print $2 }' /etc/ipsec.conf); do
20 echo "/usr/sbin/ipsec up $conn"
21 done
22 fi
23 sleep 1
24done