resolved may be included in nsswitch.conf even though systemd-resolved
is not running. E.g. Arch Linux includes resolved in nsswitch.conf by
default, but systemd-resolved is not enabled by default, which causes
this script to fail updating dns.
This patch uses the systemd-resolve command, which is included with
systemd, to check if systemd-resolved is actually running.
Signed-off-by: Trygve Aaberge <trygveaa@gmail.com>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
ifconfig_syntax_ptpv6=""
fi
-grep ^hosts /etc/nsswitch.conf 2>/dev/null|grep resolve >/dev/null 2>&1
-if [ $? = 0 ];then
+if grep -qs '^hosts.*resolve' /etc/nsswitch.conf 2>/dev/null && (command -v systemd-resolve && systemd-resolve --status) >/dev/null 2>&1; then
RESOLVEDENABLED=1
else
RESOLVEDENABLED=0