X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=components%2F9990-misc-helpers.sh;h=42518986f3bad4ea6d060ecde22b2306831a3321;hb=773bef668749c32f1b01d6fa3e61a251602016f5;hp=2a3e6ad2b3f2a68458d098e163d8efc54cc63818;hpb=1ba79ed1eb5e2a52bdf226b0bbeaa3917f048778;p=live-boot-grml.git diff --git a/components/9990-misc-helpers.sh b/components/9990-misc-helpers.sh index 2a3e6ad..4251898 100755 --- a/components/9990-misc-helpers.sh +++ b/components/9990-misc-helpers.sh @@ -15,6 +15,42 @@ is_live_path() return 1 } +grml_match_bootid() +{ + path="$1" + + if [ -n "$IGNORE_BOOTID" ] ; then + echo " * Ignoring verification of bootid.txt as requested via ignore_bootid.">>/boot.log + return 0 + fi + + if [ -n "$BOOTID" ] && ! [ -r "${path}/conf/bootid.txt" ] ; then + echo " * Warning: bootid=... specified but no bootid.txt found on currently requested device.">>/boot.log + return 1 + fi + + [ -r "${path}/conf/bootid.txt" ] || return 0 + + bootid_conf=$(cat "${path}/conf/bootid.txt") + + if [ -z "$BOOTID" -a -z "$IGNORE_BOOTID" ] + then + echo " * Warning: bootid.txt found but ignore_bootid / bootid=.. bootoption missing...">>/boot.log + return 1 + fi + + if [ "$BOOTID" = "$bootid_conf" ] + then + echo " * Successfully verified /conf/bootid.txt from ISO, continuing... ">>/boot.log + else + echo " * Warning: BOOTID of ISO does not match. Retrying and continuing search...">>/boot.log + return 1 + fi + + return 0 +} + + matches_uuid () { if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ] @@ -76,7 +112,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 +197,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 +205,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 @@ -214,7 +250,7 @@ check_dev () fi if is_live_path ${mountpoint} && \ - ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint}) + ([ "${skip_uuid_check}" ] || grml_match_bootid ${mountpoint}) then echo ${mountpoint} return 0 @@ -310,19 +346,6 @@ find_livefs () return 0 fi done - elif [ "${fstype}" = "squashfs" -o \ - "${fstype}" = "btrfs" -o \ - "${fstype}" = "ext2" -o \ - "${fstype}" = "ext3" -o \ - "${fstype}" = "ext4" -o \ - "${fstype}" = "jffs2" ] - then - # This is an ugly hack situation, the block device has - # an image directly on it. It's hopefully - # live-boot, so take it and run with it. - ln -s "${devname}" "${devname}.${fstype}" - echo "${devname}.${fstype}" - return 0 fi done @@ -426,7 +449,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 @@ -803,9 +826,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 ${?} ] @@ -816,11 +860,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 @@ -1254,23 +1315,8 @@ do_union () rw_opt="rw" ro_opt="rr+wh" noxino_opt="noxino" - ;; - - unionfs-fuse) - rw_opt="RW" - ro_opt="RO" - ;; - - *) - rw_opt="rw" - ro_opt="ro" - ;; - esac - case "${UNIONTYPE}" in - unionfs-fuse) - unionmountopts="-o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid" - unionmountopts="${unionmountopts} ${unionrw}=${rw_opt}" + unionmountopts="-o noatime,${noxino_opt},dirs=${unionrw}=${rw_opt}" if [ -n "${unionro}" ] then for rofs in ${unionro} @@ -1278,38 +1324,29 @@ do_union () unionmountopts="${unionmountopts}:${rofs}=${ro_opt}" done fi - ( sysctl -w fs.file-max=391524 ; ulimit -HSn 16384 - unionfs-fuse ${unionmountopts} "${unionmountpoint}" ) && \ - ( mkdir -p /run/sendsigs.omit.d - pidof unionfs-fuse >> /run/sendsigs.omit.d/unionfs-fuse || true ) ;; - overlayfs) - # XXX: can multiple unionro be used? (overlayfs only handles two dirs, but perhaps they can be chained?) - # XXX: and can unionro be optional? i.e. can overlayfs skip lowerdir? + overlay) + # XXX: can multiple unionro be used? (overlay only handles two dirs, but perhaps they can be chained?) + # XXX: and can unionro be optional? i.e. can overlay skip lowerdir? if echo ${unionro} | grep -q " " then - panic "Multiple lower filesystems are currently not supported with overlayfs (unionro = ${unionro})." + panic "Multiple lower filesystems are currently not supported with overlay (unionro = ${unionro})." elif [ -z "${unionro}" ] then - panic "Overlayfs needs at least one lower filesystem (read-only branch)." - fi - unionmountopts="-o noatime,lowerdir=${unionro},upperdir=${unionrw}" - mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}" - ;; - - *) - unionmountopts="-o noatime,${noxino_opt},dirs=${unionrw}=${rw_opt}" - if [ -n "${unionro}" ] - then - for rofs in ${unionro} - do - unionmountopts="${unionmountopts}:${rofs}=${ro_opt}" - done + panic "overlay needs at least one lower filesystem (read-only branch)." fi - mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}" + # overlayfs requires: + # + a workdir to become mounted + # + workdir and upperdir to reside under the same mount + # + workdir and upperdir to be in separate directories + mkdir "${unionrw}/rw" + mkdir "${unionrw}/work" + unionmountopts="-o noatime,lowerdir=${unionro},upperdir=${unionrw}/rw,workdir=${unionrw}/work" ;; esac + + mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}" } get_custom_mounts () @@ -1377,7 +1414,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 @@ -1422,7 +1459,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}\(/.*\)\?$"