diff options
-rwxr-xr-x | modules.d/90mgalive/mgalive-root.sh | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/modules.d/90mgalive/mgalive-root.sh b/modules.d/90mgalive/mgalive-root.sh index 9d3f86a..8991749 100755 --- a/modules.d/90mgalive/mgalive-root.sh +++ b/modules.d/90mgalive/mgalive-root.sh @@ -2,6 +2,12 @@ . /lib/dracut-lib.sh +can_decrypt=0 +if [ -f /lib/dracut-crypt-lib.sh ] ; then + . /lib/dracut-crypt-lib.sh + can_decrypt=1 +fi + [ -f /tmp/root.info ] && . /tmp/root.info PATH=/usr/sbin:/usr/bin:/sbin:/bin @@ -21,6 +27,19 @@ basedev=$(echo $livedev | sed -e 's,\(/dev/sd[a-z]\)1,\1,g' -e 's,\(/dev/mmcblk[ # Make it available to draklive-install and mgalive-shutdown echo $basedev > /run/mgalive/basedev +# Unlock any encrypted partitions on the base device +if [ $can_decrypt -eq 1 ] ; then + for dev in $(blkid -t TYPE=crypto_LUKS -o device | grep $basedev) ; do + ask_for_password \ + --ply-cmd "cryptsetup open -T1 $dev crypt_${dev##/dev/}" \ + --ply-prompt "Password ($dev)" \ + --ply-tries 3 \ + --tty-cmd "cryptsetup open -T3 $dev crypt_${dev##/dev/}" \ + --tty-tries 1 + done +fi + + # Get the base directory for locating the loopback file. In normal use this is # the root directory, but a multi-boot USB stick may want to override this. basedir=$(getarg mgalive.basedir) @@ -30,7 +49,7 @@ basedir=$(getarg mgalive.basedir) # stick may want to override this. overlay=$(getarg mgalive.overlay) if [ -z "$overlay" ] ; then - overlay=$(blkid -t LABEL=mgalive-persist -o device | grep $basedev) + overlay=$(blkid -t LABEL=mgalive-persist -o device | grep $basedev'\|'/dev/mapper) else overlay=$livedev$overlay fi @@ -41,7 +60,8 @@ info "mgalive basedir is $basedir/" info "mgalive overlay is $overlay" media=$livedev -if [ -z "$(blkid $livedev)" ] ; then +ps=$(partx -go START $livedev) +if [ $ps -ne 0 ] ; then if strstr "$(blkid $basedev)" "iso9660" ; then # This happens when we boot from a USB stick with a isohybrid partition # scheme where the first sector is unclaimed, so the first partition starts @@ -53,7 +73,6 @@ if [ -z "$(blkid $livedev)" ] ; then # If we mount the raw device, we can't then also mount a partition # on that device. So to enable persistence, we need to extend the # first partition to claim the full range of the iso9660 filesystem. - ps=$(partx -go START $livedev) pe=$(partx -go END $livedev) if [ $ps -eq 1 ] ; then info "Extending $livedev to cover sector 0" |