crypt/crypt-run-generator.sh: fixup last commit 065fc56ab27d8ea1aace72de54a6884bb558ea97
authorHarald Hoyer <harald@redhat.com>
Wed, 21 Nov 2012 15:30:58 +0000 (16:30 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 21 Nov 2012 15:36:37 +0000 (16:36 +0100)
modules.d/90crypt/crypt-run-generator.sh
modules.d/90crypt/cryptroot-ask.sh

index 29fb22d..8d16f7c 100755 (executable)
@@ -1,4 +1,6 @@
 #!/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
 
@@ -11,18 +13,21 @@ if [ -f /etc/crypttab ]; then
     done < /etc/crypttab
 fi
 
+allowdiscards="-"
+
 # parse for allow-discards
 if strstr "$(cryptsetup --help)" "allow-discards"; then
     if discarduuids=$(getargs "rd.luks.allow-discards"); then
-        if strstr " ${luksdev##luks-} " " ${discarduuids##luks-}"; then
-           allowdiscards="allow-discards"
-       fi
-    elif getargbool rd.luks.allow-discards; then
-       allowdiscards="allow-discards"
+        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 none $allowdiscards" >> /etc/crypttab
+echo "$luks $dev - $allowdiscards" >> /etc/crypttab
 
 if command -v systemctl >/dev/null; then
     systemctl daemon-reload
index 87522d9..9665e48 100755 (executable)
@@ -97,10 +97,11 @@ done
 # parse for allow-discards
 if strstr "$(cryptsetup --help)" "allow-discards"; then
     if discarduuids=$(getargs "rd.luks.allow-discards"); then
-        if strstr " ${luksdev##luks-} " " ${discarduuids##luks-}"; then
+        discarduuids=$(str_replace "$discarduuids" 'luks-' '')
+        if strstr " $discarduuids " " ${luksdev##luks-}"; then
             allowdiscards="--allow-discards"
         fi
-    elif getargbool rd.luks.allow-discards; then
+    elif getargbool rd.luks.allow-discards; then
         allowdiscards="--allow-discards"
     fi
 fi