]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Cryptroot-ask.sh: Use variables consistently
authorTill Maas <opensource@till.name>
Sun, 9 Feb 2014 08:08:42 +0000 (09:08 +0100)
committerHarald Hoyer <harald@redhat.com>
Sun, 9 Feb 2014 13:12:44 +0000 (14:12 +0100)
- Always use $luksname instead of sometimes $2
- define $asked_file instead of using the same path twice

modules.d/90crypt/cryptroot-ask.sh

index 18b2d387d2beefd77f1762ef1c3c673246e5a4de..1c3e792b042c9e0ddf1087c4d4af315ad72909c9 100755 (executable)
@@ -10,6 +10,24 @@ NEWROOT=${NEWROOT:-"/sysroot"}
 
 . /lib/dracut-lib.sh
 
+# default luksname - luks-UUID
+luksname=$2
+
+# check if destination already exists
+[ -b /dev/mapper/luksname ] && exit 0
+
+# we already asked for this device
+asked_file=/tmp/cryptroot-asked-$luksname
+[ -f $asked_file ] && exit 0
+
+# load dm_crypt if it is not already loaded
+[ -d /sys/module/dm_crypt ] || modprobe dm_crypt
+
+. /lib/dracut-crypt-lib.sh
+
+# fallback to passphrase
+ask_passphrase=1
+
 # if device name is /dev/dm-X, convert to /dev/mapper/name
 if [ "${1##/dev/dm-}" != "$1" ]; then
     device="/dev/mapper/$(dmsetup info -c --noheadings -o name "$1")"
@@ -33,7 +51,7 @@ if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -d -n rd_NO_CRYPTTAB; t
 
         # UUID used in crypttab
         if [ "${dev%%=*}" = "UUID" ]; then
-            if [ "luks-${dev##UUID=}" = "$2" ]; then
+            if [ "luks-${dev##UUID=}" = "$luksname" ]; then
                 luksname="$name"
                 break
             fi
@@ -159,7 +177,7 @@ fi
 unset device luksname luksfile
 
 # mark device as asked
->> /tmp/cryptroot-asked-$luksname
+>> $asked_file
 
 need_shutdown
 udevsettle