From fc0cc6f159857e463aacababdc0735b0972d103c Mon Sep 17 00:00:00 2001 From: Sergio Correia Date: Wed, 13 May 2020 23:51:04 -0300 Subject: [PATCH 4/8] Add rd.neednet=1 to cmdline only if there are devices bound to tang --- .../dracut/clevis-pin-tang/module-setup.sh.in | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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 index 1bb2ead..a4984dc 100755 --- a/src/luks/systemd/dracut/clevis-pin-tang/module-setup.sh.in +++ b/src/luks/systemd/dracut/clevis-pin-tang/module-setup.sh.in @@ -18,8 +18,23 @@ # along with this program. If not, see . # +has_devices_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 clevis network + local deps="clevis" + if has_devices_bound_to_tang; then + deps=$(printf "%s network" "${deps}") + fi + echo "${deps}" return 0 } @@ -28,7 +43,9 @@ cmdline() { } install() { - cmdline > "${initdir}/etc/cmdline.d/99clevis-pin-tang.conf" + if has_devices_bound_to_tang; then + cmdline > "${initdir}/etc/cmdline.d/99clevis-pin-tang.conf" + fi inst_multiple \ clevis-decrypt-tang \ -- 2.18.4