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

524513
From 25009adea66d3bf9b73f128273de28e532b03281 Mon Sep 17 00:00:00 2001
524513
From: Sergio Correia <scorreia@redhat.com>
524513
Date: Sat, 30 Nov 2019 18:23:09 -0500
524513
Subject: [PATCH] Add rd.neednet=1 to cmdline only if there are devices bound
524513
 to tang
524513
524513
---
524513
 src/luks/systemd/dracut/module-setup.sh.in | 24 ++++++++++++++++++----
524513
 1 file changed, 20 insertions(+), 4 deletions(-)
524513
524513
diff --git a/src/luks/systemd/dracut/module-setup.sh.in b/src/luks/systemd/dracut/module-setup.sh.in
524513
index 990bf4a..841f7a8 100755
524513
--- a/src/luks/systemd/dracut/module-setup.sh.in
524513
+++ b/src/luks/systemd/dracut/module-setup.sh.in
524513
@@ -18,19 +18,35 @@
524513
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
524513
 #
524513
 
524513
+is_bound_to_tang() {
524513
+    local dev
524513
+    for dev in $(lsblk -p -n -s -r \
524513
+                 | awk '$6 == "crypt" { getline; print $1 }' | sort -u); do
524513
+       if clevis luks list -d "${dev}" 2>/dev/null | grep -q tang; then
524513
+           return 0
524513
+       fi
524513
+    done
524513
+    return 1
524513
+}
524513
+
524513
 depends() {
524513
-    echo crypt systemd network
524513
-    return 0
524513
+    local depends="crypt systemd"
524513
+    if is_bound_to_tang; then
524513
+        depends=$(printf "%s network" "${depends}")
524513
+    fi
524513
+    echo "${depends}"
524513
 }
524513
 
524513
-cmdline() {
524513
+tang_cmdline() {
524513
     echo "rd.neednet=1"
524513
 }
524513
 
524513
 install() {
524513
     local ret=0
524513
 
524513
-    cmdline > "${initdir}/etc/cmdline.d/99clevis.conf"
524513
+    if is_bound_to_tang; then
524513
+        tang_cmdline > "${initdir}/etc/cmdline.d/99clevis.conf"
524513
+    fi
524513
 
524513
     inst_hook initqueue/online 60 "$moddir/clevis-hook.sh"
524513
     inst_hook initqueue/settled 60 "$moddir/clevis-hook.sh"
524513
-- 
524513
2.18.1
524513