crypt: wait for all rd_LUKS_UUID disks to appear
[platform/upstream/dracut.git] / modules.d / 90crypt / parse-crypt.sh
1 #!/bin/sh
2 if getarg rd_NO_LUKS; then
3     info "rd_NO_LUKS: removing cryptoluks activation"
4     rm -f /etc/udev/rules.d/70-luks.rules
5 else
6     {
7         echo 'SUBSYSTEM!="block", GOTO="luks_end"'
8         echo 'ACTION!="add|change", GOTO="luks_end"'
9     } > /etc/udev/rules.d/70-luks.rules
10     LUKS=$(getargs rd_LUKS_UUID=)
11     if [ -n "$LUKS" ]; then
12         echo '. /lib/dracut-lib.sh' > /emergency/crypt.sh
13         for luksid in $LUKS; do 
14         printf 'ENV{ID_FS_TYPE}=="crypto_LUKS", ENV{ID_FS_UUID}=="*%s*", RUN+="/sbin/initqueue --unique --onetime --name cryptroot-ask-%%k /sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"\n' $luksid \
15             >> /etc/udev/rules.d/70-luks.rules  
16         printf '[ -e /dev/disk/by-uuid/*%s* ] || exit 1 \n'  $luksid >> /initqueue-finished/crypt.sh
17         printf '[ -e /dev/disk/by-uuid/*%s* ] || warn "crypto LUKS UUID "%s" not found" \n' $luksid $luksid >> /emergency/00-crypt.sh
18         done
19     else
20         echo 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue --unique --onetime --name cryptroot-ask-%k /sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"' \
21             >> /etc/udev/rules.d/70-luks.rules  
22     fi
23     echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules
24
25 fi
26