Blame SOURCES/0004-Add-rd.neednet-1-to-cmdline-only-if-there-are-device.patch

95204d
From fc0cc6f159857e463aacababdc0735b0972d103c Mon Sep 17 00:00:00 2001
95204d
From: Sergio Correia <scorreia@redhat.com>
95204d
Date: Wed, 13 May 2020 23:51:04 -0300
95204d
Subject: [PATCH 4/8] Add rd.neednet=1 to cmdline only if there are devices
95204d
 bound to tang
95204d
95204d
---
95204d
 .../dracut/clevis-pin-tang/module-setup.sh.in | 21 +++++++++++++++++--
95204d
 1 file changed, 19 insertions(+), 2 deletions(-)
95204d
95204d
diff --git a/src/luks/systemd/dracut/clevis-pin-tang/module-setup.sh.in b/src/luks/systemd/dracut/clevis-pin-tang/module-setup.sh.in
95204d
index 1bb2ead..a4984dc 100755
95204d
--- a/src/luks/systemd/dracut/clevis-pin-tang/module-setup.sh.in
95204d
+++ b/src/luks/systemd/dracut/clevis-pin-tang/module-setup.sh.in
95204d
@@ -18,8 +18,23 @@
95204d
 # along with this program.  If not, see <http: www.gnu.org="" licenses=""/>.
95204d
 #
95204d
 
95204d
+has_devices_bound_to_tang() {
95204d
+    local dev
95204d
+    for dev in $(lsblk -p -n -s -r \
95204d
+                 | awk '$6 == "crypt" { getline; print $1 }' | sort -u); do
95204d
+       if clevis luks list -d "${dev}" 2>/dev/null | grep -q tang; then
95204d
+           return 0
95204d
+       fi
95204d
+    done
95204d
+    return 1
95204d
+}
95204d
+
95204d
 depends() {
95204d
-    echo clevis network
95204d
+    local deps="clevis"
95204d
+    if has_devices_bound_to_tang; then
95204d
+         deps=$(printf "%s network" "${deps}")
95204d
+    fi
95204d
+    echo "${deps}"
95204d
     return 0
95204d
 }
95204d
 
95204d
@@ -28,7 +43,9 @@ cmdline() {
95204d
 }
95204d
 
95204d
 install() {
95204d
-    cmdline > "${initdir}/etc/cmdline.d/99clevis-pin-tang.conf"
95204d
+    if has_devices_bound_to_tang; then
95204d
+        cmdline > "${initdir}/etc/cmdline.d/99clevis-pin-tang.conf"
95204d
+    fi
95204d
 
95204d
     inst_multiple \
95204d
 	clevis-decrypt-tang \
95204d
-- 
95204d
2.18.4
95204d