From 106a2ce3c9e19b49b6997dd71b4fa5b8cba0c65b Mon Sep 17 00:00:00 2001 From: randomshell Date: Fri, 26 Jun 2020 20:11:19 +0000 Subject: [PATCH] Update regex check for existing clients and make it idempotent again See https://github.com/angristan/openvpn-install/issues/652#issuecomment-650372450 --- openvpn-install.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 4a9e347..3355dc7 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -1068,11 +1068,10 @@ function newClient() { read -rp "Select an option [1-2]: " -e -i 1 PASS done - CLIENTEXISTS=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep -c -E "/CN=$CLIENT\$") + CLIENTEXISTS=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep -c -E "^V.*/CN=$CLIENT\$") if [[ $CLIENTEXISTS == '1' ]]; then echo "" - echo "The specified client CN was already found in easy-rsa, please choose another name." - exit + echo "The specified client CN was already found in easy-rsa." else cd /etc/openvpn/easy-rsa/ || return case $PASS in