]> www.infradead.org Git - users/dwmw2/vpnc-scripts.git/commitdiff
vpnc-script: Detect systemd with resolvectl status
authorJordan Justen <jljusten@gmail.com>
Mon, 25 Oct 2021 07:54:20 +0000 (00:54 -0700)
committerDaniel Lenski <dlenski@gmail.com>
Thu, 18 Nov 2021 05:51:01 +0000 (05:51 +0000)
It appears that the "resolvectl status" command has been available since:

Ref: https://github.com/systemd/systemd/commit/c2e84cab3afb09e726be40ce80b6ce6129c8af32
Ref: https://github.com/systemd/systemd/commit/a7a4c60a253a181385764bcb542906a312b68fe9

which was first released in systemd v239 from June 2018.

systemd-resolve is usually symlinked to resolvectl, but it appears to
be deprecated. This change will still fallback to trying
systemd-resolve if resolvectl fails.

Signed-off-by: Jordan Justen <jljusten@gmail.com>
vpnc-script

index 237062e734dc984cc6dd0b669c4c603e88e8f2c4..51ee969642628f2af943f350933c2e6fd09732ad 100755 (executable)
@@ -154,11 +154,13 @@ else
        ifconfig_syntax_ptpv6=""
 fi
 
-grep '^hosts' /etc/nsswitch.conf 2>/dev/null|grep resolve >/dev/null 2>&1 && command systemd-resolve --status >/dev/null 2>&1
+RESOLVEDENABLED=0
+grep '^hosts' /etc/nsswitch.conf 2>/dev/null|grep resolve >/dev/null 2>&1
 if [ $? = 0 ];then
-       RESOLVEDENABLED=1
-else
-       RESOLVEDENABLED=0
+       command resolvectl status >/dev/null 2>&1 || command systemd-resolve --status >/dev/null 2>&1
+       if [ $? = 0 ];then
+               RESOLVEDENABLED=1
+       fi
 fi
 
 if [ -r /etc/openwrt_release ] && [ -n "$OPENWRT_INTERFACE" ]; then