1
0
mirror of https://github.com/Nyr/openvpn-install.git synced 2024-11-23 21:46:08 +03:00

check if selected client to revoke does exist

This commit is contained in:
zocker-160 2018-02-19 20:04:05 +01:00
parent 33452242a1
commit f778282002

View File

@ -110,6 +110,18 @@ if [[ -e /etc/openvpn/server.conf ]]; then
else
read -p "Select one client [1-$NUMBEROFCLIENTS]: " CLIENTNUMBER
fi
#check if selected client does exist
if [[ !("$CLIENTNUMBER" =~ ^[0-9]+$) ]]; then
echo ""
echo "error: please enter a valid number!"
exit
fi
if [[ "$CLIENTNUMBER" < "1" || "$CLIENTNUMBER" > "$NUMBEROFCLIENTS" || ${#CLIENTNUMBER} != ${#NUMBEROFCLIENTS} ]]; then
echo ""
echo "error: could not find client number $CLIENTNUMBER."
exit
fi
echo "INPUT: $CLIENTNUMBER"
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/
./easyrsa --batch revoke $CLIENT
@ -422,4 +434,4 @@ verb 3" > /etc/openvpn/client-common.txt
echo ""
echo "Your client configuration is available at" ~/"$CLIENT.ovpn"
echo "If you want to add more clients, you simply need to run this script again!"
fi
fi