mkinitrd unification across distributions
 help / color / mirror / Atom feed
From: Till Maas <opensource-44rtNO6TQJOzQB+pC5nmwQ@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Till Maas <opensource-44rtNO6TQJOzQB+pC5nmwQ@public.gmane.org>
Subject: [PATCH] Cryptroot-ask.sh: Use variables consistently
Date: Sun,  9 Feb 2014 09:08:42 +0100	[thread overview]
Message-ID: <1391933322-17308-1-git-send-email-opensource@till.name> (raw)

- Always use $luksname instead of sometimes $2
- define $asked_file instead of using the same path twice
---
 modules.d/90crypt/cryptroot-ask.sh | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules.d/90crypt/cryptroot-ask.sh b/modules.d/90crypt/cryptroot-ask.sh
index 9665e48..1ab03bc 100755
--- a/modules.d/90crypt/cryptroot-ask.sh
+++ b/modules.d/90crypt/cryptroot-ask.sh
@@ -8,19 +8,21 @@ NEWROOT=${NEWROOT:-"/sysroot"}
 # do not ask, if we already have root
 [ -f $NEWROOT/proc ] && exit 0
 
+# default luksname - luks-UUID
+luksname=$2
+
 # check if destination already exists
-[ -b /dev/mapper/$2 ] && exit 0
+[ -b /dev/mapper/luksname ] && exit 0
 
 # we already asked for this device
-[ -f /tmp/cryptroot-asked-$2 ] && exit 0
+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
 
-# default luksname - luks-UUID
-luksname=$2
 
 # fallback to passphrase
 ask_passphrase=1
@@ -45,7 +47,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
@@ -157,7 +159,7 @@ fi
 unset device luksname luksfile
 
 # mark device as asked
->> /tmp/cryptroot-asked-$2
+>> $asked_file
 
 need_shutdown
 udevsettle
-- 
1.8.3.1

             reply	other threads:[~2014-02-09  8:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-09  8:08 Till Maas [this message]
     [not found] ` <1391933322-17308-1-git-send-email-opensource-44rtNO6TQJOzQB+pC5nmwQ@public.gmane.org>
2014-02-09 13:13   ` [PATCH] Cryptroot-ask.sh: Use variables consistently Harald Hoyer
     [not found]     ` <52F77EFA.2070600-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-02-09 15:19       ` Till Maas
2014-02-09 19:37   ` Alexander Tsoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391933322-17308-1-git-send-email-opensource@till.name \
    --to=opensource-44rtno6tqjozqb+pc5nmwq@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox