From f411d9dec7a0879dd2166573375287130c096166 Mon Sep 17 00:00:00 2001 From: Stanislas Lange Date: Mon, 27 Apr 2020 17:35:30 +0200 Subject: [PATCH] fix(revokeClient): fix prompt input check fix #477 #590 --- openvpn-install.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 8eaae90..2f9972f 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -1138,12 +1138,13 @@ function revokeClient() { echo "" echo "Select the existing client certificate you want to revoke" tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep "^V" | cut -d '=' -f 2 | nl -s ') ' - if [[ $NUMBEROFCLIENTS == '1' ]]; then - read -rp "Select one client [1]: " CLIENTNUMBER - else - read -rp "Select one client [1-$NUMBEROFCLIENTS]: " CLIENTNUMBER - fi - + until [[ $CLIENTNUMBER -ge 1 && $CLIENTNUMBER -le $NUMBEROFCLIENTS ]]; do + if [[ $CLIENTNUMBER == '1' ]]; then + read -rp "Select one client [1]: " CLIENTNUMBER + else + read -rp "Select one client [1-$NUMBEROFCLIENTS]: " CLIENTNUMBER + fi + done CLIENT=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep "^V" | cut -d '=' -f 2 | sed -n "$CLIENTNUMBER"p) cd /etc/openvpn/easy-rsa/ || return ./easyrsa --batch revoke "$CLIENT"