X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=components%2F9990-misc-helpers.sh;h=fb139ecb6b01acf1548f256b6024dd0e02694b42;hb=6b123988267c263a2b12a43c9e9d2c9ff60104ba;hp=2515ea1ea15988131e3aaa0f1e696966944be8a8;hpb=e5904f5079fd4362c4dd63027075fce4b47c51c5;p=live-boot-grml.git diff --git a/components/9990-misc-helpers.sh b/components/9990-misc-helpers.sh index 2515ea1..fb139ec 100755 --- a/components/9990-misc-helpers.sh +++ b/components/9990-misc-helpers.sh @@ -76,7 +76,7 @@ is_nice_device () { sysfs_path="${1#/sys}" - if udevadm test-builtin path_id "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-[^-]*-(ide|sas|scsi|usb|virtio)|platform-sata_mv|platform-orion-ehci|platform-mmc|platform-mxsdhci)" + if udevadm info --query=all --path="${sysfs_path}" | egrep -q "DEVTYPE=disk" then return 0 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$' @@ -161,7 +161,7 @@ check_dev () # Adding lvm support if [ -x /scripts/local-top/lvm2 ] then - ROOT="$device" resume="" /scripts/local-top/lvm2 + ROOT="$device" resume="" /scripts/local-top/lvm2 >>/boot.log fi ;; @@ -169,10 +169,10 @@ check_dev () # Adding raid support if [ -x /scripts/local-top/mdadm ] then - cp /conf/conf.d/md /conf/conf.d/md.orig + [ -r /conf/conf.d/md ] && cp /conf/conf.d/md /conf/conf.d/md.orig echo "MD_DEVS=$device " >> /conf/conf.d/md - /scripts/local-top/mdadm - mv /conf/conf.d/md.orig /conf/conf.d/md + /scripts/local-top/mdadm >>/boot.log + [ -r /conf/conf.d/md.orig ] && mv /conf/conf.d/md.orig /conf/conf.d/md fi ;; esac @@ -426,7 +426,7 @@ is_supported_fs () return 0 else # Then try to add support for it the gentle way using the initramfs capabilities - modprobe ${fstype} + modprobe -q -b ${fstype} if grep -q ${fstype} /proc/filesystems then return 0 @@ -684,8 +684,9 @@ try_mount () } # Try to mount $device to the place expected by live-boot. If $device -# is already mounted somewhere, move it to the expected place. If -# we're only probing $device (to check if it has custom persistence) +# is already mounted somewhere, move it to the expected place. If $device +# ends with a "/" this is a directory path. +# If we're only probing $device (to check if it has custom persistence) # $probe should be set, which suppresses warnings upon failure. On # success, print the mount point for $device. mount_persistence_media () @@ -694,6 +695,15 @@ mount_persistence_media () device=${1} probe=${2} + # get_custom_mounts() might call this with a directory path instead + # of a block device path. This means we have found sub-directory path + # underneath /lib/live/mounts/persistence, so we're done + if [ -d "${device}" ] + then + echo "${device}" + return 0 + fi + if [ ! -b "${device}" ] then return 1 @@ -793,9 +803,30 @@ open_luks_device () load_keymap + # check for plymouth + if [ -x /bin/plymouth ] + then + _PLYMOUTH="true" + fi + + case "${_PLYMOUTH}" in + true) + plymouth --ping + + cryptkeyscript="plymouth ask-for-password --prompt" + # Plymouth will add a : if it is a non-graphical prompt + cryptkeyprompt="Please unlock disk ${dev}" + ;; + + *) + cryptkeyscript="/lib/cryptsetup/askpass" + cryptkeyprompt="Please unlock disk ${dev}: " + ;; + esac + while true do - /lib/cryptsetup/askpass "Enter passphrase for ${dev}: " | \ + $cryptkeyscript "$cryptkeyprompt" | \ /sbin/cryptsetup -T 1 luksOpen ${dev} ${name} ${opts} if [ 0 -eq ${?} ] @@ -806,11 +837,28 @@ open_luks_device () fi echo >&6 - echo -n "There was an error decrypting ${dev} ... Retry? [Y/n] " >&6 - read answer + retryprompt="There was an error decrypting ${dev} ... Retry? [Y/n]" + + case "${_PLYMOUTH}" in + true) + plymouth display-message --text "${retryprompt}" + answer=$(plymouth watch-keystroke --keys="YNyn") + ;; + + *) + echo -n "${retryprompt} " >&6 + read answer + ;; + esac if [ "$(echo "${answer}" | cut -b1 | tr A-Z a-z)" = "n" ] then + case "${_PLYMOUTH}" in + true) + plymouth display-message --text "" + ;; + esac + return 2 fi done @@ -908,6 +956,39 @@ probe_for_file_name () fi } +probe_for_directory_name () +{ + local overlays dev ret backing + overlays="${1}" + dev="${2}" + + ret="" + backing="$(mount_persistence_media ${dev} probe)" + if [ -z "${backing}" ] + then + return + fi + + for label in ${overlays} + do + path=${backing}/${PERSISTENCE_PATH}/${label} + if [ -d "${path}" ] + then + # in this case the "device" ends with a "/" + ret="${ret} ${label}=${backing}/${PERSISTENCE_PATH}/${label%%/}/" + fi + done + + if [ -n "${ret}" ] + then + echo ${ret} + else + # unmount and remove mountpoint + umount ${backing} > /dev/null 2>&1 || true + rmdir ${backing} > /dev/null 2>&1 || true + fi +} + find_persistence_media () { # Scans devices for overlays, and returns a whitespace @@ -1013,6 +1094,17 @@ find_persistence_media () fi fi + # Probe for directory with matching name on mounted partition + if is_in_comma_sep_list directory ${PERSISTENCE_STORAGE} + then + result=$(probe_for_directory_name "${overlays}" ${dev}) + if [ -n "${result}" ] + then + ret="${ret} ${result}" + continue + fi + fi + # Close luks device if it isn't used if [ -z "${result}" ] && [ -n "${luks_device}" ] && is_active_luks_mapping "${luks_device}" then @@ -1323,7 +1415,7 @@ get_custom_mounts () union|bind) ;; *) - log_warning_msg "Skipping custom mount with unkown option: ${opt}" + log_warning_msg "Skipping custom mount with unknown option: ${opt}" continue 2 ;; esac @@ -1368,7 +1460,7 @@ get_custom_mounts () prev_dest="" # This sort will ensure that a source /a comes right before a source # /a/b so we only need to look at the previous source - sort -k2 -b ${custom_mounts} | + [ -e ${custom_mounts} ] && sort -k2 -b ${custom_mounts} | while read device source dest options do if echo ${source} | grep -qe "^${prev_source}\(/.*\)\?$"