1
1
mirror of https://github.com/angristan/wireguard-install.git synced 2024-06-05 13:00:48 +00:00

Add check for existing clients

This commit is contained in:
randomshell 2020-07-02 15:51:20 +00:00
parent 52f922fc86
commit 94de617fe6

View File

@ -19,6 +19,14 @@ function addClient() {
read -rp "Client name: " -e CLIENT_NAME
done
CLIENT_EXISTS=$(grep -c -E "^### Client $CLIENT_NAME\$" "/etc/wireguard/$SERVER_WG_NIC.conf")
if [[ $CLIENT_EXISTS == '1' ]]; then
echo ""
echo "A client with the specified name was already created, please choose another name."
exit 1
fi
CLIENT_WG_IPV4="10.66.66.2"
read -rp "Client's WireGuard IPv4 " -e -i "$CLIENT_WG_IPV4" CLIENT_WG_IPV4