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