Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit a6f812c

Browse files
authored
Merge pull request #25 from dngray/pr-expose_config_filename
Add VPN_CONFIG_FILE option
2 parents 9ef9c95 + cf48388 commit a6f812c

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ services:
7070
| --- | --- | --- |
7171
| `KILL_SWITCH` | `on` | The on/off status of the network kill switch. |
7272
| `SUBNETS` | | A list of one or more comma-separated subnets (e.g. `192.168.0.0/24,192.168.1.0/24`) to allow outside of the VPN tunnel. See important note about this [below](#subnets). |
73+
| `VPN_CONFIG_FILE` | | The OpenVPN config file to use. If this is unset, the first file with the extension .conf will be used. |
7374
| `VPN_LOG_LEVEL` | `3` | OpenVPN verbosity (`1`-`11`) |
7475
| `HTTP_PROXY` | `off` | The on/off status of Tinyproxy, the built-in HTTP proxy server. To enable, set to `on`. Any other value (including unset) will cause the proxy server to not start. It listens on port 8080. |
7576
| `SOCKS_PROXY` | `off` | The on/off status of Dante, the built-in SOCKS proxy server. To enable, set to `on`. Any other value (including unset) will cause the proxy server to not start. It listens on port 1080. |

data/scripts/entry.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ is_ip() {
2323
echo "$1" | grep -Eq "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"
2424
}
2525

26-
# Capture the filename of the first .conf file to use as the OpenVPN config.
27-
config_file_original=$(find /data/vpn -name "*.conf" 2> /dev/null | sort | head -1)
28-
if [ -z "$config_file_original" ]; then
29-
>&2 echo "ERROR: No configuration file found. Please check your mount and file permissions. Exiting."
30-
exit 1
31-
fi
32-
3326
# shellcheck disable=SC2153
3427
if ! (echo "$VPN_LOG_LEVEL" | grep -Eq '^([1-9]|1[0-1])$'); then
3528
echo "WARNING: Invalid log level $VPN_LOG_LEVEL. Setting to default."
@@ -46,9 +39,19 @@ SOCKS proxy: ${SOCKS_PROXY:-off}
4639
Proxy username secret: ${PROXY_PASSWORD_SECRET:-none}
4740
Proxy password secret: ${PROXY_USERNAME_SECRET:-none}
4841
Allowing subnets: ${SUBNETS:-none}
49-
Using configuration file: $config_file_original
50-
Using OpenVPN log level: $vpn_log_level
51-
"
42+
Using OpenVPN log level: $vpn_log_level"
43+
44+
if [ -n "$VPN_CONFIG_FILE" ]; then
45+
config_file_original="/data/vpn/$VPN_CONFIG_FILE"
46+
else
47+
# Capture the filename of the first .conf file to use as the OpenVPN config.
48+
config_file_original=$(find /data/vpn -name "*.conf" 2> /dev/null | sort | head -1)
49+
if [ -z "$config_file_original" ]; then
50+
>&2 echo "ERROR: No configuration file found. Please check your mount and file permissions. Exiting."
51+
exit 1
52+
fi
53+
fi
54+
echo "Using configuration file: $config_file_original"
5255

5356
# Create a new configuration file to modify so the original is left untouched.
5457
config_file_modified="${config_file_original}.modified"

0 commit comments

Comments
 (0)