]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/90crypt/crypt-run-generator.sh
8dad76ba1e4c3e44a05558cbb93ff37161b1603d
[thirdparty/dracut.git] / modules.d / 90crypt / crypt-run-generator.sh
1 #!/bin/sh
2
3 . /lib/dracut-lib.sh
4 type crypttab_contains >/dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
5
6 dev=$1
7 luks=$2
8
9 crypttab_contains "$luks" "$dev" && exit 0
10
11 allowdiscards="-"
12
13 # parse for allow-discards
14 if strstr "$(cryptsetup --help)" "allow-discards"; then
15 if discarduuids=$(getargs "rd.luks.allow-discards"); then
16 discarduuids=$(str_replace "$discarduuids" 'luks-' '')
17 if strstr " $discarduuids " " ${luks##luks-}"; then
18 allowdiscards="discard"
19 fi
20 elif getargbool 0 rd.luks.allow-discards; then
21 allowdiscards="discard"
22 fi
23 fi
24
25 echo "$luks $dev - timeout=0,$allowdiscards" >> /etc/crypttab
26
27 if command -v systemctl >/dev/null; then
28 systemctl daemon-reload
29 systemctl start cryptsetup.target
30 fi
31 exit 0