--- initrd.scripts.orig 2011-11-21 20:23:05.830355895 +0100 +++ initrd.scripts 2011-11-22 00:58:53.790815922 +0100 @@ -354,7 +354,7 @@ then eval $1 >/dev/null 2>/dev/null else - splash 'verbose' > /dev/null & eval $1 res=$? if [ ${res} -eq 0 ] @@ -815,6 +815,8 @@ done if [ ! -b "${LUKS_KEYDEV}" ] then + warn_msg "Removable device ${LUKS_KEYDEV} not found. Trying to autodetect correct device..." ${CRYPT_SILENT} + # auto handling of *inexistent* LUKS_KEYDEV eval CRYPT_${TYPE}_KEY=${LUKS_KEY} bootstrapKey ${TYPE} eval LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"' @@ -833,18 +835,38 @@ mount -n -o ro ${LUKS_KEYDEV} ${mntkey} >/dev/null 2>/dev/null if [ "$?" != '0' ] then - KEYDEV_ERROR=1 - bad_msg "Mounting of device ${LUKS_KEYDEV} failed." ${CRYPT_SILENT} + warn_msg "Mounting of device ${LUKS_KEYDEV} failed. Trying to autodetect correct device..." ${CRYPT_SILENT} + # auto handling of *wrong* / *not mountable* LUKS_KEYDEV + eval unset CRYPT_${TYPE}_KEYDEV + eval CRYPT_${TYPE}_KEY=${LUKS_KEY} + bootstrapKey ${TYPE} + eval LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"' + if [ ! -b "${LUKS_KEYDEV}" ]; then + KEYDEV_ERROR=1 + bad_msg "Removable device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT} + fi continue else good_msg "Removable device ${LUKS_KEYDEV} mounted." ${CRYPT_SILENT} - sleep 2 + + if [ ! -e "${mntkey}${LUKS_KEY}" ]; then + sleep 2 + fi + # keyfile exists? if [ ! -e "${mntkey}${LUKS_KEY}" ]; then umount -n ${mntkey} 2>/dev/null >/dev/null - KEY_ERROR=1 - KEYDEV_ERROR=1 - bad_msg "Key {LUKS_KEY} on device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT} + warn_msg "Key ${LUKS_KEY} on device ${LUKS_KEYDEV} not found. Trying to autodetect correct device..." ${CRYPT_SILENT} + # auto handling of *wrong* LUKS_KEYDEV without LUKS_KEY on it + eval unset CRYPT_${TYPE}_KEYDEV + eval CRYPT_${TYPE}_KEY=${LUKS_KEY} + bootstrapKey ${TYPE} + eval LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"' + if [ ! -b "${LUKS_KEYDEV}" ]; then + KEY_ERROR=1 + KEYDEV_ERROR=1 + bad_msg "Key ${LUKS_KEY} on device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT} + fi continue fi fi