diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-05-26 13:19:11 +0200 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-05-26 15:04:56 +0200 |
commit | b22d90e59438481b421b1eb2449e6efdfb7f2118 (patch) | |
tree | d17998c5db42406d7e61f9ccaf2ff32ce57e08aa /test/TEST-24-CRYPTSETUP | |
parent | 1fb7f8e15e19fbe61230b70203b0c35fca54f0a0 (diff) | |
download | systemd-b22d90e59438481b421b1eb2449e6efdfb7f2118.tar.gz |
test: generate a custom initrd for TEST-24 if $INITRD is unset
Co-Authored-By: Yu Watanabe <watanabe.yu+github@gmail.com>
Diffstat (limited to 'test/TEST-24-CRYPTSETUP')
-rwxr-xr-x | test/TEST-24-CRYPTSETUP/test.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/TEST-24-CRYPTSETUP/test.sh b/test/TEST-24-CRYPTSETUP/test.sh index 83f4d65b1d..bdf630d912 100755 --- a/test/TEST-24-CRYPTSETUP/test.sh +++ b/test/TEST-24-CRYPTSETUP/test.sh @@ -66,6 +66,30 @@ EOF # Forward journal messages to the console, so we have something # to investigate even if we fail to mount the encrypted /var echo ForwardToConsole=yes >> "$initdir/etc/systemd/journald.conf" + + # If $INITRD wasn't provided explicitly, generate a custom one with dm-crypt + # support + if [[ -z "$INITRD" ]]; then + INITRD="${TESTDIR:?}/initrd.img" + dinfo "Generating a custom initrd with dm-crypt support in '${INITRD:?}'" + + if command -v dracut >/dev/null; then + dracut --force --verbose --add crypt "$INITRD" + elif command -v mkinitcpio >/dev/null; then + mkinitcpio --addhooks sd-encrypt --generate "$INITRD" + elif command -v mkinitramfs >/dev/null; then + # The cryptroot hook is provided by the cryptsetup-initramfs package + if ! dpkg-query -s cryptsetup-initramfs; then + derror "Missing 'cryptsetup-initramfs' package for dm-crypt support in initrd" + return 1 + fi + + mkinitramfs -o "$INITRD" + else + dfatal "Unrecognized initrd generator, can't continue" + return 1 + fi + fi } cleanup_root_var() { |