Lines 4-23
Link Here
|
4 |
|
4 |
|
5 |
[ -f /tmp/fstab ] || exit 0 |
5 |
[ -f /tmp/fstab ] || exit 0 |
6 |
|
6 |
|
7 |
for device in $(find /dev/ -name 'dm-*' -type b); |
7 |
for device in $(findmnt -neo SOURCE -F /tmp/fstab); |
8 |
do |
8 |
do |
9 |
uuid=$(blkid -o value -s UUID "$device") |
9 |
# filter out non-luks devices |
10 |
fgrep "$uuid" "/tmp/fstab" &> /dev/null || continue |
10 |
MAJMIN="$(findmnt $device -rno MAJ:MIN)" |
|
|
11 |
device_luks="/dev/"$(ls -1 "/sys/dev/block/$MAJMIN/slaves/") |
12 |
[ "$(blkid -o value -s TYPE "$device_luks")" = "crypto_LUKS" ] || continue |
13 |
|
11 |
# we should add luks feature to initrd if / is placed on luks |
14 |
# we should add luks feature to initrd if / is placed on luks |
12 |
# or create /etc/crypttab otherwise |
15 |
# or create /etc/crypttab otherwise |
13 |
if grep -qe ".*$uuid.*[^[:alnum:]]/[^[:alnum:]]" "/tmp/fstab"; then |
16 |
if [ "$(findmnt $device -no TARGET -F /tmp/fstab)" = "/" ]; then |
14 |
echo 'FEATURES += luks' >> $destdir/etc/initrd.mk |
17 |
echo 'FEATURES += luks' >> $destdir/etc/initrd.mk |
15 |
exit 0 |
|
|
16 |
fi |
18 |
fi |
17 |
|
19 |
|
18 |
device_luks="/dev/"$(ls "/sys/block/$(basename "$device")/slaves/") |
|
|
19 |
[ "$(blkid -o value -s TYPE "$device_luks")" = "crypto_LUKS" ] || continue |
20 |
|
21 |
luks_uuid=$(blkid -o value -s UUID "$device_luks") |
20 |
luks_uuid=$(blkid -o value -s UUID "$device_luks") |
22 |
|
21 |
|
23 |
[ -r "$destdir/etc/crypttab" ] && fgrep "$luks_uuid" "$destdir/etc/crypttab" &> /dev/null && continue |
22 |
[ -r "$destdir/etc/crypttab" ] && fgrep "$luks_uuid" "$destdir/etc/crypttab" &> /dev/null && continue |