From 10a072ca177ee6098f5f49b2a8761dc8bd01dc81 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sat, 30 Mar 2019 14:05:43 +0100 Subject: [PATCH] Add a config parameter: add capability to specify client config IP (client-config-dir) --- bin/ovpn_genconfig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/ovpn_genconfig b/bin/ovpn_genconfig index 7d46345..6a2be78 100755 --- a/bin/ovpn_genconfig +++ b/bin/ovpn_genconfig @@ -106,6 +106,7 @@ usage() { echo " -z Enable comp-lzo compression." echo " -S Change status folder. Default '/tmp'" echo " -R Disable the reduce the OpenVPN daemon's privileges after initialization." + echo " -K Set a client config directory. Default Disable. Example: 'ccd'" } process_route_config() { @@ -171,12 +172,13 @@ OVPN_SERVER_URL='' OVPN_TLS_CIPHER='' OVPN_STATUS_PATH='/tmp' OVPN_DISABLE_REDUCE_DEAMON_S_PRIVILEGES=0 +OVPN_CLIENT_CONFIG_DIR='' # Import existing configuration if present [ -r "$OVPN_ENV" ] && source "$OVPN_ENV" # Parse arguments -while getopts ":a:e:E:C:T:r:s:du:bcp:n:k:DNm:f:tz2S:R" opt; do +while getopts ":a:e:E:C:T:r:s:du:bcp:n:k:DNm:f:tz2S:RK:" opt; do case $opt in a) OVPN_AUTH="$OPTARG" @@ -263,6 +265,9 @@ while getopts ":a:e:E:C:T:r:s:du:bcp:n:k:DNm:f:tz2S:R" opt; do R) OVPN_DISABLE_REDUCE_DEAMON_S_PRIVILEGES=1 ;; + K) + OVPN_CLIENT_CONFIG_DIR="$OPTARG" + ;; \?) set +x echo "Invalid option: -$OPTARG" >&2 @@ -361,6 +366,12 @@ else process_push_config "block-outside-dns" fi +if [ "${OVPN_CLIENT_CONFIG_DIR}" == "" ]; then + echo "Disable client config 'client-config-dir'" +else + echo "client-config-dir ${OVPN_CLIENT_CONFIG_DIR}" >> "$conf" +fi + [ -n "$OVPN_TLS_CIPHER" ] && echo "tls-cipher $OVPN_TLS_CIPHER" >> "$conf" [ -n "$OVPN_CIPHER" ] && echo "cipher $OVPN_CIPHER" >> "$conf" [ -n "$OVPN_AUTH" ] && echo "auth $OVPN_AUTH" >> "$conf"