diff --git a/autodecrypt.sh b/autodecrypt.sh index 223317e..48e1cc6 100755 --- a/autodecrypt.sh +++ b/autodecrypt.sh @@ -153,6 +153,7 @@ function test_clevis_unlock { } function check_initramfs_hooks { + local clevis_found=0 echo "Checking initramfs hooks..." if [ ! -f "/usr/share/initramfs-tools/hooks/clevis" ]; then @@ -161,7 +162,11 @@ function check_initramfs_hooks { fi # Check if clevis hook is in the generated initramfs - if ! lsinitramfs /boot/initrd.img-$(uname -r) 2>/dev/null | grep -q clevis; then + set +o pipefail + # if grep finds a match, lsinitramfs gets SIGPIPE but we still want a success + lsinitramfs /boot/initrd.img-$(uname -r) 2>/dev/null | grep -q clevis && clevis_found=1 + set -o pipefail + if [ "$clevis_found" = 0 ]; then echo "WARNING: Clevis not found in current initramfs. Will update initramfs." return 1 fi