diff --git a/wireguard-install.sh b/wireguard-install.sh index 5a852a1..f7b5ab0 100644 --- a/wireguard-install.sh +++ b/wireguard-install.sh @@ -331,7 +331,10 @@ function newClient() { echo "" echo "The client name must consist of alphanumeric character(s). It may also include underscores or dashes and can't exceed 15 chars." - CLIENT_EXISTS=$(grep -c -E "^### Client ${CLIENT_NAME}\$" "/etc/wireguard/${SERVER_WG_NIC}.conf") + if [[ ${APPROVE_INSTALL} == "y" ]]; then + CLIENT_EXISTS="0" + fi + until [[ ${CLIENT_NAME} =~ ^[a-zA-Z0-9_-]+$ && ${CLIENT_EXISTS} == '0' && ${#CLIENT_NAME} -lt 16 ]]; do read -rp "Client name: " -e CLIENT_NAME CLIENT_EXISTS=$(grep -c -E "^### Client ${CLIENT_NAME}\$" "/etc/wireguard/${SERVER_WG_NIC}.conf")