Client: prevent log lines from being written into wg0.conf

This commit is contained in:
Ruslan
2026-04-14 11:22:17 +03:00
parent b54437a480
commit e2d3993fb3

View File

@@ -330,12 +330,19 @@ build_client_interface_address() {
write_client_config() { write_client_config() {
local conf="/etc/wireguard/${WG_INTERFACE}.conf" local conf="/etc/wireguard/${WG_INTERFACE}.conf"
local dns local dns
local include_dns=0
dns="$CLIENT_DNS" dns="$CLIENT_DNS"
if [[ -z "$dns" ]]; then if [[ -z "$dns" ]]; then
dns="${SERVER_DNS_REMOTE:-1.1.1.1}" dns="${SERVER_DNS_REMOTE:-1.1.1.1}"
fi fi
if command -v resolvconf >/dev/null 2>&1; then
include_dns=1
else
log_warn "Команда resolvconf не найдена. Пропускаю строку DNS в конфиге WireGuard."
fi
if [[ -f "$conf" ]]; then if [[ -f "$conf" ]]; then
backup_file "$conf" backup_file "$conf"
fi fi
@@ -344,10 +351,8 @@ write_client_config() {
echo "[Interface]" echo "[Interface]"
echo "PrivateKey = $(cat "$CLIENT_PRIV_KEY_PATH")" echo "PrivateKey = $(cat "$CLIENT_PRIV_KEY_PATH")"
echo "Address = ${CLIENT_INTERFACE_ADDRESS}" echo "Address = ${CLIENT_INTERFACE_ADDRESS}"
if command -v resolvconf >/dev/null 2>&1; then if ((include_dns)); then
echo "DNS = ${dns}" echo "DNS = ${dns}"
else
log_warn "Команда resolvconf не найдена. Пропускаю строку DNS в конфиге WireGuard."
fi fi
if [[ -n "$PRE_UP" ]]; then if [[ -n "$PRE_UP" ]]; then
echo "$PRE_UP" echo "$PRE_UP"