blob: 7842b3cbf20e9748ae0860c450ead9e8bfbbf240 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
. /lib/dracut-lib.sh
dev=$1
luks=$2
if [ -f /etc/crypttab ]; then
while read l rest; do
strstr "${l##luks-}" "${luks##luks-}" && exit 0
done < /etc/crypttab
fi
allowdiscards="-"
# parse for allow-discards
if strstr "$(cryptsetup --help)" "allow-discards"; then
if discarduuids=$(getargs "rd.luks.allow-discards"); then
discarduuids=$(str_replace "$discarduuids" 'luks-' '')
if strstr " $discarduuids " " ${luks##luks-}"; then
allowdiscards="allow-discards"
fi
elif getargbool 0 rd.luks.allow-discards; then
allowdiscards="allow-discards"
fi
fi
echo "$luks $dev - timeout=0,$allowdiscards" >> /etc/crypttab
if command -v systemctl >/dev/null; then
systemctl daemon-reload
systemctl start cryptsetup.target
fi
exit 0
|