From a3041161e47e784a1b94618a617c5247019940db Mon Sep 17 00:00:00 2001 From: Podesta <11512008+Podesta@users.noreply.github.com> Date: Mon, 4 Jul 2022 10:50:18 +0000 Subject: [PATCH] feat: add flag for creation of new client after install --- openvpn-install.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 64d8ed0..1fa6462 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -602,8 +602,12 @@ function installQuestions() { done fi echo "" + # Ask the user if they would like to add a new client after installation. + until [[ $NEW_CLIENT =~ (y|n) ]]; do + read -rp "Would you like to add a new client after installation? [y/n]: " -e -i y NEW_CLIENT + done + echo "" echo "Okay, that was all I needed. We are ready to setup your OpenVPN server now." - echo "You will be able to generate a client at the end of the installation." APPROVE_INSTALL=${APPROVE_INSTALL:-n} if [[ $APPROVE_INSTALL =~ n ]]; then read -n1 -r -p "Press any key to continue..." @@ -624,6 +628,7 @@ function installOpenVPN() { CLIENT=${CLIENT:-client} PASS=${PASS:-1} CONTINUE=${CONTINUE:-y} + NEW_CLIENT=${NEW_CLIENT:-y} # Behind NAT, we'll default to the publicly reachable IPv4/IPv6. if [[ $IPV6_SUPPORT == "y" ]]; then @@ -1051,8 +1056,12 @@ verb 3" >>/etc/openvpn/client-template.txt fi # Generate the custom client.ovpn - newClient - echo "If you want to add more clients, you simply need to run this script another time!" + if [[ $NEW_CLIENT == "n" ]]; then + echo "No clients added. To add clients, simply run the script again." + else + newClient + echo "If you want to add more clients, you simply need to run this script another time!" + fi } function newClient() {