From 91b036b39825349c29cc8e9bfa06f39aae403862 Mon Sep 17 00:00:00 2001 From: Kristian Haugene Date: Wed, 28 Oct 2020 22:02:10 +0100 Subject: [PATCH] Use xargs to run modification script, plus some syntax updates #1334 --- openvpn/modify-openvpn-config.sh | 2 +- openvpn/pia/configure-openvpn.sh | 2 +- openvpn/start.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openvpn/modify-openvpn-config.sh b/openvpn/modify-openvpn-config.sh index e6332cbca..6ce938174 100755 --- a/openvpn/modify-openvpn-config.sh +++ b/openvpn/modify-openvpn-config.sh @@ -18,5 +18,5 @@ CONFIG_MOD_USERPASS=${CONFIG_MOD_USERPASS:-"1"} ## Option 1 - Change the auth-user-pass line to point to credentials file if [[ $CONFIG_MOD_USERPASS == "1" ]]; then [[ "${DEBUG}" == "true" ]] && echo "Point auth-user-pass option to the username/password file" - sed -i "s/auth-user-pass/auth-user-pass \/config\/openvpn-credentials.txt/" "$CONFIG" + sed -i "s#auth-user-pass#auth-user-pass /config/openvpn-credentials.txt#g" "$CONFIG" fi diff --git a/openvpn/pia/configure-openvpn.sh b/openvpn/pia/configure-openvpn.sh index f99b143dd..b829d125a 100755 --- a/openvpn/pia/configure-openvpn.sh +++ b/openvpn/pia/configure-openvpn.sh @@ -28,7 +28,7 @@ echo "Extract OpenVPN config bundle into PIA directory $VPN_PROVIDER_HOME" unzip -qjo "$tmp_file" -d "$VPN_PROVIDER_HOME" echo "Modify configs for this container" -find "$VPN_PROVIDER_HOME" -type f -name "*.ovpn" -exec /etc/openvpn/modify-openvpn-config.sh {} \; +find "$VPN_PROVIDER_HOME" -type f -name "*.ovpn" -print0 | xargs -n 1 -r0 /etc/openvpn/modify-openvpn-config.sh # Select a random server as default.ovpn ln -sf "$(find "$VPN_PROVIDER_HOME" -name "*.ovpn" | shuf -n 1)" "$VPN_PROVIDER_HOME"/default.ovpn diff --git a/openvpn/start.sh b/openvpn/start.sh index 40ded74e1..1263d8ebd 100755 --- a/openvpn/start.sh +++ b/openvpn/start.sh @@ -18,7 +18,7 @@ if compgen -e | grep -q "OVERRIDE_DNS"; then echo "One or more OVERRIDE_DNS addresses found. Will use them to overwrite /etc/resolv.conf" echo "" > /etc/resolv.conf for var in $(compgen -e | grep "OVERRIDE_DNS"); do - echo "nameserver $(printenv $var)" >> /etc/resolv.conf + echo "nameserver $(printenv "$var")" >> /etc/resolv.conf done fi @@ -53,7 +53,7 @@ if [[ -n $OPENVPN_CONFIG_URL ]]; then CHOSEN_OPENVPN_CONFIG=$VPN_PROVIDER_HOME/downloaded_config.ovpn curl -o "$CHOSEN_OPENVPN_CONFIG" -sSL "$OPENVPN_CONFIG_URL" # shellcheck source=openvpn/modify-openvpn-config.sh - /etc/openvpn/modify-openvpn-config.sh $CHOSEN_OPENVPN_CONFIG + /etc/openvpn/modify-openvpn-config.sh "$CHOSEN_OPENVPN_CONFIG" elif [[ -x $VPN_PROVIDER_HOME/configure-openvpn.sh ]]; then echo "Provider $OPENVPN_PROVIDER has a custom startup script, executing it" # shellcheck source=/dev/null