diff --git a/openvpn-install.sh b/openvpn-install.sh index ee420ca..fda60fa 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -75,7 +75,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then echo "" echo "What do you want to do?" echo " 1) Add a new user" - echo " 2) Revoke an existing user" + echo " 2) Show and revoke existing users" echo " 3) Remove OpenVPN" echo " 4) Exit" read -p "Select an option [1-4]: " option @@ -106,9 +106,12 @@ if [[ -e /etc/openvpn/server.conf ]]; then 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 -p "Select one client [1]: " CLIENTNUMBER + read -p "Select one client [1] or 'x' to exit: " CLIENTNUMBER else - read -p "Select one client [1-$NUMBEROFCLIENTS]: " CLIENTNUMBER + read -p "Select one client [1-$NUMBEROFCLIENTS] or 'x' to exit: " CLIENTNUMBER + fi + if [[ "$CLIENTNUMBER" = 'x' ]]; then + exit fi 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/ @@ -422,4 +425,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 \ No newline at end of file +fi