Client: handle missing resolvconf when DNS is set

This commit is contained in:
Ruslan
2026-04-14 10:54:17 +03:00
parent 5542fbdaee
commit f5cc07fbbb

View File

@@ -164,6 +164,16 @@ collect_inputs() {
install_packages() { install_packages() {
apt_install_if_missing wireguard wireguard-tools iproute2 openssh-client sshpass ca-certificates apt_install_if_missing wireguard wireguard-tools iproute2 openssh-client sshpass ca-certificates
if ! command -v resolvconf >/dev/null 2>&1; then
if apt-cache show openresolv >/dev/null 2>&1; then
apt_install_if_missing openresolv
elif apt-cache show resolvconf >/dev/null 2>&1; then
apt_install_if_missing resolvconf
else
log_warn "Пакеты openresolv/resolvconf недоступны. DNS-строка в wg0.conf будет пропущена."
fi
fi
} }
reset_existing_client_install() { reset_existing_client_install() {
@@ -312,7 +322,11 @@ 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}"
echo "DNS = ${dns}" if command -v resolvconf >/dev/null 2>&1; then
echo "DNS = ${dns}"
else
log_warn "Команда resolvconf не найдена. Пропускаю строку DNS в конфиге WireGuard."
fi
if [[ -n "$PRE_UP" ]]; then if [[ -n "$PRE_UP" ]]; then
echo "$PRE_UP" echo "$PRE_UP"
fi fi