From d20f82e6f296de757d6e442d08893ccd1dabcc52 Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Fri, 11 Feb 2022 21:50:00 -0600 Subject: [PATCH] Update IKEv2 script - Minor improvement to IKEv2 config password retrieval --- extras/ikev2setup.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/extras/ikev2setup.sh b/extras/ikev2setup.sh index 34e4264..31d8ce4 100755 --- a/extras/ikev2setup.sh +++ b/extras/ikev2setup.sh @@ -651,10 +651,8 @@ create_client_cert() { create_p12_password() { config_file="/etc/ipsec.d/.vpnconfig" - if grep -qs '^IKEV2_CONFIG_PASSWORD=.\+' "$config_file"; then - . "$config_file" - p12_password="$IKEV2_CONFIG_PASSWORD" - else + p12_password=$(grep -s '^IKEV2_CONFIG_PASSWORD=.\+' "$config_file" | tail -n 1 | cut -f2- -d= | sed -e "s/^'//" -e "s/'$//") + if [ -z "$p12_password" ]; then p12_password=$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' /dev/null | head -c 18) [ -z "$p12_password" ] && exiterr "Could not generate a random password for .p12 file." mkdir -p /etc/ipsec.d