diff --git a/qbittorrent/rootfs/etc/cont-init.d/01-openvpn.sh b/qbittorrent/rootfs/etc/cont-init.d/01-openvpn.sh index 2028732a6..34f03909e 100644 --- a/qbittorrent/rootfs/etc/cont-init.d/01-openvpn.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/01-openvpn.sh @@ -3,13 +3,25 @@ set -e mkdir -p /config/openvpn +QBT_CONFIG_FILE="/config/qBittorrent/config/qBittorrent.conf" -if [ -d /config/openvpn ]; then - if [ -n "$(ls -A /config/openvpn 2>/dev/null)" ]; then - # Modify ovpn config - if ! grep -q route-nopull /etc/openvpn/config.ovpn; then - echo "... adding route-nopull to your config.ovpn" - sed -i "1a route-nopull" /etc/openvpn/config.ovpn +# Correct openvpn files +if [ bashio::config "VPN_ENABLED" == "yes" ]; then + + # If there is a config file, add nopull + if [ -n "$(ls -A /config/openvpn 2>/dev/null)" ]; then + if ! grep -q route-nopull /etc/openvpn/config.ovpn; then + echo "... adding route-nopull to your config.ovpn" + sed -i "1a route-nopull" /etc/openvpn/config.ovpn + fi fi - fi + +else + + # Ensure no redirection by removing the direction tag + if [ -f "$QBT_CONFIG_FILE" ]; then + sed -i '/Interface/d' "$QBT_CONFIG_FILE" + fi + bashio::log.info "... direct connection without VPN enabled" + fi