Skip to content

Commit

Permalink
Update 93-openvpn.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbelgium authored Dec 29, 2023
1 parent c9b946b commit aee7679
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ if bashio::config.true 'openvpn_enabled'; then
bashio::log.info "Openvpn enabled, configuring"
bashio::log.info "----------------------------"

# If openvpn_config not set, but folder is not empty
if [ ! "$(ls -A /config/openvpn/*.ovpn 2>/dev/null)" ]; then
bashio::exit.nok "Configured ovpn file : $openvpn_config not found! Are you sure you added it in /addon_configs/$HOSTNAME/openvpn using the Filebrowser addon ?"
fi

# Get current ip
curl -s ipecho.net/plain > /currentip

Expand Down Expand Up @@ -46,6 +41,7 @@ if bashio::config.true 'openvpn_enabled'; then
else
# Print an error message
bashio::log.warning "$file_name is referenced in your ovpn file but does not exist, and can't be found either in the /config/openvpn/ directory"
sleep 5
fi
fi
fi
Expand All @@ -54,7 +50,6 @@ if bashio::config.true 'openvpn_enabled'; then
# Standardize lf
dos2unix "$file"


# Correct paths
sed -i "s=/etc/openvpn=/config/openvpn=g" "$file"

Expand Down Expand Up @@ -82,10 +77,12 @@ if bashio::config.true 'openvpn_enabled'; then
else
bashio::exit.nok "Configured ovpn file : $openvpn_config is set but does not end by .ovpn ; it can't be used!"
fi
else
bashio::exit.nok "Configured ovpn file : $openvpn_config not found! Are you sure you added it in /addon_configs/$HOSTNAME/openvpn using the Filebrowser addon ?"
fi

# If openvpn_config not set, but folder is not empty
else
# If openvpn_config not set, but folder is not empty
elif [ ! "$(ls -A /config/openvpn/*.ovpn 2>/dev/null)" ]; then
# Look for openvpn files
# Wildcard search for openvpn config files and store results in array
mapfile -t VPN_CONFIGS < <( find /config/openvpn -maxdepth 1 -name "*.ovpn" -print )
Expand All @@ -100,6 +97,10 @@ if bashio::config.true 'openvpn_enabled'; then
cp /config/openvpn/* /etc/openvpn/
# Standardize file
cp /config/openvpn/"${openvpn_config}" /etc/openvpn/config.ovpn

# If openvpn_enabled set, config not set, and openvpn folder empty
else
bashio::exit.nok "openvpn_enabled is set, however, your openvpn folder is empty ! Are you sure you added it in /addon_configs/$HOSTNAME/openvpn using the Filebrowser addon ?"
fi

# Set credentials
Expand Down

0 comments on commit aee7679

Please sign in to comment.