fix: stabilize installer flows, managers, and terminal output

This commit is contained in:
houseassassin
2026-05-17 14:46:56 +03:00
parent 6dc1afcb2a
commit 1c183496ca
9 changed files with 605 additions and 148 deletions
+14 -2
View File
@@ -23,8 +23,12 @@ get_next_wg_ip() {
if [ -z "$LAST_IP" ]; then
echo "10.0.0.2"
else
LAST_NUM=$(echo $LAST_IP | cut -d. -f4)
LAST_NUM=$(echo "$LAST_IP" | cut -d. -f4)
NEXT_NUM=$((LAST_NUM + 1))
if [ "$NEXT_NUM" -gt 254 ]; then
error "Пул адресов WireGuard исчерпан (10.0.0.2-10.0.0.254)"
return 1
fi
echo "10.0.0.$NEXT_NUM"
fi
}
@@ -147,7 +151,15 @@ remove_wireguard_client() {
return 0
fi
sed -i "/# $client_name/,+2d" $WG_CONF
local tmp_conf
tmp_conf="$(mktemp)"
awk -v marker="# ${client_name}" '
BEGIN {skip=0}
$0 == marker {skip=1; next}
skip && /^\[Peer\]/ {skip=0}
!skip {print}
' "$WG_CONF" > "$tmp_conf"
mv "$tmp_conf" "$WG_CONF"
rm -rf "$CLIENT_DIR"
systemctl restart wg-quick@wg0