From 8516203d53380bc32f62827afd0c13d16337c4e6 Mon Sep 17 00:00:00 2001
From: Moritz Maxeiner <moritz@ucworks.org>
Date: Thu, 1 Sep 2016 18:29:31 +0200
Subject: [PATCH 220/530] zfs dracut module should not assume systemd presence

Signed-off-by: Moritz Maxeiner <moritz@ucworks.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4749
Closes #5058
---
 contrib/dracut/90zfs/mount-zfs.sh.in | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/contrib/dracut/90zfs/mount-zfs.sh.in b/contrib/dracut/90zfs/mount-zfs.sh.in
index 43862fa..51e107b 100755
--- a/contrib/dracut/90zfs/mount-zfs.sh.in
+++ b/contrib/dracut/90zfs/mount-zfs.sh.in
@@ -10,14 +10,16 @@ case "${root}" in
 	*) return ;;
 esac
 
-# If sysroot.mount exists, the initial RAM disk configured
-# it to mount ZFS on root.  In that case, we bail early.
-loadstate="$(systemctl --system --show -p LoadState sysroot.mount || true)"
-if [ "${loadstate}" = "LoadState=not-found" -o "${loadstate}" = "" ] ; then
-	info "ZFS: sysroot.mount absent, mounting root with mount-zfs.sh"
-else
-	info "ZFS: sysroot.mount present, delegating root mount to it"
-	return
+if command -v systemctl >/dev/null; then
+	# If sysroot.mount exists, the initial RAM disk configured
+	# it to mount ZFS on root.  In that case, we bail early.
+	loadstate="$(systemctl --system --show -p LoadState sysroot.mount || true)"
+	if [ "${loadstate}" = "LoadState=not-found" -o "${loadstate}" = "" ] ; then
+		info "ZFS: sysroot.mount absent, mounting root with mount-zfs.sh"
+	else
+		info "ZFS: sysroot.mount present, delegating root mount to it"
+		return
+	fi
 fi
 
 # Delay until all required block devices are present.
-- 
2.1.4

