Fixed breakage caused by splitting on SPACE in OPENVPN_CONFIG
Changed to split on comma as many openvpn configs have space in the name. Added a bit more validation that a provider is set. Updated docs.
This commit is contained in:
@@ -65,10 +65,10 @@ Find available OpenVPN configurations by looking in the openvpn folder of the Gi
|
|||||||
-e "OPENVPN_CONFIG=ipvanish-AT-Vienna-vie-c02"
|
-e "OPENVPN_CONFIG=ipvanish-AT-Vienna-vie-c02"
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also provide a list of openvpn configuration filenames separated by a space.
|
You can also provide a comma separated list of openvpn configuration filenames.
|
||||||
If you provide a list, a file will be randomly chosen in the list, this is useful for redundancy setups. For example:
|
If you provide a list, a file will be randomly chosen in the list, this is useful for redundancy setups. For example:
|
||||||
```
|
```
|
||||||
-e "OPENVPN_CONFIG=ipvanish-AT-Vienna-vie-c02 ipvanish-FR-Paris-par-a01 ipvanish-DE-Frankfurt-fra-a01"
|
-e "OPENVPN_CONFIG=ipvanish-AT-Vienna-vie-c02,ipvanish-FR-Paris-par-a01,ipvanish-DE-Frankfurt-fra-a01"
|
||||||
```
|
```
|
||||||
If you provide a list and the selected server goes down, after the value of ping-timeout the container will be restarted and a server will be randomly chosen, note that the faulty server can be chosen again, if this should occur, the container will be restarted again until a working server is selected.
|
If you provide a list and the selected server goes down, after the value of ping-timeout the container will be restarted and a server will be randomly chosen, note that the faulty server can be chosen again, if this should occur, the container will be restarted again until a working server is selected.
|
||||||
|
|
||||||
|
@@ -1,7 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
VPN_PROVIDER="${OPENVPN_PROVIDER,,}"
|
VPN_PROVIDER="${OPENVPN_PROVIDER,,}"
|
||||||
VPN_PROVIDER_CONFIGS="/etc/openvpn/${VPN_PROVIDER}"
|
VPN_PROVIDER_CONFIGS="/etc/openvpn/${VPN_PROVIDER}"
|
||||||
if [[ ! -d "${VPN_PROVIDER_CONFIGS}" ]]; then
|
|
||||||
|
if [[ "${OPENVPN_PROVIDER}" == "**None**" ]] || [[ -z "${OPENVPN_PROVIDER-}" ]]; then
|
||||||
|
echo "OpenVPN provider not set. Exiting."
|
||||||
|
exit 1
|
||||||
|
elif [[ ! -d "${VPN_PROVIDER_CONFIGS}" ]]; then
|
||||||
echo "Could not find OpenVPN provider: ${OPENVPN_PROVIDER}"
|
echo "Could not find OpenVPN provider: ${OPENVPN_PROVIDER}"
|
||||||
echo "Please check your settings."
|
echo "Please check your settings."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -9,14 +13,12 @@ fi
|
|||||||
|
|
||||||
echo "Using OpenVPN provider: ${OPENVPN_PROVIDER}"
|
echo "Using OpenVPN provider: ${OPENVPN_PROVIDER}"
|
||||||
|
|
||||||
if [[ ! -z "${OPENVPN_CONFIG}" ]]; then
|
if [[ -n "${OPENVPN_CONFIG-}" ]]; then
|
||||||
n=$(echo "$OPENVPN_CONFIG" | wc -w)
|
readarray -t OPENVPN_CONFIG_ARRAY <<< "${OPENVPN_CONFIG//,/$'\n'}"
|
||||||
if [ $n -gt 1 ]
|
if (( ${#OPENVPN_CONFIG_ARRAY[@]} > 1 )); then
|
||||||
then
|
OPENVPN_CONFIG_RANDOM=$((RANDOM%${#OPENVPN_CONFIG_ARRAY[@]}))
|
||||||
rnd=$((RANDOM%n+1))
|
echo "${#OPENVPN_CONFIG_ARRAY[@]} servers found in OPENVPN_CONFIG, ${OPENVPN_CONFIG_ARRAY[${OPENVPN_CONFIG_RANDOM}]} chosen randomly"
|
||||||
srv=$(echo "$OPENVPN_CONFIG" | awk -vrnd=$rnd '{print $rnd}')
|
OPENVPN_CONFIG="${OPENVPN_CONFIG_ARRAY[${OPENVPN_CONFIG_RANDOM}]}"
|
||||||
echo "$n servers found in OPENVPN_CONFIG, $srv chosen randomly"
|
|
||||||
OPENVPN_CONFIG=$srv
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "${VPN_PROVIDER_CONFIGS}/${OPENVPN_CONFIG}".ovpn ]]; then
|
if [[ -f "${VPN_PROVIDER_CONFIGS}/${OPENVPN_CONFIG}".ovpn ]]; then
|
||||||
|
Reference in New Issue
Block a user