From 6a65d4a8e0afe2e4230e1043a926c21dedea1e92 Mon Sep 17 00:00:00 2001 From: Angristan Date: Sat, 18 Aug 2018 19:33:33 +0200 Subject: [PATCH] Add checks for user input --- openvpn-install.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index da3c74c..0773803 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -114,7 +114,9 @@ if [[ -e /etc/openvpn/server.conf ]]; then echo "(e.g. encrypt the private key with a password)" echo " 1) Add a passwordless client" echo " 2) Use a password for the client" - read -p "Select an option [1-2]: " pass + until [[ "$pass" =~ ^[1-2]$ ]]; do + read -rp "Select an option [1-2]: " -e -i 1 pass + done echo "" echo "Tell me a name for the client cert" echo "Please, use one word only, no special characters" @@ -334,7 +336,9 @@ else echo "(e.g. encrypt the private key with a password)" echo " 1) Add a passwordless client" echo " 2) Use a password for the client" - read -p "Select an option [1-2]: " pass + until [[ "$pass" =~ ^[1-2]$ ]]; do + read -rp "Select an option [1-2]: " -e -i 1 pass + done echo "" echo "Finally, tell me a name for the client certificate and configuration" while [[ $CLIENT = "" ]]; do