[PATCH] Use systemd-resolve to check if resolved is running

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 at gmail.com>
---
 vpnc-script | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/vpnc-script b/vpnc-script
index 6a55546..b00dbb9 100755
--- a/vpnc-script
+++ b/vpnc-script
@@ -116,8 +116,7 @@ else
 	ifconfig_syntax_ptpv6=""
 fi
 
-grep ^hosts /etc/nsswitch.conf|grep resolve >/dev/null 2>&1
-if [ $? = 0 ];then
+if grep -qs '^hosts.*resolve' /etc/nsswitch.conf && (command -v systemd-resolve && systemd-resolve --status) >/dev/null 2>&1; then
 	RESOLVEDENABLED=1
 else
 	RESOLVEDENABLED=0
-- 
Trygve Aaberge




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux