Fix resolv.conf detection

- Apply upstream change Nyr/wireguard-install commit 98f45f8.
- Some systems have other DNS servers along with 127.0.0.53 in /etc/resolv.conf.
This commit is contained in:
hwdsl2 2022-08-21 22:46:55 -05:00
parent 0e00b824c1
commit 505958b307

View File

@ -117,13 +117,13 @@ new_client_dns () {
1|"")
# Locate the proper resolv.conf
# Needed for systems running systemd-resolved
if grep -q '^nameserver 127.0.0.53' "/etc/resolv.conf"; then
resolv_conf="/run/systemd/resolve/resolv.conf"
else
if grep '^nameserver' "/etc/resolv.conf" | grep -qv '127.0.0.53' ; then
resolv_conf="/etc/resolv.conf"
else
resolv_conf="/run/systemd/resolve/resolv.conf"
fi
# Extract nameservers and provide them in the required format
dns=$(grep -v '^#\|^;' "$resolv_conf" | grep '^nameserver' | grep -oE '[0-9]{1,3}(\.[0-9]{1,3}){3}' | xargs | sed -e 's/ /, /g')
dns=$(grep -v '^#\|^;' "$resolv_conf" | grep '^nameserver' | grep -v '127.0.0.53' | grep -oE '[0-9]{1,3}(\.[0-9]{1,3}){3}' | xargs | sed -e 's/ /, /g')
;;
2)
dns="8.8.8.8, 8.8.4.4"
@ -448,7 +448,7 @@ WantedBy=multi-user.target" >> /etc/systemd/system/wg-iptables.service
echo -e '\xE2\x86\x91 That is a QR code containing the client configuration.'
echo
# If the kernel module didn't load, system probably had an outdated kernel
# We'll try to help, but will not will not force a kernel upgrade upon the user
# We'll try to help, but will not force a kernel upgrade upon the user
if ! modprobe -nq wireguard; then
echo "Warning!"
echo "Installation was finished, but the WireGuard kernel module could not load."