From 3c4af4a75c9386535ab84b3532a928755e6373b3 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 4 Jul 2022 10:06:18 +0200 Subject: [PATCH] Test : periodically check VPN is up https://github.com/alexbelgium/hassio-addons/issues/377 --- qbittorrent/rootfs/etc/services.d/nginx/run | 26 +++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/qbittorrent/rootfs/etc/services.d/nginx/run b/qbittorrent/rootfs/etc/services.d/nginx/run index 8918ca6c6..03198c1c3 100644 --- a/qbittorrent/rootfs/etc/services.d/nginx/run +++ b/qbittorrent/rootfs/etc/services.d/nginx/run @@ -26,12 +26,30 @@ if [ -f /currentip ]; then # Inform by message bashio::log.info "VPN is up and running with ip $(cat /vpnip), based in country : $COUNTRY" - - rm /vpnip - rm /currentip fi bashio::log.info "Starting NGinx..." -exec nginx +# Check vpn is working +if [ -f /currentip ]; then + exec nginx & \ + while true; do + sleep 15m + # Get vpn ip + if bashio::config.true 'openvpn_alt_mode'; then + curl -s ipecho.net/plain > /vpnip + else + curl -s ipecho.net/plain --interface tun0 > /vpnip + fi + + # Verify ip has changed + if [[ "$(cat /vpnip)" = "$(cat /currentip)" ]]; then + bashio::log.fatal "VPN is not properly configured. Your ip is exposed. Please fix this, or do not use the vpn alt mode" + bashio::exit.nok + fi + true + done +else + exec nginx +fi