X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Flive;h=ec3a6394aef565e6d85d839ba2cc7b3944bb2046;hb=b7d8cc3bdbfb83bf203baab832cde1f846c8ee9d;hp=e73ee80a2f998ca11f8a7e5b03598dcab7122618;hpb=0ce3d8be7921ca1565ddc6567cb40e688075158c;p=live-boot-grml.git diff --git a/scripts/live b/scripts/live index e73ee80..ec3a639 100755 --- a/scripts/live +++ b/scripts/live @@ -20,6 +20,7 @@ USERFULLNAME="Live user" HOSTNAME="host" mkdir -p "${mountpoint}" +tried="/tmp/tried" # Create /etc/mtab for debug purpose and future syncs if [ ! -d /etc ] @@ -42,9 +43,39 @@ then touch /live.vars fi +network_started= + +start_network () +{ + [ -z "$network_started" ] || return + [ -z "$NETBOOT" ] || return + + mount -n -o bind /sys /root/sys + mount -n -o bind /proc /root/proc + mount -n -o bind /dev /root/dev + mkdir -p /root/var/run/network + + # Close inherited fd's to prevent debconf-communicate from + # continuing to run post-live-initramfs. + chroot /root dhclient eth0 3>&- 4<&- + + network_started=1 +} + +stop_network () +{ + [ "$network_started" ] || return + + chroot /root ifconfig eth0 down + umount /root/sys + umount /root/proc + umount /root/dev +} + Arguments () { PRESEEDS="" + LOCATIONS="" for ARGUMENT in $(cat /proc/cmdline) do @@ -417,8 +448,8 @@ Arguments () ;; preseed/file=*|file=*) - LOCATION="${ARGUMENT#*=}" - export LOCATION + LOCATIONS="${ARGUMENT#*=} ${LOCATIONS}" + export LOCATIONS ;; nopreseed) @@ -427,22 +458,11 @@ Arguments () ;; url=*) - location="${ARGUMENT#url=}" - - mount -o bind /sys /root/sys - mount -o bind /proc /root/proc - mount -o bind /dev /root/dev - - mkdir -p /root/var/run/network - [ "${NETBOOT}" ] || chroot /root dhclient eth0 - chroot /root wget -P /tmp "${location}" - [ "${NETBOOT}" ] || chroot /root ifconfig eth0 down - - umount /root/sys - umount /root/proc - umount /root/dev + URL_LOCATION="${ARGUMENT#url=}" - LOCATION="/tmp/$(basename "${location}")" + start_network + chroot /root wget -P /tmp "${URL_LOCATION}" + LOCATIONS="/tmp/$(basename ${URL_LOCATION}) ${LOCATIONS}" ;; */*=*) @@ -665,12 +685,15 @@ is_nice_device () { sysfs_path="${1#/sys}" - if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-|platform-orion-ehci|platform-mmc|platform-mxsdhci|)" + if /lib/udev/path_id "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-|platform-orion-ehci|platform-mmc|platform-mxsdhci|)" then return 0 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$' then return 0 + elif echo ${sysfs_path} | grep -q "^/block/dm-" + then + return 0 fi return 1 @@ -700,7 +723,7 @@ copy_live_to () if [ "${copytodev}" = "ram" ] then # copying to ram: - freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\/dev/console # "cp -a" from busybox also copies hidden files else mkdir -p ${copyto}/${LIVE_MEDIA_PATH} - cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH} # "cp -a" from busybox also copies hidden files + cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH} + if [ -e ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ] + then + cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ${copyto} + fi fi fi @@ -775,6 +802,10 @@ do_netmount () udevadm trigger udevadm settle + if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \ + [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ] + then + # if ethdevice was not specified on the kernel command line # make sure we try to get a working network configuration # for *every* present network device (except for loopback of course) @@ -818,6 +849,10 @@ do_netmount () fi done + else + ipconfig ${DEVICE} | tee /netboot.config + fi + # source relevant ipconfig output OLDHOSTNAME=${HOSTNAME} . /tmp/net-${DEVICE}.conf @@ -995,7 +1030,7 @@ do_snap_copy () todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts) freespace=$(df -k | awk '/'${todev}'/{print $4}') else - freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\" $tried && continue mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue + [ -n "$devuid" ] && echo "$devuid" >> $tried if is_live_path ${mountpoint} && \ ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint}) @@ -1660,7 +1699,7 @@ find_livefs () # or do the scan of block devices # prefer removable devices over non-removable devices, so scan them first - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)") + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | egrep -v "/(loop|ram|dm-|fd)") do if [ "$(cat ${sysblock}/removable)" = "1" ] then @@ -1674,6 +1713,7 @@ find_livefs () for sysblock in $devices_to_scan do devname=$(sys2dev "${sysblock}") + [ -e "$devname" ] || continue fstype=$(get_fstype "${devname}") if /lib/udev/cdrom_id ${devname} > /dev/null @@ -1745,6 +1785,14 @@ integrity_check () fi } +start_usplash_pulse () +{ + if [ -x /sbin/usplash_write ] + then + /sbin/usplash_write "PULSELOGO" + fi +} + mountroot () { if [ -x /scripts/local-top/cryptroot ]; then @@ -1764,6 +1812,7 @@ mountroot () Arguments set_usplash_timeout + start_usplash_pulse maybe_break live-premount log_begin_msg "Running /scripts/live-premount" @@ -1858,6 +1907,36 @@ mountroot () mount -n -o bind /dev "${rootmnt}/dev" fi + # Open up two fifo's fd's for debconf-communicate to use. Speeds up + # the live-initramfs process considerably. + log_begin_msg "Creating debconf-communicate fifo mechanism" + mkfifo /tmp/debconf-in.fifo + mkfifo /tmp/debconf-out.fifo + + # Make the template database read-only, so that passthrough debconf + # instances can write to it directly; otherwise templates are only + # passed through when necessary. Use temporary config databases as + # well; we'll copy their contents back at the end. + DEBCONF_TMPDIR="$(chroot /root mktemp -dt debconf.XXXXXX)" + cp -a /root/var/cache/debconf/config.dat "/root$DEBCONF_TMPDIR/" + cp -a /root/var/cache/debconf/passwords.dat "/root$DEBCONF_TMPDIR/" + sed "s,^Filename: /var/cache/debconf/\(config\|passwords\).dat$,Filename: $DEBCONF_TMPDIR/\1.dat,; /^Name: templatedb/a\ ++Readonly: true" /root/etc/debconf.conf >"/root$DEBCONF_TMPDIR/debconf.conf" + + # Save the PID so it can be killed later. + DEBCONF_SYSTEMRC="$DEBCONF_TMPDIR/debconf.conf" chroot /root debconf-communicate -fnoninteractive live-initramfs > /tmp/debconf-out.fifo < /tmp/debconf-in.fifo & + + if [ ! -p /tmp/debconf-in.fifo ] || [ ! -p /tmp/debconf-out.fifo ] + then + log_warning_msg "failed to setup debconf-communicate channel" + fi + log_end_msg + + # Order matters! + # These file descriptors must stay open until we're finished with + # debconf-communicate. + exec 4/tmp/debconf-in.fifo + maybe_break live-bottom log_begin_msg "Running /scripts/live-bottom\n" @@ -1869,6 +1948,20 @@ mountroot () umount "${rootmnt}/dev" fi + # Close the fd's associated with debconf-communicate + exec 3>&- 4<&- + rm -f /tmp/debconf-in.fifo + rm -f /tmp/debconf-out.fifo + + # Copy config database changes back to the master files. + chroot /root debconf-copydb tmpdb config \ + --config=Name:tmpdb --config=Driver:File \ + --config="Filename:$DEBCONF_TMPDIR/config.dat" + chroot /root debconf-copydb tmpdb passwords \ + --config=Name:tmpdb --config=Driver:File \ + --config="Filename:$DEBCONF_TMPDIR/passwords.dat" + rm -rf "$DEBCONF_TMPDIR" + exec 1>&6 6>&- exec 2>&7 7>&- kill ${tailpid}