|
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 -no 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 |
18 |
exit 0 |
| 16 |
fi |
19 |
fi |
| 17 |
|
20 |
|
| 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") |
21 |
luks_uuid=$(blkid -o value -s UUID "$device_luks") |
| 22 |
|
22 |
|
| 23 |
[ -r "$destdir/etc/crypttab" ] && fgrep "$luks_uuid" "$destdir/etc/crypttab" &> /dev/null && continue |
23 |
[ -r "$destdir/etc/crypttab" ] && fgrep "$luks_uuid" "$destdir/etc/crypttab" &> /dev/null && continue |