From 249ded3db629f03685db6170f59b99a3dc387c85 Mon Sep 17 00:00:00 2001
From: even <even03060@163.com>
Date: Thu, 17 Feb 2022 21:47:15 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A6=81=E7=94=A8=E7=94=A8?=
 =?UTF-8?q?=E6=88=B7=E5=90=8E=E9=87=8D=E6=96=B0=E6=B7=BB=E5=8A=A0=E5=90=8C?=
 =?UTF-8?q?=E5=90=8D=E7=94=A8=E6=88=B7=E6=8F=90=E7=A4=BA=E7=94=A8=E6=88=B7?=
 =?UTF-8?q?=E5=B7=B2=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 openvpn-install.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/openvpn-install.sh b/openvpn-install.sh
index eb20f4a..a6abc69 100755
--- a/openvpn-install.sh
+++ b/openvpn-install.sh
@@ -1074,7 +1074,7 @@ 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 -E "^V" | grep -c -E "/CN=$CLIENT\$")
 	if [[ $CLIENTEXISTS == '1' ]]; then
 		echo ""
 		echo "The specified client CN was already found in easy-rsa, please choose another name."
@@ -1183,7 +1183,6 @@ function revokeClient() {
 	rm -f "/root/$CLIENT.ovpn"
 	sed -i "/^$CLIENT,.*/d" /etc/openvpn/ipp.txt
 	cp /etc/openvpn/easy-rsa/pki/index.txt{,.bk}
-	sed -i "/CN=$CLIENT/d" /etc/openvpn/easy-rsa/pki/index.txt
 
 	echo ""
 	echo "Certificate for client $CLIENT revoked."