SVN: geninitrd/trunk/mod-luks.sh

arekm arekm at pld-linux.org
Thu Feb 17 22:37:19 CET 2011


Author: arekm
Date: Thu Feb 17 22:37:19 2011
New Revision: 12157

Modified:
   geninitrd/trunk/mod-luks.sh
Log:
Try to activate luks only if not yet active (because cryptsetup is run twice).

Modified: geninitrd/trunk/mod-luks.sh
==============================================================================
--- geninitrd/trunk/mod-luks.sh	(original)
+++ geninitrd/trunk/mod-luks.sh	Thu Feb 17 22:37:19 2011
@@ -151,8 +151,15 @@
 
 			debug "+ cryptsetup ${keyfile:+-d $keyfile} luksOpen '$src' '$dst'"
 			add_linuxrc <<-EOF
+			# cryptsetup can be called twice and in case on crypt on lvm only second
+			# will succeed because there will be no src device in first cryptsetup call
+			# this can be called multiple times, before lvm and after lvm.
 			if [ -e "$src" ]; then
-				cryptsetup ${keyfile:+-d $keyfile} luksOpen '$src' '$dst' <&1
+				crypt_status=\$(cryptsetup status '$dst')
+				if [ "\${crypt_status%%is inactive.}" != "\$crypt_status" ]; then
+					# is inactive
+					cryptsetup ${keyfile:+-d $keyfile} luksOpen '$src' '$dst' <&1
+				fi
 			fi
 
 			debugshell


More information about the pld-cvs-commit mailing list