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

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