SVN: geninitrd/trunk/mod-luks.sh

wiget wiget at pld-linux.org
Thu Sep 15 20:45:11 CEST 2011


Author: wiget
Date: Thu Sep 15 20:45:11 2011
New Revision: 12348

Modified:
   geninitrd/trunk/mod-luks.sh
Log:
Handle /dev/disk/by-uuid/* devices in /etc/crypttab

Modified: geninitrd/trunk/mod-luks.sh
==============================================================================
--- geninitrd/trunk/mod-luks.sh	(original)
+++ geninitrd/trunk/mod-luks.sh	Thu Sep 15 20:45:11 2011
@@ -119,7 +119,7 @@
 
 	while read dst src key opt; do
 		[ -z "$dst" -o "${dst#\#}" != "$dst" ] && continue
-		[ "$src" != "$LUKSDEV" ] && continue
+		[ "$src" != "$LUKSDEV" ] && [ "$(readlink -f $src)" != "$LUKSDEV" ] && continue
 
 		if [ -n "$key" -a "x$key" != "xnone" ]; then
 			if test -e "$key" ; then
@@ -155,11 +155,23 @@
 			# 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
+			luksdev='$src'
+			if [ \${luksdev##/dev/disk/by-uuid/} != \${luksdev} ]; then
+			        src_uuid=\${luksdev##/dev/disk/by-uuid/}
+			        while read x y z name; do
+			                found_uuid=\$(cryptsetup luksUUID /dev/\${name} 2>/dev/null)
+			                if [ "\$found_uuid" = "\$src_uuid" ]; then
+			                        luksdev=/dev/\$name
+			                        break
+			                fi
+			        done < /proc/partitions
+			fi
+
+			if [ -e "\$luksdev" ]; then
 				crypt_status=\$(cryptsetup status '$dst')
 				if [ "\${crypt_status%%is inactive.}" != "\$crypt_status" ]; then
 					# is inactive
-					cryptsetup ${keyfile:+-d $keyfile} luksOpen '$src' '$dst' <&1
+					cryptsetup ${keyfile:+-d $keyfile} luksOpen "\$luksdev" '$dst' <&1
 				fi
 			fi
 


More information about the pld-cvs-commit mailing list