From 6b23cf8d88bf218171bfd1bb2b64f5d9fa207843 Mon Sep 17 00:00:00 2001 From: omriiluz Date: Sat, 28 Feb 2015 03:01:00 -0800 Subject: [PATCH] do not accumulate routes and push directives from default if new directives were defined --- bin/ovpn_genconfig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/ovpn_genconfig b/bin/ovpn_genconfig index 42be8a6..faea108 100755 --- a/bin/ovpn_genconfig +++ b/bin/ovpn_genconfig @@ -58,7 +58,9 @@ OVPN_DEFROUTE=1 OVPN_NAT=0 OVPN_DNS=1 OVPN_ROUTES=() +TMP_ROUTES=() OVPN_PUSH=() +TMP_PUSH=() # Import defaults if present [ -r "$OVPN_ENV" ] && source "$OVPN_ENV" @@ -67,7 +69,7 @@ OVPN_PUSH=() while getopts ":r:s:du:cp:DNm:" opt; do case $opt in r) - OVPN_ROUTES+=("$OPTARG") + TMP_ROUTES+=("$OPTARG") ;; s) OVPN_SERVER=$OPTARG @@ -82,7 +84,7 @@ while getopts ":r:s:du:cp:DNm:" opt; do OVPN_CLIENT_TO_CLIENT=1 ;; p) - OVPN_PUSH+=("$OPTARG") + TMP_PUSH+=("$OPTARG") ;; D) OVPN_DNS=0 @@ -108,6 +110,11 @@ while getopts ":r:s:du:cp:DNm:" opt; do esac done +# if new routes were not defined with -r, use default +[ ${#TMP_ROUTES[@]} -gt 0 ] && OVPN_ROUTES=${TMP_ROUTES[@]} + +# if new push directives were not defined with -p, use default +[ ${#TMP_PUSH[@]} -gt 0 ] && OVPN_PUSH=${TMP_PUSH[@]} # Server name is in the form "udp://vpn.example.com:1194" if [[ "$OVPN_SERVER_URL" =~ ^((udp|tcp)://)?([0-9a-zA-Z\.\-]+)(:([0-9]+))?$ ]]; then