From 15bad014b46ae985bfec32fd2215fbcb1c8f4696 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 10 Jan 2024 06:04:59 +0300 Subject: [PATCH] ... Signed-off-by: Alex A. Naanou --- wireguard/templates/root/getFreeClientIP | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/wireguard/templates/root/getFreeClientIP b/wireguard/templates/root/getFreeClientIP index ca175dc..fef3ad0 100755 --- a/wireguard/templates/root/getFreeClientIP +++ b/wireguard/templates/root/getFreeClientIP @@ -1,19 +1,19 @@ -#!/usr/bin/bash - -CLIENT_IPS=${CLIENT_IPS} - -BASE_IP=${CLIENT_IPS/0\/*} -IPs=($(cat /etc/wireguard/clients/* \ - | grep Address \ - | cut -d'.' -f 4 \ - | cut -d '/' -f 1 \ - | sort)) -IPs=${IPs[@]} - -i=1 -while [ "$( echo $IPs | fgrep -w $i )" ] ; do - i=$(( i + 1 )) -done - -echo $BASE_IP.$i - +#!/usr/bin/bash + +CLIENT_IPS=${CLIENT_IPS} + +BASE_IP=${CLIENT_IPS/0\/*} +IPs=($(cat /etc/wireguard/clients/* \ + | grep Address \ + | cut -d'.' -f 4 \ + | cut -d '/' -f 1 \ + | sort)) +IPs=${IPs[@]} + +i=1 +while [ "$( echo $IPs | fgrep -w $i )" ] ; do + i=$(( i + 1 )) +done + +echo $BASE_IP.$i +