|
Lines 4-21
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") |
|
|
| 10 |
fgrep "$uuid" "/tmp/fstab" &> /dev/null || continue |
| 11 |
# we should add luks feature to initrd if / is placed on luks |
9 |
# we should add luks feature to initrd if / is placed on luks |
| 12 |
# or create /etc/crypttab otherwise |
10 |
# or create /etc/crypttab otherwise |
| 13 |
if grep -qe ".*$uuid.*[^[:alnum:]]/[^[:alnum:]]" "/tmp/fstab"; then |
11 |
if [ "$(findmnt $device -no TARGET -F /tmp/fstab)" = "/" ]; then |
| 14 |
echo 'FEATURES += luks' >> $destdir/etc/initrd.mk |
12 |
echo 'FEATURES += luks' >> $destdir/etc/initrd.mk |
| 15 |
exit 0 |
13 |
exit 0 |
| 16 |
fi |
14 |
fi |
| 17 |
|
15 |
|
| 18 |
device_luks="/dev/"$(ls "/sys/block/$(basename "$device")/slaves/") |
16 |
MAJMIN="$(findmnt $device -no MAJ:MIN)" |
|
|
17 |
device_luks="/dev/"$(ls -1 "/sys/dev/block/$MAJMIN/slaves/") |
| 19 |
[ "$(blkid -o value -s TYPE "$device_luks")" = "crypto_LUKS" ] || continue |
18 |
[ "$(blkid -o value -s TYPE "$device_luks")" = "crypto_LUKS" ] || continue |
| 20 |
|
19 |
|
| 21 |
luks_uuid=$(blkid -o value -s UUID "$device_luks") |
20 |
luks_uuid=$(blkid -o value -s UUID "$device_luks") |