From 31168280fefe9d3fd0b8a7aa0b571e94a6fc084f Mon Sep 17 00:00:00 2001 From: redxef Date: Thu, 30 Jun 2022 16:45:34 +0200 Subject: [PATCH] Add debug output if connection to VPN fails. Increase timeout to 10secs. --- start-openvpn.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/start-openvpn.sh b/start-openvpn.sh index a5f8b7f..8724a5e 100644 --- a/start-openvpn.sh +++ b/start-openvpn.sh @@ -2,6 +2,8 @@ set -o pipefail +OVPN_LOG_FILE=/tmp/ovpnlog.txt + change_hostname() { echo VPNDOCKER > /etc/hostname } @@ -17,7 +19,7 @@ connect_vpn() { -e 's|^down .*$|down /etc/openvpn/down.sh|' \ -e 's|^auth-user-pass.*$|auth-user-pass|' \ "$OVPN_CONFIGURATION_FILE" > /tmp/ovpn.conf - openvpn --config /tmp/ovpn.conf --daemon + openvpn --config /tmp/ovpn.conf --log "$OVPN_LOG_FILE" --daemon } get_ip() { @@ -45,7 +47,7 @@ fi change_hostname create_net_dev connect_vpn -for _ in {1..50}; do +for _ in {1..100}; do vpn_ip="$(get_ip)" if [ "$vpn_ip" = "$own_ip" ] || [ "$vpn_ip" = "" ]; then sleep .1 @@ -55,6 +57,8 @@ for _ in {1..50}; do done if [ "$vpn_ip" = "$own_ip" ] || [ "$vpn_ip" = "" ]; then echo "ERROR: Failed to connect to VPN (vpn_ip=$vpn_ip), aborting" >&2 + echo "Ovpn log:" >&2 + cat "$OVPN_LOG_FILE" >&2 exit 1 fi echo "VPN IP: $vpn_ip"