From 2648cbc4fbb19cc4b20bca4b4f3d38d515f130a1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 6 May 2013 13:46:18 +0200 Subject: Adding debian version 4.0~a1-1. --- scripts/boot/3010-verify-checksums | 33 ++--- scripts/boot/3020-swapon | 17 +-- scripts/boot/9990-aaa-fixme.sh | 2 - scripts/boot/9990-fstab.sh | 17 +-- scripts/boot/9990-main.sh | 29 ++-- scripts/boot/9990-misc-helpers.sh | 293 ++++++++++++++----------------------- scripts/boot/9990-mount-http.sh | 7 +- scripts/boot/9990-mount-iscsi.sh | 13 +- scripts/boot/9990-netbase.sh | 15 ++ scripts/boot/9990-networking.sh | 8 - scripts/boot/9990-overlay.sh | 102 +++++++------ 11 files changed, 218 insertions(+), 318 deletions(-) (limited to 'scripts/boot') diff --git a/scripts/boot/3010-verify-checksums b/scripts/boot/3010-verify-checksums index 08b2972..8ccd663 100755 --- a/scripts/boot/3010-verify-checksums +++ b/scripts/boot/3010-verify-checksums @@ -38,29 +38,26 @@ Verify_checksums () for _DIGEST in $(echo ${LIVE_VERIFY_CHECKSUMS_DIGESTS} | sed -e 's|,| |g') do - _CHECKSUMS="$(echo ${_DIGEST} | tr [a-z] [A-Z])SUMS ${_DIGEST}sum.txt" + _CHECKSUMS="$(echo ${_DIGEST} | tr [a-z] [A-Z])SUMS" - for _CHECKSUM in ${_CHECKSUMS} - do - if [ -e "${_CHECKSUM}" ] - then - echo "Found ${_CHECKSUM}..." > "${_TTY}" + if [ -e "${_CHECKSUMS}" ] + then + echo "Found ${_CHECKSUMS}..." > "${_TTY}" - if [ -e "/bin/${_DIGEST}sum" ] - then - echo "Checking ${_CHECKSUM}..." > "${_TTY}" + if [ -e "/bin/${_DIGEST}sum" ] + then + echo "Checking ${_CHECKSUMS}..." > "${_TTY}" - # Verify checksums - /bin/${_DIGEST}sum -c "${_CHECKSUM}" < "${_TTY}" > "${_TTY}" - _RETURN="${?}" + # Verify checksums + /bin/${_DIGEST}sum -c "${_CHECKSUMS}" < "${_TTY}" > "${_TTY}" + _RETURN="${?}" - # Stop after first verification - break - else - echo "Not found /bin/${_DIGEST}sum..." > "${_TTY}" - fi + # Stop after first verification + break + else + echo "Not found /bin/${_DIGEST}sum..." > "${_TTY}" fi - done + fi done log_end_msg diff --git a/scripts/boot/3020-swapon b/scripts/boot/3020-swapon index e7aed6c..3df90de 100755 --- a/scripts/boot/3020-swapon +++ b/scripts/boot/3020-swapon @@ -29,15 +29,6 @@ Swap () LIVE_SWAP_DEVICES="${LIVE_SWAP_DEVICES:-/dev/sd* /dev/vd*}" - if [ -e /root/etc/fstab.d ] - then - # wheezy - _FSTAB="/root/etc/fstab.d/swap" - else - # squeeze - _FSTAB="/root/etc/fstab" - fi - for _DEVICE in $(echo ${LIVE_SWAP_DEVICES} | sed -e 's|,| |g') do if [ ! -b "${_DEVICE}" ] @@ -57,15 +48,15 @@ Swap () done # Remove all auto swap entries - if grep -qs "swap swap" "${_FSTAB}" + if grep -qs "swap swap" /root/etc/fstab.d/swap then - grep -v "swap swap" "${_FSTAB}" > "${_FSTAB}".tmp - mv "${_FSTAB}".tmp "${_FSTAB}" + grep -v "swap swap" /root/etc/fstab.d/swap > /root/etc/fstab.d/swap.tmp + mv /root/etc/fstab.d/swap.tmp /root/etc/fstab.d/swap fi # Add new swap entries for _DEVICE in ${_SWAP_DEVICES} do - echo "${_DEVICE} swap swap defaults 0 0" >> "${_FSTAB}" + echo "${_DEVICE} swap swap defaults 0 0" >> /root/etc/fstab.d/swap done } diff --git a/scripts/boot/9990-aaa-fixme.sh b/scripts/boot/9990-aaa-fixme.sh index a1eb14a..416d6b4 100755 --- a/scripts/boot/9990-aaa-fixme.sh +++ b/scripts/boot/9990-aaa-fixme.sh @@ -40,8 +40,6 @@ else udevinfo='udevinfo' fi -old_root_overlay_label="live-rw" -old_home_overlay_label="home-rw" custom_overlay_label="persistence" persistence_list="persistence.conf" old_persistence_list="live-persistence.conf" diff --git a/scripts/boot/9990-fstab.sh b/scripts/boot/9990-fstab.sh index abc7b23..5ae9546 100755 --- a/scripts/boot/9990-fstab.sh +++ b/scripts/boot/9990-fstab.sh @@ -13,25 +13,16 @@ Fstab () return fi - if [ -e /root/etc/fstab.d ] - then - # wheezy - _FSTAB="/root/etc/fstab.d/live" - else - # squeeze - _FSTAB="/root/etc/fstab" - fi - log_begin_msg "Configuring fstab" - if ! grep -qs "^${UNIONTYPE}" "${_FSTAB}" + if ! grep -qs "^${UNIONTYPE}" /root/etc/fstab.d/live then - echo "${UNIONTYPE} / ${UNIONTYPE} rw 0 0" >> "${_FSTAB}" + echo "${UNIONTYPE} / ${UNIONTYPE} rw 0 0" >> /root/etc/fstab.d/live fi - if ! grep -qs "^tmpfs /tmp" "${_FSTAB}" + if ! grep -qs "^tmpfs /tmp" /root/etc/fstab.d/live then - echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> "${_FSTAB}" + echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> /root/etc/fstab.d/live fi log_end_msg diff --git a/scripts/boot/9990-main.sh b/scripts/boot/9990-main.sh index fd10e5d..983a1cb 100755 --- a/scripts/boot/9990-main.sh +++ b/scripts/boot/9990-main.sh @@ -32,12 +32,6 @@ Main () . /conf/param.conf fi - if [ -n "${FUSE_MOUNT}" ] - then - # fuse does not work with klibc mount - ln -f /bin/mount.util-linux /bin/mount - fi - # Needed here too because some things (*cough* udev *cough*) # changes the timeout @@ -135,19 +129,6 @@ Main () mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}" fi - # At this point /root should contain the final root filesystem. - # Move all mountpoints below /live into /root/lib/live/mount. - # This has to be done after mounting the root filesystem to / - # otherwise these mount points won't be accessible from the running system. - for _MOUNT in $(cat /proc/mounts | cut -f 2 -d " " | grep -e "^/live/") - do - local newmount - newmount="${rootmnt}/lib/live/mount/${_MOUNT#/live/}" - mkdir -p "${newmount}" - mount -o move "${_MOUNT}" "${newmount}" > /dev/null 2>&1 || \ - mount -o bind "${_MOUNT}" "${newmount}" > /dev/null || \ - log_warning_msg "W: failed to move or bindmount ${_MOUNT} to ${newmount}" - done if [ -n "${ROOT_PID}" ] then @@ -164,6 +145,9 @@ Main () ;; esac + # Move to the new root filesystem so that programs there can get at it. + mkdir -p /root/lib/live/mount/medium + mount --move /live/medium /root/lib/live/mount/medium # aufs2 in kernel versions around 2.6.33 has a regression: # directories can't be accessed when read for the first the time, @@ -171,6 +155,13 @@ Main () # when booting FAI, this simple workaround solves it ls /root/* >/dev/null 2>&1 + # Move findiso directory to the new root filesystem so that programs there can get at it. + if [ -d /live/findiso ] + then + mkdir -p /root/lib/live/mount/findiso + mount -n --move /live/findiso /root/lib/live/mount/findiso + fi + # if we do not unmount the ISO we can't run "fsck /dev/ice" later on # because the mountpoint is left behind in /proc/mounts, so let's get # rid of it when running from RAM diff --git a/scripts/boot/9990-misc-helpers.sh b/scripts/boot/9990-misc-helpers.sh index 2509c90..358448b 100755 --- a/scripts/boot/9990-misc-helpers.sh +++ b/scripts/boot/9990-misc-helpers.sh @@ -65,8 +65,7 @@ get_backing_device () match_files_in_dir () { # Does any files match pattern ${1} ? - local pattern - pattern="${1}" + local pattern="${1}" if [ "$(echo ${pattern})" != "${pattern}" ] then @@ -100,16 +99,7 @@ is_nice_device () { sysfs_path="${1#/sys}" - if [ -e /lib/udev/path_id ] - then - # squeeze - PATH_ID="/lib/udev/path_id" - else - # wheezy/sid (udev >= 174) - PATH_ID="/sbin/udevadm test-builtin path_id" - fi - - if ${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 /sbin/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)" then return 0 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$' @@ -379,27 +369,24 @@ really_export () is_in_list_separator_helper () { - local sep element list - sep=${1} + local sep=${1} shift - element=${1} + local element=${1} shift - list=${*} + local list=${*} echo ${list} | grep -qe "^\(.*${sep}\)\?${element}\(${sep}.*\)\?$" } is_in_space_sep_list () { - local element - element=${1} + local element=${1} shift is_in_list_separator_helper "[[:space:]]" "${element}" "${*}" } is_in_comma_sep_list () { - local element - element=${1} + local element=${1} shift is_in_list_separator_helper "," "${element}" "${*}" } @@ -516,28 +503,25 @@ trim_path () what_is_mounted_on () { - local dir - dir="$(trim_path ${1})" + local dir="$(trim_path ${1})" grep -m1 "^[^ ]\+ ${dir} " /proc/mounts | cut -d' ' -f1 } chown_ref () { - local reference targets owner - reference="${1}" + local reference="${1}" shift - targets=${@} - owner=$(stat -c %u:%g "${reference}") + local targets=${@} + local owner=$(stat -c %u:%g "${reference}") chown -h ${owner} ${targets} } chmod_ref () { - local reference targets rights - reference="${1}" + local reference="${1}" shift - targets=${@} - rights=$(stat -c %a "${reference}") + local targets=${@} + local rights=$(stat -c %a "${reference}") chmod ${rights} ${targets} } @@ -600,7 +584,7 @@ fs_size () size=$(expr ${size} + ${size} / 20 ) # FIXME: 5% more to be sure else # free space - size="$(df -kP | grep -s ${mountp} | awk '{print $4}')" + size="$(df -k | grep -s ${mountp} | awk '{print $4}')" fi if [ -n "${doumount}" ] @@ -623,13 +607,12 @@ load_keymap () setup_loop () { - local fspath module pattern offset encryption readonly - fspath=${1} - module=${2} - pattern=${3} - offset=${4} - encryption=${5} - readonly=${6} + local fspath=${1} + local module=${2} + local pattern=${3} + local offset=${4} + local encryption=${5} + local readonly=${6} # the output of setup_loop is evaluated in other functions, # modprobe leaks kernel options like "libata.dma=0" @@ -731,25 +714,19 @@ try_mount () fi } -# 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) -# $probe should be set, which suppresses warnings upon failure. On -# success, print the mount point for $device. mount_persistence_media () { - local device probe backing old_backing fstype mount_opts - device=${1} - probe=${2} + local device=${1} + local probe=${2} - backing="/live/persistence/$(basename ${device})" + local backing="/live/persistence/$(basename ${device})" mkdir -p "${backing}" - old_backing="$(where_is_mounted ${device})" + local old_backing="$(where_is_mounted ${device})" if [ -z "${old_backing}" ] then - fstype="$(get_fstype ${device})" - mount_opts="rw,noatime" + local fstype="$(get_fstype ${device})" + local mount_opts="rw,noatime" if [ -n "${PERSISTENCE_READONLY}" ] then mount_opts="ro,noatime" @@ -774,19 +751,14 @@ mount_persistence_media () rmdir "${backing}" return 1 fi - else - # This means that $device has already been mounted on - # the place expected by live-boot, so we're done. - echo ${backing} - return 0 fi + return 0 } close_persistence_media () { - local device backing - device=${1} - backing="$(where_is_mounted ${device})" + local device=${1} + local backing="$(where_is_mounted ${device})" if [ -d "${backing}" ] then @@ -852,25 +824,22 @@ open_luks_device () get_gpt_name () { - local dev - dev="${1}" + local dev="${1}" /sbin/blkid -s PART_ENTRY_NAME -p -o value ${dev} 2>/dev/null } is_gpt_device () { - local dev - dev="${1}" + local dev="${1}" [ "$(/sbin/blkid -s PART_ENTRY_SCHEME -p -o value ${dev} 2>/dev/null)" = "gpt" ] } probe_for_gpt_name () { - local overlays dev gpt_dev gpt_name - overlays="${1}" - dev="${2}" + local overlays="${1}" + local dev="${2}" - gpt_dev="${dev}" + local gpt_dev="${dev}" if is_active_luks_mapping ${dev} then # if $dev is an opened luks device, we need to check @@ -883,7 +852,7 @@ probe_for_gpt_name () return fi - gpt_name=$(get_gpt_name ${gpt_dev}) + local gpt_name=$(get_gpt_name ${gpt_dev}) for label in ${overlays} do if [ "${gpt_name}" = "${label}" ] @@ -895,9 +864,8 @@ probe_for_gpt_name () probe_for_fs_label () { - local overlays dev - overlays="${1}" - dev="${2}" + local overlays="${1}" + local dev="${2}" for label in ${overlays} do @@ -910,12 +878,11 @@ probe_for_fs_label () probe_for_file_name () { - local overlays dev ret backing - overlays="${1}" - dev="${2}" + local overlays="${1}" + local dev="${2}" - ret="" - backing="$(mount_persistence_media ${dev} probe)" + local ret="" + local backing="$(mount_persistence_media ${dev} probe)" if [ -z "${backing}" ] then return @@ -926,8 +893,7 @@ probe_for_file_name () path=${backing}/${PERSISTENCE_PATH}${label} if [ -f "${path}" ] then - local loopdev - loopdev=$(setup_loop "${path}" "loop" "/sys/block/loop*") + local loopdev=$(setup_loop "${path}" "loop" "/sys/block/loop*") ret="${ret} ${label}=${loopdev}" fi done @@ -961,19 +927,17 @@ find_persistence_media () # ${white_list_devices} is non-empty, only devices in it will be # scanned. - local overlays white_listed_devices ret black_listed_devices - overlays="${1}" - white_listed_devices="${2}" - ret="" + local overlays="${1}" + local white_listed_devices="${2}" + local ret="" - black_listed_devices="$(what_is_mounted_on /live/medium)" + local black_listed_devices="$(what_is_mounted_on /live/medium)" for dev in $(storage_devices "${black_listed_devices}" "${white_listed_devices}") do - local result luks_device - result="" + local result="" - luks_device="" + local luks_device="" # Check if it's a luks device; we'll have to open the device # in order to probe any filesystem it contains, like we do # below. activate_custom_mounts() also depends on that any luks @@ -1149,12 +1113,11 @@ link_files () # is non-empty, remove mask from all source paths when # creating links (will be necessary if we change root, which # live-boot normally does (into $rootmnt)). - local src_dir dest_dir src_mask # remove multiple /:s and ensure ending on / - src_dir="$(trim_path ${1})/" - dest_dir="$(trim_path ${2})/" - src_mask="${3}" + local src_dir="$(trim_path ${1})/" + local dest_dir="$(trim_path ${2})/" + local src_mask="${3}" # This check can only trigger on the inital, non-recursive call since # we create the destination before recursive calls @@ -1167,8 +1130,7 @@ link_files () find "${src_dir}" -mindepth 1 -maxdepth 1 | \ while read src do - local dest final_src - dest="${dest_dir}$(basename "${src}")" + local dest="${dest_dir}$(basename "${src}")" if [ -d "${src}" ] then if [ -z "$(ls -A "${src}")" ] @@ -1183,7 +1145,7 @@ link_files () fi link_files "${src}" "${dest}" "${src_mask}" else - final_src=${src} + local final_src=${src} if [ -n "${src_mask}" ] then final_src="$(echo ${final_src} | sed "s|^${src_mask}||")" @@ -1197,12 +1159,10 @@ link_files () do_union () { - local unionmountpoint unionrw unionro - unionmountpoint="${1}" # directory where the union is mounted - shift - unionrw="${1}" # branch where the union changes are stored - shift - unionro="${*}" # space separated list of read-only branches (optional) + local unionmountpoint="${1}" # directory where the union is mounted + local unionrw="${2}" # branch where the union changes are stored + local unionro1="${3}" # first underlying read-only branch (optional) + local unionro2="${4}" # second underlying read-only branch (optional) case "${UNIONTYPE}" in aufs) @@ -1226,12 +1186,13 @@ do_union () unionfs-fuse) unionmountopts="-o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid" unionmountopts="${unionmountopts} ${unionrw}=${rw_opt}" - if [ -n "${unionro}" ] + if [ -n "${unionro1}" ] then - for rofs in ${unionro} - do - unionmountopts="${unionmountopts}:${rofs}=${ro_opt}" - done + unionmountopts="${unionmountopts}:${unionro1}=${ro_opt}" + fi + if [ -n "${unionro2}" ] + then + unionmountopts="${unionmountopts}:${unionro2}=${ro_opt}" fi ( sysctl -w fs.file-max=391524 ; ulimit -HSn 16384 unionfs-fuse ${unionmountopts} "${unionmountpoint}" ) && \ @@ -1240,27 +1201,21 @@ do_union () ;; 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? - if echo ${unionro} | grep -q " " - then - panic "Multiple lower filesystems are currently not supported with overlayfs (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}" + # XXX: can unionro2 be used? (overlayfs only handles two dirs, but perhaps they can be chained?) + # XXX: and can unionro1 be optional? i.e. can overlayfs skip lowerdir? + unionmountopts="-o noatime,lowerdir=${unionro1},upperdir=${unionrw}" mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}" ;; *) unionmountopts="-o noatime,${noxino_opt},dirs=${unionrw}=${rw_opt}" - if [ -n "${unionro}" ] + if [ -n "${unionro1}" ] then - for rofs in ${unionro} - do - unionmountopts="${unionmountopts}:${rofs}=${ro_opt}" - done + unionmountopts="${unionmountopts}:${unionro1}=${ro_opt}" + fi + if [ -n "${unionro2}" ] + then + unionmountopts="${unionmountopts}:${unionro2}=${ro_opt}" fi mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}" ;; @@ -1272,13 +1227,12 @@ get_custom_mounts () # Side-effect: leaves $devices with persistence.conf mounted in /live/persistence # Side-effect: prints info to file $custom_mounts - local custom_mounts devices bindings links - custom_mounts=${1} + local custom_mounts=${1} shift - devices=${@} + local devices=${@} - bindings="/tmp/bindings.list" - links="/tmp/links.list" + local bindings="/tmp/bindings.list" + local links="/tmp/links.list" rm -rf ${bindings} ${links} 2> /dev/null for device in ${devices} @@ -1288,14 +1242,14 @@ get_custom_mounts () continue fi - local device_name backing include_list - device_name="$(basename ${device})" - backing=$(mount_persistence_media ${device}) + local device_name="$(basename ${device})" + local backing=$(mount_persistence_media ${device}) if [ -z "${backing}" ] then continue fi + local include_list if [ -r "${backing}/${persistence_list}" ] then include_list="${backing}/${persistence_list}" @@ -1319,15 +1273,14 @@ get_custom_mounts () continue fi - if trim_path ${dir} | grep -q -e "^[^/]" -e "^/lib" -e "^/lib/live\(/.*\)\?$" -e "^/\(.*/\)\?\.\.\?\(/.*\)\?$" + if trim_path ${dir} | grep -q -e "^[^/]" -e "^/live\(/.*\)\?$" -e "^/\(.*/\)\?\.\.\?\(/.*\)\?$" then - log_warning_msg "Skipping unsafe custom mount ${dir}: must be an absolute path containing neither the \".\" nor \"..\" special dirs, and cannot be \"/lib\", or \"/lib/live\" or any of its sub-directories." + log_warning_msg "Skipping unsafe custom mount ${dir}: must be an absolute path containing neither the \".\" nor \"..\" special dirs, and cannot be \"/live\" or any sub-directory therein." continue fi - local opt_source opt_link source full_source full_dest - opt_source="" - opt_link="" + local opt_source="" + local opt_link="" for opt in $(echo ${options} | tr ',' ' '); do case "${opt}" in @@ -1346,7 +1299,7 @@ get_custom_mounts () esac done - source="${dir}" + local source="${dir}" if [ -n "${opt_source}" ] then if echo ${opt_source} | grep -q -e "^/" -e "^\(.*/\)\?\.\.\?\(/.*\)\?$" && [ "${opt_source}" != "." ] @@ -1358,8 +1311,8 @@ get_custom_mounts () fi fi - full_source="$(trim_path ${backing}/${source})" - full_dest="$(trim_path ${rootmnt}/${dir})" + local full_source="$(trim_path ${backing}/${source})" + local full_dest="$(trim_path ${rootmnt}/${dir})" if [ -n "${opt_link}" ] then echo "${device} ${full_source} ${full_dest} ${options}" >> ${links} @@ -1380,9 +1333,8 @@ get_custom_mounts () # We need to make sure that no two custom mounts have the same sources # or are nested; if that is the case, too much weird stuff can happen. - local prev_source prev_dest - prev_source="impossible source" # first iteration must not match - prev_dest="" + local prev_source="impossible source" # first iteration must not match + local 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} | @@ -1399,16 +1351,14 @@ get_custom_mounts () activate_custom_mounts () { - local custom_mounts used_devices - custom_mounts="${1}" # the ouput from get_custom_mounts() - used_devices="" + local custom_mounts="${1}" # the ouput from get_custom_mounts() + local used_devices="" while read device source dest options # < ${custom_mounts} do - local opt_bind opt_link opt_union - opt_bind="true" - opt_link="" - opt_union="" + local opt_bind="true" + local opt_link="" + local opt_union="" for opt in $(echo ${options} | tr ',' ' '); do case "${opt}" in @@ -1489,33 +1439,33 @@ activate_custom_mounts () # XXX: If CONFIG_AUFS_ROBR is added to the Debian kernel we can # ignore the loop below and set rootfs_dest_backing=$dest - local rootfs_dest_backing - rootfs_dest_backing="" + local rootfs_dest_backing="" if [ -n "${opt_link}"] then for d in /live/rootfs/* do if [ -n "${rootmnt}" ] then - fs="${d}/$(echo ${dest} | sed -e "s|${rootmnt}||")" + rootfs_dest_backing="${d}/$(echo ${dest} | sed -e "s|${rootmnt}||")" else - fs="${d}/${dest}" + rootfs_dest_backing="${d}/${dest}" fi - if [ -d "${fs}" ] + if [ -d "${rootfs_dest_backing}" ] then - rootfs_dest_backing="${rootfs_dest_backing} ${fs}" + break + else + rootfs_dest_backing="" fi done fi - local cow_dir links_source if [ -n "${opt_link}" ] && [ -z "${PERSISTENCE_READONLY}" ] then link_files ${source} ${dest} ${rootmnt} elif [ -n "${opt_link}" ] && [ -n "${PERSISTENCE_READONLY}" ] then - mkdir -p ${rootmnt}/lib/live/mount/persistence - links_source=$(mktemp -d ${rootmnt}/lib/live/mount/persistence/links-source-XXXXXX) + mkdir -p /live/persistence + local links_source=$(mktemp -d /live/persistence/links-source-XXXXXX) chown_ref ${source} ${links_source} chmod_ref ${source} ${links_source} # We put the cow dir in the below strange place to @@ -1523,7 +1473,7 @@ activate_custom_mounts () # has its own directory and isn't nested with some # other custom mount (if so that mount's files would # be linked, causing breakage. - cow_dir="/live/overlay/lib/live/mount/persistence/$(basename ${links_source})" + local cow_dir="/live/overlay/live/persistence/$(basename ${links_source})" mkdir -p ${cow_dir} chown_ref "${source}" "${cow_dir}" chmod_ref "${source}" "${cow_dir}" @@ -1540,7 +1490,14 @@ activate_custom_mounts () # bind-mount and union mount are handled the same # in read-only mode, but note that rootfs_dest_backing # is non-empty (and necessary) only for unions - cow_dir="/live/overlay/${dest}" + if [ -n "${rootmnt}" ] + then + local cow_dir="$(echo ${dest} | sed -e "s|^${rootmnt}|/live/overlay/|")" + else + # This is happens if persistence is activated + # post boot + local cow_dir="/live/overlay/${dest}" + fi if [ -e "${cow_dir}" ] && [ -z "${opt_link}" ] then # If an earlier custom mount has files here @@ -1566,32 +1523,6 @@ activate_custom_mounts () echo ${used_devices} } -fix_backwards_compatibility () -{ - local device dir opt backing include_list - device=${1} - dir=${2} - opt=${3} - - if [ -n "${PERSISTENCE_READONLY}" ] - then - return - fi - - backing="$(mount_persistence_media ${device})" - if [ -z "${backing}" ] - then - return - fi - - include_list="${backing}/${persistence_list}" - if [ ! -r "${include_list}" ] && [ ! -r "${backing}/${old_persistence_list}" ] - then - echo "# persistence backwards compatibility: -${dir} ${opt},source=." > "${include_list}" - fi -} - is_mountpoint () { directory="$1" diff --git a/scripts/boot/9990-mount-http.sh b/scripts/boot/9990-mount-http.sh index b557404..1b718c0 100755 --- a/scripts/boot/9990-mount-http.sh +++ b/scripts/boot/9990-mount-http.sh @@ -8,9 +8,8 @@ do_httpmount () for webfile in HTTPFS FTPFS FETCH do - local url extension dest - url="$(eval echo \"\$\{${webfile}\}\")" - extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')" + local url="$(eval echo \"\$\{${webfile}\}\")" + local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')" if [ -n "$url" ] then @@ -21,7 +20,7 @@ do_httpmount () mkdir -p "${alt_mountpoint}" dest="${alt_mountpoint}" else - dest="${mountpoint}/${LIVE_MEDIA_PATH}" + local dest="${mountpoint}/${LIVE_MEDIA_PATH}" mount -t ramfs ram "${mountpoint}" mkdir -p "${dest}" fi diff --git a/scripts/boot/9990-mount-iscsi.sh b/scripts/boot/9990-mount-iscsi.sh index 6ce9851..fd29d91 100755 --- a/scripts/boot/9990-mount-iscsi.sh +++ b/scripts/boot/9990-mount-iscsi.sh @@ -7,8 +7,7 @@ do_iscsi() do_netsetup #modprobe ib_iser modprobe iscsi_tcp - local debugopt - debugopt="" + local debugopt="" [ "${DEBUG}" = "true" ] && debugopt="-d 8" #FIXME this name is supposed to be unique - some date + ifconfig hash? ISCSI_INITIATORNAME="iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)" @@ -22,14 +21,12 @@ do_iscsi() then panic "Failed to log into iscsi target" fi - local host - host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \ - /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')" + local host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \ + /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')" if [ -n "${host}" ] then - local devices i - devices="" - i=0 + local devices="" + local i=0 while [ -z "${devices}" -a $i -lt 60 ] do sleep 1 diff --git a/scripts/boot/9990-netbase.sh b/scripts/boot/9990-netbase.sh index b3f886c..64e30df 100755 --- a/scripts/boot/9990-netbase.sh +++ b/scripts/boot/9990-netbase.sh @@ -135,5 +135,20 @@ EOF fi fi + #if [ ! -x /root/usr/sbin/NetworkManager ] + #then + # for i in eth0 eth1 eth2 ath0 wlan0 + # do + # grep -q "iface ${i}" ${IFFILE} && continue + # + #cat >> "${IFFILE}" << EOF + #allow-hotplug ${i} + #iface ${i} inet dhcp + # + #EOF + # + # done + #fi + log_end_msg } diff --git a/scripts/boot/9990-networking.sh b/scripts/boot/9990-networking.sh index f32ae6c..d9607b7 100755 --- a/scripts/boot/9990-networking.sh +++ b/scripts/boot/9990-networking.sh @@ -111,10 +111,6 @@ do_netsetup () for interface in ${DEVICE}; do ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config - # squeeze - [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf - - # wheezy [ -e /run/net-${interface}.conf ] && . /run/net-${interface}.conf if [ "$IPV4ADDR" != "0.0.0.0" ] @@ -129,10 +125,6 @@ do_netsetup () # source relevant ipconfig output OLDHOSTNAME=${HOSTNAME} - # squeeze - [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf - - # wheezy [ -e /run/net-${interface}.conf ] && . /run/net-${interface}.conf [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME} diff --git a/scripts/boot/9990-overlay.sh b/scripts/boot/9990-overlay.sh index 098111c..e8e00b6 100755 --- a/scripts/boot/9990-overlay.sh +++ b/scripts/boot/9990-overlay.sh @@ -189,58 +189,37 @@ setup_unionfs () done fi - local whitelistdev - whitelistdev="" - if [ -n "${PERSISTENCE_MEDIA}" ] - then - case "${PERSISTENCE_MEDIA}" in - removable) - whitelistdev="$(removable_dev)" - ;; + case "${PERSISTENCE_MEDIA}" in + removable) + whitelistdev="$(removable_dev)" + ;; - removable-usb) - whitelistdev="$(removable_usb_dev)" - ;; - esac - if [ -z "${whitelistdev}" ] - then - whitelistdev="ignore_all_devices" - fi - fi + removable-usb) + whitelistdev="$(removable_usb_dev)" + ;; + + *) + whitelistdev="" + ;; + esac if is_in_comma_sep_list overlay ${PERSISTENCE_METHOD} then - overlays="${old_root_overlay_label} ${old_home_overlay_label} ${custom_overlay_label}" + overlays="${custom_overlay_label}" fi - local overlay_devices - overlay_devices="" - if [ "${whitelistdev}" != "ignore_all_devices" ] - then - for media in $(find_persistence_media "${overlays}" "${whitelistdev}") - do - media="$(echo ${media} | tr ":" " ")" - - case ${media} in - ${old_root_overlay_label}=*) - device="${media#*=}" - fix_backwards_compatibility ${device} / union - overlay_devices="${overlay_devices} ${device}" - ;; - - ${old_home_overlay_label}=*) - device="${media#*=}" - fix_backwards_compatibility ${device} /home bind - overlay_devices="${overlay_devices} ${device}" - ;; + local overlay_devices="" + for media in $(find_persistence_media "${overlays}" "${whitelistdev}") + do + media="$(echo ${media} | tr ":" " ")" - ${custom_overlay_label}=*) - device="${media#*=}" - overlay_devices="${overlay_devices} ${device}" - ;; - esac - done - fi + case ${media} in + ${custom_overlay_label}=*) + device="${media#*=}" + overlay_devices="${overlay_devices} ${device}" + ;; + esac + done elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENCE}" ] then # check if there are any nfs options @@ -335,8 +314,7 @@ setup_unionfs () then # FIXME: handle PERSISTENCE_READONLY unionmountopts="-t ${cow_fstype} -o noatime,union,${cow_mountopt} ${cowdevice}" - # unionmount only works with util-linux mount - mount.util-linux $unionmountopts "${unionmountpoint}" + mount_full $unionmountopts "${unionmountpoint}" else cow_dir="/live/overlay${dir}" rootfs_dir="${rootfs}${dir}" @@ -386,18 +364,16 @@ setup_unionfs () # Adding custom persistence if [ -n "${PERSISTENCE}" ] && [ -z "${NOPERSISTENCE}" ] then - local custom_mounts - custom_mounts="/tmp/custom_mounts.list" + local custom_mounts="/tmp/custom_mounts.list" rm -rf ${custom_mounts} 2> /dev/null # Gather information about custom mounts from devies detected as overlays get_custom_mounts ${custom_mounts} ${overlay_devices} - [ -n "${DEBUG}" ] && cp ${custom_mounts} "/lib/live/mount/persistence" + [ -n "${DEBUG}" ] && cp ${custom_mounts} "/live/persistence" # Now we do the actual mounting (and symlinking) - local used_overlays - used_overlays="" + local used_overlays="" used_overlays=$(activate_custom_mounts ${custom_mounts}) rm ${custom_mounts} @@ -411,6 +387,28 @@ setup_unionfs () done fi + # move all mountpoints to root filesystem + for _DIRECTORY in rootfs persistence + do + if [ -d "/live/${_DIRECTORY}" ] + then + mkdir -p "${rootmnt}/lib/live/mount/${_DIRECTORY}" + + for _MOUNT in $(ls /live/${_DIRECTORY}) + do + mkdir -p "${rootmnt}/lib/live/mount/${_DIRECTORY}/${_MOUNT}" + mount -o move "/live/${_DIRECTORY}/${_MOUNT}" "${rootmnt}/lib/live/mount/${_DIRECTORY}/${_MOUNT}" > /dev/null 2>&1 || \ + mount -o bind "/live/${_DIRECTORY}/${_MOUNT}" "${rootmnt}/lib/live/mount/${_DIRECTORY}/${_MOUNT}" || \ + log_warning_msg "W: failed to mount /live/${_DIRECTORY}/${_MOUNT} to ${rootmnt}/lib/live/mount/${_DIRECTORY}/${_MOUNT}" + done + fi + done + + mkdir -p "${rootmnt}/lib/live/mount/overlay" + mount -o move /live/overlay "${rootmnt}/lib/live/mount/overlay" > /dev/null 2>&1 || \ + mount -o bind /live/overlay "${rootmnt}/lib/live/mount/overlay" || \ + log_warning_msg "W: failed to mount /live/overlay to ${rootmnt}/lib/live/mount/overlay" + # ensure that a potentially stray tmpfs gets removed # otherways, initramfs-tools is unable to remove /live # and fails to boot -- cgit v1.2.3