Skip to content

Commit

Permalink
add RECONNECT variable to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Julio Gutierrez committed May 28, 2021
1 parent b08af10 commit a7a60a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ services:
* `NETWORK6` - CIDR IPv6 networks (IE fe00:d34d:b33f::/64), add a route to allows replies once the VPN is up.
* `PORTS` - Semicolon delimited list of ports to whitelist for both UDP and TCP. For example '- PORTS=9091;9095'
* `PORT_RANGE` - Port range to whitelist for both UDP and TCP. For example '- PORT_RANGE=9091 9095'
* `RECONNECT` - Time in seconds to check connection and reconnect if need it. (300 by default) For example '- RECONNECT=600'
* `DEBUG` - Set to 'on' for troubleshooting (User and Pass would be logged).

# Issues
Expand Down
23 changes: 9 additions & 14 deletions start_vpn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ connect() {
cat /var/log/nordvpn/daemon.log
exit 1
}
tail -f --pid="$(cat /run/nordvpn/nordvpn.pid)" /var/log/nordvpn/daemon.log &
}
connect

Expand All @@ -174,17 +175,11 @@ cleanup() {
}
trap cleanup SIGTERM SIGINT EXIT # https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/

if [[ -n ${RECONNECT} ]]; then
tail -f --pid="$(cat /run/nordvpn/nordvpn.pid)" /var/log/nordvpn/daemon.log &
while true; do
sleep "${RECONNECT}"
if [ "$(curl -m 20 -s https://api.nordvpn.com/v1/helpers/ips/insights | jq -r '.["protected"]')" != "true" ]; then
echo "Reconnecting..."
restart_daemon
connect
tail -f --pid="$(cat /run/nordvpn/nordvpn.pid)" /var/log/nordvpn/daemon.log &
fi
done
else
tail -f --pid="$(cat /run/nordvpn/nordvpn.pid)" /var/log/nordvpn/daemon.log
fi
while true; do
sleep "${RECONNECT:-300}"
if [ "$(curl -m 20 -s https://api.nordvpn.com/v1/helpers/ips/insights | jq -r '.["protected"]')" != "true" ]; then
echo "Reconnecting..."
restart_daemon
connect
fi
done

0 comments on commit a7a60a5

Please sign in to comment.