dnsmasq.sh: Fix dns resolv workaround for hosts using resolvconf instead of systemd-resolved

Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com>
Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com>
This commit is contained in:
Tobias Knöppler 2024-04-28 18:43:19 +02:00 committed by Tobias K
parent 78039d38d1
commit f58852ea27
No known key found for this signature in database
GPG Key ID: 44FD368932E645C1

View File

@ -16,38 +16,30 @@ install()
apt-get install --no-install-recommends -y dnsmasq
rc=0
service dnsmasq status > /dev/null 2>&1 || rc=$?
! is_docker && [[ $rc -eq 3 ]] && ! [[ "$INIT_SYSTEM" =~ ^("chroot"|"unknown")$ ]] && {
[[ $rc -eq 3 ]] && ! [[ "$INIT_SYSTEM" =~ ^("chroot"|"unknown")$ ]] && command -v systemd-resolve > /dev/null || {
echo "Applying workaround for dnsmasq bug (compare issue #1446)"
service systemd-resolved stop || true
service dnsmasq start
service dnsmasq status
mkdir -p /etc/systemd/resolved.conf.d
if systemctl status systemd-resolved
then
cat <<EOF > /etc/systemd/resolved.conf.d/nostublistener.conf
[Resolve]
DNSStubListener=no
EOF
[[ "$INIT_SYSTEM" != "systemd" ]] || systemctl restart systemd-resolved
else
systemctl stop resolvconf
systemctl start dnsmasq
systemctl status dnsmasq
fi
# service systemd-resolved stop || true
systemctl start dnsmasq
systemctl status dnsmasq
}
service dnsmasq stop
[[ "$INIT_SYSTEM" == "systemd" ]] && service systemd-resolved start || true
[[ "$INIT_SYSTEM" != "systemd" ]] || systemctl start systemd-resolved || systemctl start resolvconf
update-rc.d dnsmasq disable || rm /etc/systemd/system/multi-user.target.wants/dnsmasq.service
[[ "$DOCKERBUILD" == 1 ]] && {
cat > /etc/services-available.d/100dnsmasq <<EOF
#!/bin/bash
source /usr/local/etc/library.sh
[[ "\$1" == "stop" ]] && {
echo "stopping dnsmasq..."
service dnsmasq stop
exit 0
}
persistent_cfg /etc/dnsmasq.conf
echo "Starting dnsmasq..."
service dnsmasq start
exit 0
EOF
chmod +x /etc/services-available.d/100dnsmasq
}
return 0
}