X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Flive;h=0e9b0aa9f34e2dc9fab34e011064f403641ce1d2;hb=fb986329e0ee3dedc5873f22a40dfc8a0f7a4207;hp=0e1b2f444550c5fdb37ee0ea926eb6bdcf104cc7;hpb=04513ecf47ccb7f069f2cdcd98c4c26edda24948;p=live-boot-grml.git diff --git a/scripts/live b/scripts/live index 0e1b2f4..0e9b0aa 100755 --- a/scripts/live +++ b/scripts/live @@ -68,6 +68,10 @@ Arguments () export DEFCONSOLE ;; + BOOTIF=*) + BOOTIF="${x#BOOTIF=}" + ;; + debug) DEBUG="Yes" export DEBUG @@ -462,7 +466,7 @@ is_nice_device () { sysfs_path="${1#/sys}" - if /lib/udev/path_id "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-|platform-sata_mv|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]$' @@ -577,10 +581,61 @@ do_netsetup () udevadm trigger udevadm settle + [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15 + echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration." + if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \ [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ] then + + # support for Syslinux IPAPPEND parameter + # it sets the BOOTIF variable on the kernel parameter + + if [ -n "${BOOTIF}" ] + then + # pxelinux sets BOOTIF to a value based on the mac address of the + # network card used to PXE boot, so use this value for DEVICE rather + # than a hard-coded device name from initramfs.conf. this facilitates + # network booting when machines may have multiple network cards. + # pxelinux sets BOOTIF to 01-$mac_address + + # strip off the leading "01-", which isn't part of the mac + # address + temp_mac=${BOOTIF#*-} + + # convert to typical mac address format by replacing "-" with ":" + bootif_mac="" + IFS='-' + for x in $temp_mac + do + if [ -z "$bootif_mac" ] + then + bootif_mac="$x" + else + bootif_mac="$bootif_mac:$x" + fi + done + unset IFS + + # look for devices with matching mac address, and set DEVICE to + # appropriate value if match is found. + + for device in /sys/class/net/* + do + if [ -f "$device/address" ] + then + current_mac=$(cat "$device/address") + + if [ "$bootif_mac" = "$current_mac" ] + then + DEVICE=${device##*/} + break + fi + fi + done + fi + # 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) @@ -599,9 +654,6 @@ do_netsetup () devlist="$devlist $device" done - [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15 - echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration." - # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into # an endless loop; iff execution fails give it two further tries, that's # why we use '$devlist $devlist $devlist' for the other for loop @@ -625,45 +677,54 @@ do_netsetup () done else - ipconfig ${DEVICE} | tee /netboot.config - fi - - # source relevant ipconfig output - OLDHOSTNAME=${HOSTNAME} - . /tmp/net-${DEVICE}.conf - [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME} - export HOSTNAME - - if [ -n "${DEVICE}" ] - then - HWADDR="$(cat /sys/class/net/${DEVICE}/address)" + for interface in ${DEVICE}; do + ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config + [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf + if [ "$IPV4ADDR" != "0.0.0.0" ] + then + break + fi + done fi - if [ ! -e "/etc/resolv.conf" ] - then - echo "Creating /etc/resolv.conf" + for interface in ${DEVICE}; do + # source relevant ipconfig output + OLDHOSTNAME=${HOSTNAME} + [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf + [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME} + export HOSTNAME - if [ -n "${DNSDOMAIN}" ] + if [ -n "${interface}" ] then - echo "domain ${DNSDOMAIN}" > /etc/resolv.conf - echo "search ${DNSDOMAIN}" > /etc/resolv.conf + HWADDR="$(cat /sys/class/net/${interface}/address)" fi - for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1} - do - echo "nameserver $i" >> /etc/resolv.conf - done - fi + if [ ! -e "/etc/resolv.conf" ] + then + echo "Creating /etc/resolv.conf" - # Check if we have a network device at all - if ! ls /sys/class/net/"$DEVICE" > /dev/null 2>&1 && \ - ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \ - ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \ - ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \ - ! ls /sys/class/net/ra0 > /dev/null 2>&1 - then - panic "No supported network device found, maybe a non-mainline driver is required." - fi + if [ -n "${DNSDOMAIN}" ] + then + echo "domain ${DNSDOMAIN}" > /etc/resolv.conf + echo "search ${DNSDOMAIN}" > /etc/resolv.conf + fi + + for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1} + do + echo "nameserver $i" >> /etc/resolv.conf + done + fi + + # Check if we have a network device at all + if ! ls /sys/class/net/"$interface" > /dev/null 2>&1 && \ + ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \ + ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \ + ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \ + ! ls /sys/class/net/ra0 > /dev/null 2>&1 + then + panic "No supported network device found, maybe a non-mainline driver is required." + fi + done } do_netmount() @@ -896,8 +957,6 @@ do_snap_copy () if [ -b "${fromdev}" ] then - log_success_msg "Copying snapshot ${fromdev} to ${todir}..." - # look for free mem if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ] then @@ -935,8 +994,9 @@ do_snap_copy () return 0 else - log_warning_msg "Unable to find the snapshot ${snap_type} medium" return 1 + + log_warning_msg "Unable to find the snapshot ${snap_type} medium" fi } @@ -966,16 +1026,6 @@ try_snap () snapdata="${1}" snap_mount="${2}" snap_type="${3}" - snap_relpath="${4}" - - if [ -z "${snap_relpath}" ] - then - # root snapshot, default usage - snap_relpath="/" - else - # relative snapshot (actually used just for "/home" snapshots) - snap_mount="${2}${snap_relpath}" - fi if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ] then @@ -1013,16 +1063,8 @@ try_snap () cpioargs='--unconditional --make-directories' fi - if [ -s "${snapback}/${snapfile}" ] - then - BEFOREDIR="$(pwd)" - cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null - RES="$?" - cd "${BEFOREDIR}" - else - log_warning_msg "${snapback}/${snapfile} is empty, adding it for sync on reboot." - RES="0" - fi + cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null + RES="$?" if [ "${RES}" != "0" ] then @@ -1054,7 +1096,7 @@ try_snap () if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}" then - log_warning_msg "Impossible to include the ${snap_type} Snapshot (i)" + log_warning_msg "Impossible to include the ${snap_type} Snapshot" return 1 else if [ -n "${snapfile}" ] @@ -1064,11 +1106,11 @@ try_snap () fi fi else - log_warning_msg "Impossible to include the ${snap_type} Snapshot (o)" + log_warning_msg "Impossible to include the ${snap_type} Snapshot" return 1 fi - echo "export ${snap_type}SNAP=${snap_relpath}:${snapdev}:${snapfile}" >> snapshot.conf # for resync on reboot/halt + echo "export ${snap_type}SNAP="/cow${snap_mount#$rootmnt}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt return 0 } @@ -1406,7 +1448,7 @@ setup_unionfs () # Look for other snapshots to copy in try_snap "${root_snapdata}" "${rootmnt}" "ROOT" # This second type should be removed when snapshot grow smarter - try_snap "${home_snapdata}" "${rootmnt}" "HOME" "/home" + try_snap "${home_snapdata}" "${rootmnt}/home" "HOME" fi if [ -n "${SHOWMOUNTS}" ] @@ -1645,6 +1687,16 @@ find_livefs () return 1 } +set_usplash_timeout () +{ + if [ -x /sbin/usplash_write ] + then + /sbin/usplash_write "TIMEOUT 120" + else if [ -x /sbin/splashy_update ] ; then + /sbin/splashy_update "TIMEOUT 120" + fi ; fi +} + integrity_check () { media_mountpoint="${1}" @@ -1671,6 +1723,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 @@ -1689,6 +1749,9 @@ mountroot () Arguments + set_usplash_timeout + start_usplash_pulse + maybe_break live-premount log_begin_msg "Running /scripts/live-premount" run_scripts /scripts/live-premount @@ -1697,6 +1760,8 @@ mountroot () # Needed here too because some things (*cough* udev *cough*) # changes the timeout + set_usplash_timeout + if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ] then if do_netmount @@ -1815,18 +1880,6 @@ mountroot () # when booting FAI, this simple workaround solves it ls /root/* >/dev/null 2>&1 - # copy snapshot configuration if exists - if [ -f snapshot.conf ] - then - log_begin_msg "Copying snapshot.conf to ${rootmnt}/etc/live/boot.d" - if [ ! -d "${rootmnt}/etc/live/boot.d" ] - then - mkdir -p "${rootmnt}/etc/live/boot.d" - fi - cp snapshot.conf "${rootmnt}/etc/live/boot.d/" - log_end_msg - fi - maybe_break live-bottom log_begin_msg "Running /scripts/live-bottom\n"