fix: Approve CLIENT_NAME without checking config file

This commit is contained in:
Goetz Epperlein 2024-03-16 20:37:01 +01:00
parent a01b3cf4dc
commit f285af5743
1 changed files with 4 additions and 1 deletions

View File

@ -331,7 +331,10 @@ function newClient() {
echo "" echo ""
echo "The client name must consist of alphanumeric character(s). It may also include underscores or dashes and can't exceed 15 chars." 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 until [[ ${CLIENT_NAME} =~ ^[a-zA-Z0-9_-]+$ && ${CLIENT_EXISTS} == '0' && ${#CLIENT_NAME} -lt 16 ]]; do
read -rp "Client name: " -e CLIENT_NAME read -rp "Client name: " -e CLIENT_NAME
CLIENT_EXISTS=$(grep -c -E "^### Client ${CLIENT_NAME}\$" "/etc/wireguard/${SERVER_WG_NIC}.conf") CLIENT_EXISTS=$(grep -c -E "^### Client ${CLIENT_NAME}\$" "/etc/wireguard/${SERVER_WG_NIC}.conf")