Added basic infrastructure for supporting Ubuntu 9.10
authorPravin Shinde <pravin@black-perl.(none)>
Wed, 18 Nov 2009 17:38:53 +0000 (18:38 +0100)
committerPravin Shinde <pravin@black-perl.(none)>
Wed, 18 Nov 2009 17:38:53 +0000 (18:38 +0100)
Fetched the kernel image and initd image from live cd
modified the generate_initrd.sh for extracting the content of initrd image.

18 files changed:
bko/live/ubuntu/U9.10/casper [new file with mode: 0644]
bko/live/ubuntu/U9.10/generate_initrd.sh [new file with mode: 0755]
bko/live/ubuntu/U9.10/httpfs/server/fusermount [new file with mode: 0755]
bko/live/ubuntu/U9.10/httpfs/server/httpfs [new file with mode: 0755]
bko/live/ubuntu/U9.10/httpfs/static/udhcpc [new file with mode: 0755]
bko/live/ubuntu/U9.10/httpfs/static/udhcpc.sh [new file with mode: 0755]
bko/live/ubuntu/U9.10/init [new file with mode: 0755]
bko/live/ubuntu/U9.10/initrd_orig [new file with mode: 0644]
bko/live/ubuntu/U9.10/iscsi/initiatorname.iscsi [new file with mode: 0644]
bko/live/ubuntu/U9.10/iscsi/iscsid.conf [new file with mode: 0644]
bko/live/ubuntu/U9.10/iscsi/tools/iscsi-iname [new file with mode: 0755]
bko/live/ubuntu/U9.10/iscsi/tools/iscsi_discovery [new file with mode: 0755]
bko/live/ubuntu/U9.10/iscsi/tools/iscsiadm [new file with mode: 0755]
bko/live/ubuntu/U9.10/iscsi/tools/iscsid [new file with mode: 0755]
bko/live/ubuntu/U9.10/iscsi/tools/iscsistart [new file with mode: 0755]
bko/live/ubuntu/U9.10/iscsi/tools/isosize [new file with mode: 0755]
bko/live/ubuntu/U9.10/run-init [new file with mode: 0755]
bko/live/ubuntu/U9.10/vmlinuz [new file with mode: 0644]

diff --git a/bko/live/ubuntu/U9.10/casper b/bko/live/ubuntu/U9.10/casper
new file mode 100644 (file)
index 0000000..b52a3ea
--- /dev/null
@@ -0,0 +1,661 @@
+#!/bin/sh
+
+# set -e
+
+export PATH=/usr/bin:/usr/sbin:/bin:/sbin
+
+mountpoint=/cdrom
+LIVE_MEDIA_PATH=casper
+
+root_persistence="casper-rw"
+home_persistence="home-rw"
+root_snapshot_label="casper-sn"
+home_snapshot_label="home-sn"
+
+USERNAME=casper
+USERFULLNAME="Live session user"
+HOST=live
+BUILD_SYSTEM=Custom
+
+mkdir -p $mountpoint
+tried=/tmp/tried
+
+[ -f /etc/casper.conf ] && . /etc/casper.conf
+export USERNAME USERFULLNAME HOST BUILD_SYSTEM
+
+. /scripts/casper-helpers
+
+if [ ! -f /casper.vars ]; then
+    touch /casper.vars
+fi
+
+parse_cmdline() {
+    for x in $(cat /proc/cmdline); do
+        case $x in
+            showmounts|show-cow)
+                export SHOWMOUNTS='Yes' ;;
+            persistent)
+                export PERSISTENT="Yes" ;;
+            nopersistent)
+                export PERSISTENT="" ;;
+            union=*)
+                export UNIONFS="${x#union=}";;
+            ip*)
+                STATICIP=${x#ip=}
+                if [ "${STATICIP}" = "" ]; then
+                    STATICIP="frommedia"
+                fi
+                export STATICIP ;;
+            ignore_uuid)
+                IGNORE_UUID="Yes" ;;
+            live-media-path=*)
+                LIVE_MEDIA_PATH="${x#live-media-path=}"
+                export LIVE_MEDIA_PATH
+                echo "export LIVE_MEDIA_PATH=\"$LIVE_MEDIA_PATH\"" >> /etc/casper.conf ;;
+        esac
+    done
+    if [ "${UNIONFS}" = "" ]; then
+        export UNIONFS="aufs"
+    fi
+}
+
+is_casper_path() {
+    path=$1
+    if [ -d "$path/$LIVE_MEDIA_PATH" ]; then
+        if [ "$(echo $path/$LIVE_MEDIA_PATH/*.squashfs)" != "$path/$LIVE_MEDIA_PATH/*.squashfs" ] ||
+            [ "$(echo $path/$LIVE_MEDIA_PATH/*.ext2)" != "$path/$LIVE_MEDIA_PATH/*.ext2" ] ||
+            [ "$(echo $path/$LIVE_MEDIA_PATH/*.dir)" != "$path/$LIVE_MEDIA_PATH/*.dir" ]; then
+            return 0
+        fi
+    fi
+    return 1
+}
+
+matches_uuid() {
+    if [ "$IGNORE_UUID" ] || [ ! -e /conf/uuid.conf ]; then
+        return 0
+    fi
+    path="$1"
+    uuid="$(cat /conf/uuid.conf)"
+    for try_uuid_file in "$path/.disk/casper-uuid"*; do
+        [ -e "$try_uuid_file" ] || continue
+        try_uuid="$(cat "$try_uuid_file")"
+        if [ "$uuid" = "$try_uuid" ]; then
+            return 0
+        fi
+    done
+    return 1
+}
+
+get_backing_device() {
+    case "$1" in
+        *.squashfs|*.ext2)
+            echo $(setup_loop "$1" "loop" "/sys/block/loop*")
+            ;;
+        *.dir)
+            echo "directory"
+            ;;
+        *)
+            panic "Unrecognized casper filesystem: $1"
+            ;;
+    esac
+}
+
+match_files_in_dir() {
+    # Does any files match pattern $1 ?
+
+    local pattern="$1"
+    if [ "$(echo $pattern)" != "$pattern" ]; then
+        return 0
+    fi
+    return 1
+}
+
+mount_images_in_directory() {
+    directory="$1"
+    rootmnt="$2"
+    if match_files_in_dir "$directory/$LIVE_MEDIA_PATH/*.squashfs" ||
+        match_files_in_dir "$directory/$LIVE_MEDIA_PATH/*.ext2" ||
+        match_files_in_dir "$directory/$LIVE_MEDIA_PATH/*.dir"; then
+        setup_unionfs "$directory/$LIVE_MEDIA_PATH" "$rootmnt"
+    else
+        :
+    fi
+}
+
+is_nice_device() {
+    sysfs_path="${1#/sys}"
+    if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-(ide|scsi|usb)|platform-orion-ehci|platform-mmc|platform-mxsdhci)"; then
+        return 0
+    fi
+    return 1
+}
+
+copy_live_to() {
+    copyfrom="${1}"
+    copytodev="${2}"
+    copyto="${copyfrom}_swap"
+
+    size=$(fs_size "" ${copyfrom} "used")
+
+    if [ "${copytodev}" = "ram" ]; then
+        # copying to ram:
+        freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) )
+        mount_options="-o size=${size}k"
+        free_string="memory"
+        fstype="tmpfs"
+        dev="/dev/shm"
+    else
+        # it should be a writable block device
+        if [ -b "${copytodev}" ]; then
+            dev="${copytodev}"
+            free_string="space"
+            fstype=$(get_fstype "${dev}")
+            freespace=$(fs_size "${dev}")
+        else
+            [ "$quiet" != "y" ] && log_warning_msg "${copytodev} is not a block device."
+            return 1
+        fi
+    fi
+    if [ "${freespace}" -lt "${size}" ] ; then
+        [ "$quiet" != "y" ] && log_warning_msg "Not enough free ${free_string} (${freespace}k > ${size}k) to copy live media in ${copytodev}."
+        return 1
+    fi
+
+    # begin copying..
+    mkdir "${copyto}"
+    echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
+    mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
+    cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files
+    umount ${copyfrom}
+    mount -r -o move ${copyto} ${copyfrom}
+    rmdir ${copyto}
+    return 0
+}
+
+do_netmount() {
+    rc=1
+
+    modprobe "${MP_QUIET}" af_packet # For DHCP
+
+    /sbin/udevadm trigger
+    /sbin/udevadm settle
+
+    ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config
+
+    if [ "${NFSROOT}" = "auto" ]; then
+        NFSROOT=${ROOTSERVER}:${ROOTPATH}
+    fi
+
+    [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}"
+
+    if [ "${NETBOOT}" != "nfs" ] && do_cifsmount ; then
+        rc=0
+    elif do_nfsmount ; then
+        NETBOOT="nfs"
+        export NETBOOT
+        rc=0
+    fi
+
+    [ "$quiet" != "y" ] && log_end_msg
+    return ${rc}
+}
+
+do_nfsmount() {
+    rc=1
+    modprobe "${MP_QUIET}" nfs
+    if [ -z "${NFSOPTS}" ]; then
+        NFSOPTS=""
+    fi
+
+    [ "$quiet" != "y" ] && log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
+    # FIXME: This while loop is an ugly HACK round an nfs bug
+    i=0
+    while [ "$i" -lt 60 ]; do
+        nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
+        sleep 1
+        i="$(($i + 1))"
+    done
+    return ${rc}
+}
+
+do_cifsmount() {
+    rc=1
+    if [ -x "/sbin/mount.cifs" ]; then
+        if [ -z "${NFSOPTS}" ]; then
+            CIFSOPTS="-ouser=root,password="
+        else
+            CIFSOPTS="${NFSOPTS}"
+        fi
+
+        [ "$quiet" != "y" ] && log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
+        modprobe "${MP_QUIET}" cifs
+
+        if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}" ; then
+            rc=0
+        fi
+    fi
+    return ${rc}
+}
+
+do_snap_copy ()
+{
+    fromdev="${1}"
+    todir="${2}"
+    snap_type="${3}"
+
+    size=$(fs_size "${fromdev}" "" "used")
+
+    if [ -b "${fromdev}" ]; then
+        # look for free mem
+        if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]; then
+            todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' )
+            freespace=$(df -k  | grep -s ${todev} | awk '{print $4}')
+        else
+            freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ))
+        fi
+
+        tomount="/mnt/tmpsnap"
+        if [ ! -d "${tomount}" ] ; then
+            mkdir -p "${tomount}"
+        fi
+
+        fstype=$(get_fstype "${fromdev}")
+        if [ -n "${fstype}" ]; then
+            # Copying stuff...
+            mount -t "${fstype}" -o ro,noatime "${fromdev}" "${tomount}"
+            cp -a "${tomount}"/* ${todir}
+            umount "${tomount}"
+        else
+            log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
+        fi
+
+        rmdir "${tomount}"
+        if echo ${fromdev} | grep -qs loop; then
+           losetup -d "${fromdev}"
+        fi
+        return 0
+    else
+        return 1
+        [ "$quiet" != "y" ] && log_warning_msg "Unable to find the snapshot ${snap_type} medium"
+    fi
+}
+
+try_snap ()
+{
+    # Look for $snap_label.* in block devices and copy the contents to $snap_mount
+    #   and remember the device and filename for resync on exit in casper.init
+
+    snap_label="${1}"
+    snap_mount="${2}"
+    snap_type="${3}"
+
+    snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2")
+    if [ ! -z "${snapdata}" ]; then
+        snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
+        snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
+        snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
+        if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\)'; then
+            # squashfs or ext2 snapshot
+            dev=$(get_backing_device "${snapback}/${snapfile}")
+            if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"; then
+                 log_warning_msg "Impossible to include the ${snapfile} Snapshot"
+                 return 1
+            fi
+        else
+            # cpio.gz snapshot
+            # Unfortunately klibc's cpio is incompatible with the rest of
+            # the world; everything else requires -u -d, while klibc doesn't
+            # implement them. Try to detect whether it's in use.
+            cpiopath="$(which cpio)" || true
+            if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"; then
+                cpioargs=
+            else
+                cpioargs='-u -d'
+            fi
+            if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio -i $cpioargs 2>/dev/null) ; then
+                log_warning_msg "Impossible to include the ${snapfile} Snapshot"
+                return 1
+            fi
+        fi
+        umount "${snapback}"
+    else
+        dev=$(find_cow_device "${snap_label}")
+        if [ -b "${dev}" ]; then
+            if echo "${dev}" | grep -qs loop; then
+                # strange things happens, user confused?
+                snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
+                snapfile=$(basename ${snaploop})
+                snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ')
+            else
+                snapdev="${dev}"
+            fi
+            if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}" ; then
+                log_warning_msg "Impossible to include the ${snap_label} Snapshot"
+                return 1
+            else
+                if [ -n "${snapfile}" ]; then
+                     # it was a loop device, user confused
+                     umount ${snapdev}
+                fi
+            fi
+        else
+            log_warning_msg "Impossible to include the ${snap_label} Snapshot"
+            return 1
+        fi
+    fi
+    echo "export ${snap_type}SNAP="/cow${snap_mount#$rootmnt}":${snapdev}:${snapfile}" >> /etc/casper.conf # for resync on reboot/halt
+    return 0
+}
+
+setup_unionfs() {
+    image_directory="$1"
+    rootmnt="$2"
+
+    case ${UNIONFS} in
+        aufs|unionfs)
+            modprobe "${MP_QUIET}" -b ${UNIONFS} || true
+            if ! cut -f2 /proc/filesystems | grep -q "^${UNIONFS}\$" && \
+               [ -x /bin/unionfs-fuse ]; then
+                UNIONFS="unionfs-fuse"
+            fi
+            ;;
+    esac
+
+    # run-init can't deal with images in a subdir, but we're going to
+    # move all of these away before it runs anyway.  No, we're not,
+    # put them in / since move-mounting them into / breaks mono and
+    # some other apps.
+
+    croot="/"
+
+    # Let's just mount the read-only file systems first
+    rofsstring=""
+    rofslist=""
+    if [ "${NETBOOT}" = "nfs" ] ; then
+        roopt="nfsro" # work around a bug in nfs-unionfs locking
+    elif [ "${UNIONFS}" = "aufs" ]; then
+        roopt="rr"
+    elif [ "${UNIONFS}" = "unionfs-fuse" ]; then
+        roopt="RO"
+    else
+        roopt="ro"
+    fi
+
+    mkdir -p "${croot}"
+    for image_type in "ext2" "squashfs" "dir" ; do
+        for image in "${image_directory}"/*."${image_type}"; do
+            imagename=$(basename "${image}")
+            if [ -d "${image}" ]; then
+                # it is a plain directory: do nothing
+                rofsstring="${image}=${roopt}:${rofsstring}"
+                rofslist="${image} ${rofslist}"
+            elif [ -f "${image}" ]; then
+                backdev=$(get_backing_device "$image")
+                fstype=$(get_fstype "${backdev}")
+                if [ "${fstype}" = "unknown" ]; then
+                    panic "Unknown file system type on ${backdev} (${image})"
+                fi
+                mkdir -p "${croot}/${imagename}"
+                mount -t "${fstype}" -o ro,noatime "${backdev}" "${croot}/${imagename}" || panic "Can not mount $backdev ($image) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}"
+            fi
+        done
+    done
+    rofsstring=${rofsstring%:}
+
+    mkdir -p /cow
+    cowdevice="tmpfs"
+    cow_fstype="tmpfs"
+    cow_mountopt="rw,noatime,mode=755"
+
+    # Looking for "${root_persistence}" device or file
+    if [ -n "${PERSISTENT}" ]; then
+        cowprobe=$(find_cow_device "${root_persistence}")
+        if [ -b "${cowprobe}" ]; then
+            cowdevice=${cowprobe}
+            cow_fstype=$(get_fstype "${cowprobe}")
+           cow_mountopt="rw,noatime"
+        else
+            [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent medium"
+        fi
+    fi
+
+    mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || panic "Can not mount $cowdevice on /cow"
+
+    case ${UNIONFS} in
+        unionfs-fuse)
+            (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:$rofsstring "$rootmnt" || panic "${UNIONFS} mount failed")
+            mkdir -p /dev/.initramfs/varrun
+            pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
+            ;;
+        *)
+            mount -t ${UNIONFS} -o noatime,dirs=/cow=rw:$rofsstring ${UNIONFS} "$rootmnt" || panic "${UNIONFS} mount failed"
+            ;;
+    esac
+
+    # Adding other custom mounts
+    if [ -n "${PERSISTENT}" ]; then
+        # directly mount /home
+        # FIXME: add a custom mounts configurable system
+        homecow=$(find_cow_device "${home_persistence}" )
+        if [ -b "${homecow}" ]; then
+            mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
+            export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
+        else
+            [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent home medium"
+        fi
+        # Look for other snapshots to copy in
+        try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT"
+        try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME"
+    fi
+
+    if [ -n "${SHOWMOUNTS}" ]; then
+        for d in ${rofslist}; do
+            mkdir -p "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}"
+            case d in
+                *.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}"
+                    ;;
+                *)
+                    if [ "${UNIONFS}" = unionfs-fuse ]; then
+                        mount -o bind "${d}" "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}"
+                    else
+                        mount -o move "${d}" "${rootmnt}/${LIVE_MEDIA_PATH}/${d##*/}"
+                    fi
+                    ;;
+            esac
+        done
+        # shows cow fs on /cow for use by casper-snapshot
+        mkdir -p "${rootmnt}/cow"
+        mount -o bind /cow "${rootmnt}/cow"
+    fi
+
+    # move the first mount; no head in busybox-initramfs
+    for d in $(mount -t squashfs | cut -d\  -f 3); do
+        mkdir -p "${rootmnt}/rofs"
+        if [ "${UNIONFS}" = unionfs-fuse ]; then
+            mount -o bind "${d}" "${rootmnt}/rofs"
+        else
+            mount -o move "${d}" "${rootmnt}/rofs"
+        fi
+        break
+    done
+}
+
+check_dev ()
+{
+    sysdev="${1}"
+    devname="${2}"
+    skip_uuid_check="${3}"
+    if [ -z "${devname}" ]; then
+        devname=$(sys2dev "${sysdev}")
+    fi
+
+    if [ -d "${devname}" ]; then
+        mount -o bind "${devname}" $mountpoint || continue
+        if is_casper_path $mountpoint; then
+            echo $mountpoint
+            return 0
+        else
+            umount $mountpoint
+        fi
+    fi
+    [ -e "$devname" ] || continue
+
+    if [ -n "${LIVEMEDIA_OFFSET}" ]; then
+        loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVEMEDIA_OFFSET}")
+        devname="${loopdevname}" 
+    fi
+
+    fstype=$(get_fstype "${devname}")
+    if is_supported_fs ${fstype}; then
+        devuid=$(blkid -o value -s UUID "$devname")
+        [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
+        mount -t ${fstype} -o ro,noatime "${devname}" $mountpoint || continue
+        [ -n "$devuid" ] && echo "$devuid" >> $tried
+        if is_casper_path $mountpoint && \
+           ([ "$skip_uuid_check" ] || matches_uuid $mountpoint); then
+            echo $mountpoint
+            return 0
+        else
+            umount $mountpoint
+        fi
+    fi
+
+    if [ -n "${LIVEMEDIA_OFFSET}" ]; then
+        losetup -d "${loopdevname}"
+    fi
+    return 1
+}
+
+find_livefs() {
+    timeout="${1}"
+    # first look at the one specified in the command line
+    if [ ! -z "${LIVEMEDIA}" ]; then
+        if check_dev "null" "${LIVEMEDIA}" "skip_uuid_check"; then
+            return 0
+        fi
+    fi
+    # don't start autodetection before timeout has expired
+    if [ -n "${LIVEMEDIA_TIMEOUT}" ]; then
+        if [ "${timeout}" -lt "${LIVEMEDIA_TIMEOUT}" ]; then
+            return 1
+        fi
+    fi
+    # or do the scan of block devices
+    for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|fd)"); do
+        devname=$(sys2dev "${sysblock}")
+        [ -e "$devname" ] || continue
+        fstype=$(get_fstype "${devname}")
+        if /lib/udev/cdrom_id ${devname} > /dev/null; then
+            if check_dev "null" "${devname}" ; then
+                return 0
+            fi
+        elif is_nice_device "${sysblock}" ; then
+            for dev in $(subdevices "${sysblock}"); do
+                if check_dev "${dev}" ; then
+                    return 0
+                fi
+            done
+        elif [ "${fstype}" = "squashfs" -o \
+                "${fstype}" = "ext4" -o \
+                "${fstype}" = "ext3" -o \
+                "${fstype}" = "ext2" ]; then
+            # This is an ugly hack situation, the block device has
+            # an image directly on it.  It's hopefully
+            # casper, so take it and run with it.
+            ln -s "${devname}" "${devname}.${fstype}"
+            echo "${devname}.${fstype}"
+            return 0
+        fi
+    done
+    return 1
+}
+
+set_usplash_timeout() {
+    if [ -x /sbin/usplash_write ]; then
+        /sbin/usplash_write "TIMEOUT 120"
+    fi
+}
+
+mountroot() {
+    exec 6>&1
+    exec 7>&2
+    exec > casper.log
+    exec 2>&1
+    tail -f casper.log >&7 &
+    tailpid="$!"
+
+    parse_cmdline
+
+    set_usplash_timeout
+    [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-premount"
+    run_scripts /scripts/casper-premount
+    [ "$quiet" != "y" ] && log_end_msg
+
+    # Needed here too because some things (*cough* udev *cough*)
+    # changes the timeout
+
+    set_usplash_timeout
+
+    if [ ! -z "${NETBOOT}" ]; then
+        if do_netmount ; then
+            livefs_root="${mountpoint}"
+        else
+            panic "Unable to find a live file system on the network"
+        fi
+    else
+        # Scan local devices for the image
+        i=0
+        while [ "$i" -lt 60 ]; do
+            livefs_root=$(find_livefs $i)
+            if [ "${livefs_root}" ]; then
+                break
+            fi
+            sleep 1
+            i="$(($i + 1))"
+        done
+    fi
+
+    if [ -z "${livefs_root}" ]; then
+        panic "Unable to find a medium containing a live file system"
+    fi
+
+    if [ "${TORAM}" ]; then
+        live_dest="ram"
+    elif [ "${TODISK}" ]; then
+        live_dest="${TODISK}"
+    fi
+    if [ "${live_dest}" ]; then
+        log_begin_msg "Copying live_media to ${live_dest}"
+        copy_live_to "${livefs_root}" "${live_dest}"
+        log_end_msg
+    fi
+
+    mount_images_in_directory "${livefs_root}" "${rootmnt}"
+
+    log_end_msg
+
+    # unionfs-fuse needs /dev to be bind-mounted for the duration of
+    # casper-bottom; udev's init script will take care of things after that
+    if [ "${UNIONFS}" = unionfs-fuse ]; then
+        mount -n -o bind /dev "${rootmnt}/dev"
+    fi
+
+    maybe_break casper-bottom
+    [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-bottom"
+
+    run_scripts /scripts/casper-bottom
+    [ "$quiet" != "y" ] && log_end_msg
+
+    if [ "${UNIONFS}" = unionfs-fuse ]; then
+        umount "${rootmnt}/dev"
+    fi
+
+    exec 1>&6 6>&-
+    exec 2>&7 7>&-
+    kill "$tailpid"
+    cp casper.log "${rootmnt}/var/log/"
+    if [ -f /etc/casper.conf ]; then
+        cp /etc/casper.conf "${rootmnt}/etc/"
+    fi
+}
diff --git a/bko/live/ubuntu/U9.10/generate_initrd.sh b/bko/live/ubuntu/U9.10/generate_initrd.sh
new file mode 100755 (executable)
index 0000000..02a98df
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/bash
+set -e
+
+#cleanup the old mess
+echo "Removing the old files"
+sudo rm -rf initrd.lz initrd mpoint
+
+# create a copy of image to modify
+cp initrd_orig initrd.lzma
+unlzma initrd.lzma
+
+echo "extracting filesystem filesystem"
+mkdir -p mpoint
+cd mpoint 
+cpio -ivu --no-absolute-filename  < ../initrd 2> /dev/null
+cd ..
+
+
+
+echo "coping the needed files..."
+
+cp run-init mpoint/bin/
+chmod 777 mpoint/bin/run-init
+
+cp httpfs/server/httpfs mpoint/bin/
+chmod 777 mpoint/bin/httpfs
+
+cp httpfs/server/fusermount mpoint/bin/
+chmod 777 mpoint/bin/fusermount
+
+cp init mpoint/
+chmod 0777 mpoint/init 
+
+cp casper mpoint/scripts/
+chmod 0777 mpoint/scripts/casper
+
+echo "copying iscsi related files..."
+mkdir -p mpoint/etc/iscsi
+cp iscsi/iscsid.conf mpoint/etc/iscsi/
+cp iscsi/initiatorname.iscsi mpoint/etc/iscsi/
+cp iscsi/tools/* mpoint/sbin/
+
+mkdir -p mpoint/modules
+#TODO: Fetch iscsi related modules and put them here. 
+#cp modules/* mpoint/modules/
+
+sudo chown -R root.root mpoint
+cd mpoint
+echo "creating initrd from new system filesystem"
+echo "Compressing the filesystem"
+echo "exiting here as this part is not yet implemented."
+exit 0  # exiting here as I have not worked on compressing back the image.
+sudo find . | sudo cpio -oH newc | gzip -9 > ../initrd.gz
+cd ..
+
+sudo rm -rf mpoint initrd
+
+echo "Done, you can use initrd.gz"
diff --git a/bko/live/ubuntu/U9.10/httpfs/server/fusermount b/bko/live/ubuntu/U9.10/httpfs/server/fusermount
new file mode 100755 (executable)
index 0000000..c37325c
Binary files /dev/null and b/bko/live/ubuntu/U9.10/httpfs/server/fusermount differ
diff --git a/bko/live/ubuntu/U9.10/httpfs/server/httpfs b/bko/live/ubuntu/U9.10/httpfs/server/httpfs
new file mode 100755 (executable)
index 0000000..df1b078
Binary files /dev/null and b/bko/live/ubuntu/U9.10/httpfs/server/httpfs differ
diff --git a/bko/live/ubuntu/U9.10/httpfs/static/udhcpc b/bko/live/ubuntu/U9.10/httpfs/static/udhcpc
new file mode 100755 (executable)
index 0000000..2d408a5
Binary files /dev/null and b/bko/live/ubuntu/U9.10/httpfs/static/udhcpc differ
diff --git a/bko/live/ubuntu/U9.10/httpfs/static/udhcpc.sh b/bko/live/ubuntu/U9.10/httpfs/static/udhcpc.sh
new file mode 100755 (executable)
index 0000000..9a8437a
--- /dev/null
@@ -0,0 +1,18 @@
+#!/static/sh
+
+case "$1" in
+       renew|bound)
+               ifconfig $interface $ip up
+
+               if [ -n "$router" ] ; then
+                       for i in $router ; do
+                               route add -net 0.0.0.0 netmask 0.0.0.0 gw $i dev $interface
+                       done
+               fi
+               ;;
+       * )
+               ifconfig $interface 0.0.0.0
+               ;;
+esac
+
+exit 0
diff --git a/bko/live/ubuntu/U9.10/init b/bko/live/ubuntu/U9.10/init
new file mode 100755 (executable)
index 0000000..264be56
--- /dev/null
@@ -0,0 +1,260 @@
+#!/bin/sh
+
+[ -d /dev ] || mkdir -m 0755 /dev
+[ -d /root ] || mkdir -m 0700 /root
+[ -d /sys ] || mkdir /sys
+[ -d /proc ] || mkdir /proc
+[ -d /tmp ] || mkdir /tmp
+mkdir -p /var/lock
+mount -t sysfs -o nodev,noexec,nosuid none /sys 
+mount -t proc -o nodev,noexec,nosuid none /proc 
+
+grep -q '\<quiet\>' /proc/cmdline || echo "Loading, please wait..."
+
+# Note that this only becomes /dev on the real filesystem if udev's scripts
+# are used; which they will be, but it's worth pointing out
+mount -t tmpfs -o mode=0755 udev /dev
+[ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
+[ -e /dev/null ] || mknod /dev/null c 1 3
+> /dev/.initramfs-tools
+mkdir /dev/.initramfs
+
+# Export the dpkg architecture
+export DPKG_ARCH=
+. /conf/arch.conf
+
+# Set modprobe env
+export MODPROBE_OPTIONS="-qb"
+
+# Export relevant variables
+export ROOT=
+export ROOTDELAY=
+export ROOTFLAGS=
+export ROOTFSTYPE=
+export IPOPTS=
+export break=
+export init=/sbin/init
+export quiet=n
+export readonly=y
+export rootmnt=/root
+export debug=
+export panic=
+export blacklist=
+export resume_offset=
+
+# Bring in the main config
+. /conf/initramfs.conf
+for conf in conf/conf.d/*; do
+       [ -f ${conf} ] && . ${conf}
+done
+. /scripts/functions
+
+# Parse command line options
+for x in $(cat /proc/cmdline); do
+       case $x in
+       init=*)
+               init=${x#init=}
+               ;;
+       root=*)
+               ROOT=${x#root=}
+               case $ROOT in
+               LABEL=*)
+                       ROOT="${ROOT#LABEL=}"
+
+                       # support / in LABEL= paths (escape to \x2f)
+                       case "${ROOT}" in
+                       *[/]*)
+                       if [ -x "$(command -v sed)" ]; then
+                               ROOT="$(echo ${ROOT} | sed 's,/,\\x2f,g')"
+                       else
+                               if [ "${ROOT}" != "${ROOT#/}" ]; then
+                                       ROOT="\x2f${ROOT#/}"
+                               fi
+                               if [ "${ROOT}" != "${ROOT%/}" ]; then
+                                       ROOT="${ROOT%/}\x2f"
+                               fi
+                               IFS='/'
+                               newroot=
+                               for s in $ROOT; do
+                                       if [ -z "${newroot}" ]; then
+                                               newroot="${s}"
+                                       else
+                                               newroot="${newroot}\\x2f${s}"
+                                       fi
+                               done
+                               unset IFS
+                               ROOT="${newroot}"
+                       fi
+                       esac
+                       ROOT="/dev/disk/by-label/${ROOT}"
+                       ;;
+               UUID=*)
+                       ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
+                       ;;
+               /dev/nfs)
+                       [ -z "${BOOT}" ] && BOOT=nfs
+                       ;;
+               esac
+               ;;
+       rootflags=*)
+               ROOTFLAGS="-o ${x#rootflags=}"
+               ;;
+       rootfstype=*)
+               ROOTFSTYPE="${x#rootfstype=}"
+               ;;
+       rootdelay=*)
+               ROOTDELAY="${x#rootdelay=}"
+               case ${ROOTDELAY} in
+               *[![:digit:].]*)
+                       ROOTDELAY=
+                       ;;
+               esac
+               ;;
+       resumedelay=*)
+               RESUMEDELAY="${x#resumedelay=}"
+               ;;
+       loop=*)
+               LOOP="${x#loop=}"
+               ;;
+       loopflags=*)
+               LOOPFLAGS="-o ${x#loopflags=}"
+               ;;
+       loopfstype=*)
+               LOOPFSTYPE="${x#loopfstype=}"
+               ;;
+       cryptopts=*)
+               cryptopts="${x#cryptopts=}"
+               ;;
+       nfsroot=*)
+               NFSROOT="${x#nfsroot=}"
+               ;;
+       netboot=*)
+               NETBOOT="${x#netboot=}"
+               ;;
+       ip=*)
+               IPOPTS="${x#ip=}"
+               ;;
+       boot=*)
+               BOOT=${x#boot=}
+               ;;
+       resume=*)
+               RESUME="${x#resume=}"
+               ;;
+       resume_offset=*)
+               resume_offset="${x#resume_offset=}"
+               ;;
+       noresume)
+               noresume=y
+               ;;
+       panic=*)
+               panic="${x#panic=}"
+               case ${panic} in
+               *[![:digit:].]*)
+                       panic=
+                       ;;
+               esac
+               ;;
+       quiet)
+               quiet=y
+               ;;
+       ro)
+               readonly=y
+               ;;
+       rw)
+               readonly=n
+               ;;
+       debug)
+               debug=y
+               quiet=n
+               exec >/dev/.initramfs/initramfs.debug 2>&1
+               set -x
+               ;;
+       debug=*)
+               debug=y
+               quiet=n
+               set -x
+               ;;
+       break=*)
+               break=${x#break=}
+               ;;
+       break)
+               break=premount
+               ;;
+       blacklist=*)
+               blacklist=${x#blacklist=}
+               ;;
+       esac
+done
+
+if [ -z "${noresume}" ]; then
+       export resume=${RESUME}
+else
+       export noresume
+fi
+
+depmod -a
+maybe_break top
+
+# export BOOT variable value for compcache,
+# so we know if we run from casper
+export BOOT
+
+# Don't do log messages here to avoid confusing usplash
+run_scripts /scripts/init-top
+
+maybe_break modules
+log_begin_msg "Loading essential drivers..."
+load_modules
+log_end_msg
+
+maybe_break premount
+[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
+run_scripts /scripts/init-premount
+[ "$quiet" != "y" ] && log_end_msg
+
+maybe_break mount
+log_begin_msg "Mounting root file system..."
+. /scripts/${BOOT}
+parse_numeric ${ROOT}
+mountroot
+log_end_msg
+
+maybe_break bottom
+[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
+run_scripts /scripts/init-bottom
+[ "$quiet" != "y" ] && log_end_msg
+
+# Move virtual filesystems over to the real filesystem
+mount -n -o move /sys ${rootmnt}/sys
+mount -n -o move /proc ${rootmnt}/proc
+
+# Check init bootarg
+if [ -n "${init}" ] && [ ! -x "${rootmnt}${init}" ]; then
+       echo "Target filesystem doesn't have ${init}."
+       init=
+fi
+
+# Search for valid init
+if [ -z "${init}" ] ; then
+       for init in /sbin/init /etc/init /bin/init /bin/sh; do
+               if [ ! -x "${rootmnt}${init}" ]; then
+                       continue
+               fi
+               break
+       done
+fi
+
+# No init on rootmount
+if [ ! -x "${rootmnt}${init}" ]; then
+       panic "No init found. Try passing init= bootarg."
+fi
+
+# Confuses /etc/init.d/rc
+if [ -n ${debug} ]; then
+       unset debug
+fi
+
+# Chain to real filesystem
+maybe_break init
+exec run-init ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console 2>&1
+panic "Could not execute run-init."
diff --git a/bko/live/ubuntu/U9.10/initrd_orig b/bko/live/ubuntu/U9.10/initrd_orig
new file mode 100644 (file)
index 0000000..6a31f84
Binary files /dev/null and b/bko/live/ubuntu/U9.10/initrd_orig differ
diff --git a/bko/live/ubuntu/U9.10/iscsi/initiatorname.iscsi b/bko/live/ubuntu/U9.10/iscsi/initiatorname.iscsi
new file mode 100644 (file)
index 0000000..a732d75
--- /dev/null
@@ -0,0 +1,6 @@
+## DO NOT EDIT OR REMOVE THIS FILE!
+## If you remove this file, the iSCSI daemon will not start.
+## If you change the InitiatorName, existing access control lists
+## may reject this initiator.  The InitiatorName must be unique
+## for each iSCSI initiator.  Do NOT duplicate iSCSI InitiatorNames.
+InitiatorName=iqn.1993-08.org.debian:01:74e6bd2d995f
diff --git a/bko/live/ubuntu/U9.10/iscsi/iscsid.conf b/bko/live/ubuntu/U9.10/iscsi/iscsid.conf
new file mode 100644 (file)
index 0000000..83200c2
--- /dev/null
@@ -0,0 +1,245 @@
+#
+# Open-iSCSI default configuration.
+# Could be located at /etc/iscsi/iscsid.conf or ~/.iscsid.conf
+#
+# Note: To set any of these values for a specific node/session run
+# the iscsiadm --mode node --op command for the value. See the README
+# and man page for iscsiadm for details on the --op command.
+#
+
+################
+# iSNS settings
+################
+# Address of iSNS server
+#isns.address = 192.168.0.1
+#isns.port = 3205
+
+#############################
+# NIC/HBA and driver settings
+#############################
+# open-iscsi can create a session and bind it to a NIC/HBA.
+# To set this up see the example iface config file.
+
+#*****************
+# Startup settings
+#*****************
+
+# To request that the iscsi initd scripts startup a session set to "automatic".
+node.startup = automatic
+#
+# To manually startup the session set to "manual". The default is manual.
+#node.startup = manual
+
+# *************
+# CHAP Settings
+# *************
+
+# To enable CHAP authentication set node.session.auth.authmethod
+# to CHAP. The default is None.
+#node.session.auth.authmethod = CHAP
+
+# To set a CHAP username and password for initiator
+# authentication by the target(s), uncomment the following lines:
+#node.session.auth.username = username
+#node.session.auth.password = password
+
+# To set a CHAP username and password for target(s)
+# authentication by the initiator, uncomment the following lines:
+#node.session.auth.username_in = username_in
+#node.session.auth.password_in = password_in
+
+# To enable CHAP authentication for a discovery session to the target
+# set discovery.sendtargets.auth.authmethod to CHAP. The default is None.
+#discovery.sendtargets.auth.authmethod = CHAP
+
+# To set a discovery session CHAP username and password for the initiator
+# authentication by the target(s), uncomment the following lines:
+#discovery.sendtargets.auth.username = username
+#discovery.sendtargets.auth.password = password
+
+# To set a discovery session CHAP username and password for target(s)
+# authentication by the initiator, uncomment the following lines:
+#discovery.sendtargets.auth.username_in = username_in
+#discovery.sendtargets.auth.password_in = password_in
+
+# ********
+# Timeouts
+# ********
+#
+# See the iSCSI REAME's Advanced Configuration section for tips
+# on setting timeouts when using multipath or doing root over iSCSI.
+#
+# To specify the length of time to wait for session re-establishment
+# before failing SCSI commands back to the application when running
+# the Linux SCSI Layer error handler, edit the line.
+# The value is in seconds and the default is 120 seconds.
+node.session.timeo.replacement_timeout = 120
+
+# To specify the time to wait for login to complete, edit the line.
+# The value is in seconds and the default is 15 seconds.
+node.conn[0].timeo.login_timeout = 15
+
+# To specify the time to wait for logout to complete, edit the line.
+# The value is in seconds and the default is 15 seconds.
+node.conn[0].timeo.logout_timeout = 15
+
+# Time interval to wait for on connection before sending a ping.
+node.conn[0].timeo.noop_out_interval = 5
+
+# To specify the time to wait for a Nop-out response before failing
+# the connection, edit this line. Failing the connection will
+# cause IO to be failed back to the SCSI layer. If using dm-multipath
+# this will cause the IO to be failed to the multipath layer.
+node.conn[0].timeo.noop_out_timeout = 5
+
+# To specify the time to wait for abort response before
+# failing the operation and trying a logical unit reset edit the line.
+# The value is in seconds and the default is 15 seconds.
+node.session.err_timeo.abort_timeout = 15
+
+# To specify the time to wait for a logical unit response
+# before failing the operation and trying session re-establishment
+# edit the line.
+# The value is in seconds and the default is 30 seconds.
+node.session.err_timeo.lu_reset_timeout = 20
+
+#******
+# Retry
+#******
+
+# To specify the number of times iscsid should retry a login
+# if the login attempt fails due to the node.conn[0].timeo.login_timeout
+# expiring modify the following line. Note that if the login fails
+# quickly (before node.conn[0].timeo.login_timeout fires) because the network
+# layer or the target returns an error, iscsid may retry the login more than
+# node.session.initial_login_retry_max times.
+#
+# This retry count along with node.conn[0].timeo.login_timeout
+# determines the maximum amount of time iscsid will try to
+# establish the initial login. node.session.initial_login_retry_max is
+# multiplied by the node.conn[0].timeo.login_timeout to determine the
+# maximum amount.
+#
+# The default node.session.initial_login_retry_max is 8 and
+# node.conn[0].timeo.login_timeout is 15 so we have:
+#
+# node.conn[0].timeo.login_timeout * node.session.initial_login_retry_max =
+#                                                              120 seconds
+#
+# Valid values are any integer value. This only
+# affects the initial login. Setting it to a high value can slow
+# down the iscsi service startup. Setting it to a low value can
+# cause a session to not get logged into, if there are distuptions
+# during startup or if the network is not ready at that time.
+node.session.initial_login_retry_max = 8
+
+################################
+# session and device queue depth
+################################
+
+# To control how many commands the session will queue set
+# node.session.cmds_max to an integer between 2 and 2048 that is also
+# a power of 2. The default is 128.
+node.session.cmds_max = 128
+
+# To control the device's queue depth set node.session.queue_depth
+# to a value between 1 and 128. The default is 32.
+node.session.queue_depth = 32
+
+#***************
+# iSCSI settings
+#***************
+
+# To enable R2T flow control (i.e., the initiator must wait for an R2T
+# command before sending any data), uncomment the following line:
+#
+#node.session.iscsi.InitialR2T = Yes
+#
+# To disable R2T flow control (i.e., the initiator has an implied
+# initial R2T of "FirstBurstLength" at offset 0), uncomment the following line:
+#
+# The defaults is No.
+node.session.iscsi.InitialR2T = No
+
+#
+# To disable immediate data (i.e., the initiator does not send
+# unsolicited data with the iSCSI command PDU), uncomment the following line:
+#
+#node.session.iscsi.ImmediateData = No
+#
+# To enable immediate data (i.e., the initiator sends unsolicited data
+# with the iSCSI command packet), uncomment the following line:
+#
+# The default is Yes
+node.session.iscsi.ImmediateData = Yes
+
+# To specify the maximum number of unsolicited data bytes the initiator
+# can send in an iSCSI PDU to a target, edit the following line.
+#
+# The value is the number of bytes in the range of 512 to (2^24-1) and
+# the default is 262144
+node.session.iscsi.FirstBurstLength = 262144
+
+# To specify the maximum SCSI payload that the initiator will negotiate
+# with the target for, edit the following line.
+#
+# The value is the number of bytes in the range of 512 to (2^24-1) and
+# the defauls it 16776192
+node.session.iscsi.MaxBurstLength = 16776192
+
+# To specify the maximum number of data bytes the initiator can receive
+# in an iSCSI PDU from a target, edit the following line.
+#
+# The value is the number of bytes in the range of 512 to (2^24-1) and
+# the default is 131072
+node.conn[0].iscsi.MaxRecvDataSegmentLength = 131072
+
+
+# To specify the maximum number of data bytes the initiator can receive
+# in an iSCSI PDU from a target during a discovery session, edit the
+# following line.
+#
+# The value is the number of bytes in the range of 512 to (2^24-1) and
+# the default is 32768
+# 
+discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768
+
+# To allow the targets to control the setting of the digest checking,
+# with the initiator requesting a preference of enabling the checking, uncomment# one or both of the following lines:
+#node.conn[0].iscsi.HeaderDigest = CRC32C,None
+#node.conn[0].iscsi.DataDigest = CRC32C,None
+#
+# To allow the targets to control the setting of the digest checking,
+# with the initiator requesting a preference of disabling the checking,
+# uncomment one or both of the following lines:
+#node.conn[0].iscsi.HeaderDigest = None,CRC32C
+#node.conn[0].iscsi.DataDigest = None,CRC32C
+#
+# To enable CRC32C digest checking for the header and/or data part of
+# iSCSI PDUs, uncomment one or both of the following lines:
+#node.conn[0].iscsi.HeaderDigest = CRC32C
+#node.conn[0].iscsi.DataDigest = CRC32C
+#
+# To disable digest checking for the header and/or data part of
+# iSCSI PDUs, uncomment one or both of the following lines:
+#node.conn[0].iscsi.HeaderDigest = None
+#node.conn[0].iscsi.DataDigest = None
+#
+# The default is to never use DataDigests or HeaderDigests.
+#
+
+
+#************
+# Workarounds
+#************
+
+# Some targets like IET prefer after an initiator has sent a task
+# management function like an ABORT TASK or LOGICAL UNIT RESET, that
+# it does not respond to PDUs like R2Ts. To enable this behavior uncomment
+# the following line (The default behavior is Yes):
+node.session.iscsi.FastAbort = Yes
+
+# Some targets like Equalogic prefer that after an initiator has sent
+# a task management function like an ABORT TASK or LOGICAL UNIT RESET, that
+# it continue to respond to R2Ts. To enable this uncomment this line
+# node.session.iscsi.FastAbort = No
diff --git a/bko/live/ubuntu/U9.10/iscsi/tools/iscsi-iname b/bko/live/ubuntu/U9.10/iscsi/tools/iscsi-iname
new file mode 100755 (executable)
index 0000000..8afc1ba
Binary files /dev/null and b/bko/live/ubuntu/U9.10/iscsi/tools/iscsi-iname differ
diff --git a/bko/live/ubuntu/U9.10/iscsi/tools/iscsi_discovery b/bko/live/ubuntu/U9.10/iscsi/tools/iscsi_discovery
new file mode 100755 (executable)
index 0000000..398a6e8
--- /dev/null
@@ -0,0 +1,188 @@
+#!/bin/sh
+#
+# Copyright (C) Voltaire Ltd. 2006.  ALL RIGHTS RESERVED.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Author: Dan Bar Dov <danb@voltaire.com>
+
+# iscsi_discovery:
+#    * does a send-targets discovery to the given IP
+#    * set the transport type to the preferred transport (or tcp is -t flag is not used)
+#    * tries to login
+#    * if succeeds,
+#          o logout,
+#          o mark record autmatic (unless -m flag is used)
+#    * else
+#          o reset transport type to TCP
+#          o try to login
+#          o if succeeded
+#                + logout
+#                + mark record automatic (unless -m flag is used)
+#
+
+usage()
+{
+       echo "Usage: $0 <IP> [-p <port>] [-d] [-t <tcp|iser> [-f]] [-m] [-l]"
+       echo "Options:"
+       echo  "-p               set the port number (defualt is 3260)."
+       echo  "-d               print debugging information"
+       echo  "-t               set trasnpot (default is tcp)."
+       echo  "-f               force specific transport -disable the fallback to tcp (default is fallback enabled)."
+       echo  "                 force the transport specified by the argument of the -t flag."
+       echo  "-m               manual startup - will set manual startup (default is automatic startup)."
+       echo  "-l               login to the new discovered nodes (defualt is false)."
+}
+
+dbg()
+{
+       $debug && echo $@
+}
+
+initialize()
+{
+       trap "exit" 2
+       debug=false
+       force="0"
+       log_out="1"
+       startup_manual="0"
+       #set defualt transport to tcp
+       transport=tcp
+       #set defualt port to 3260
+       port=3260;
+}
+
+parse_cmdline()
+{
+       if [ $# -lt 1 ]; then
+               usage
+               exit 1
+       fi
+
+       # check if the IP address is valid
+       ip=`echo $1 | awk -F'.' '$1 != "" && $1 <=255 && $2 != "" && $2 <= 255 && $3 != "" && $3 <= 255 && $4 != "" && $4 <= 255 {print $0}'`
+       if [ -z "$ip" ]; then
+               echo "$1 is not a vaild IP address!"
+               exit 1
+       fi
+       shift
+       while getopts "dfmlt:p:" options; do
+        case $options in
+               d ) debug=true;;
+               f ) force="1";;
+               t ) transport=$OPTARG;;
+               p ) port=$OPTARG;;
+               m ) startup_manual="1";;
+               l ) log_out=0;;
+               \? ) usage
+                       exit 1;;
+               * )  usage
+                       exit 1;;
+        esac
+       done
+}
+
+discover()
+{
+       # If open-iscsi is already logged in to the portal, exit
+       if [ $(iscsiadm -m session | grep -c ${ip}:${port}) -ne 0 ]; then
+               echo "Please logout from all targets on ${ip}:${port} before trying to run discovery on that portal"
+               exit 2
+       fi
+
+       connected=0
+       discovered=0
+       df=/tmp/discovered.$$
+
+       dbg "starting discovery to $ip"
+       iscsiadm -m discovery --type sendtargets --portal ${ip}:${port} > ${df}
+       while read portal target
+       do
+               portal=${portal%,*}
+               select_transport
+       done < ${df}
+
+       discovered=$(cat ${df} | wc -l)
+       if [ ${discovered} = 0 ]; then
+               echo "failed to discover targets at ${ip}"
+               exit 2
+       else
+               echo "discovered ${discovered} targets at ${ip}"
+       fi
+       /bin/rm -f ${df}
+}
+
+try_login()
+{
+       if [ "$startup_manual" != "1" ]; then
+               iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v automatic
+       fi
+       iscsiadm -m node --targetname ${target} --portal ${portal} --login >/dev/null 2>&1
+       ret=$?
+       if [ ${ret} = 0 ]; then
+               echo "Set target ${target} to automatic login over ${transport} to portal ${portal}"
+               connected=$(($connected + 1))
+               if [ "$log_out" = "1" ]; then
+                       iscsiadm -m node --targetname ${target} --portal ${portal} --logout
+               fi
+       else
+               echo "Cannot login over ${transport} to portal ${portal}"
+               iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v manual
+       fi
+       return ${ret}
+}
+
+set_transport()
+{
+       transport=$1
+       if [ "$transport" == "iser" ];then
+               iscsiadm -m node --targetname ${target} --portal ${portal} \
+                               --op update -n node.conn[0].iscsi.HeaderDigest -v None
+               iscsiadm -m node --targetname ${target} --portal ${portal} \
+                               --op update -n node.conn[0].iscsi.DataDigest -v None
+       fi
+       transport_name=`iscsiadm  -m node -p ${portal} -T ${target} |awk '/transport_name/ {print $1}'`
+       iscsiadm -m node --targetname ${target} --portal ${portal} \
+                       --op update -n ${transport_name} -v ${transport}
+}
+
+select_transport()
+{
+       set_transport $transport
+       dbg "Testing $transport-login to target ${target} portal ${portal}"
+       try_login;
+       if [ $? != 0 -a  "$force" = "0" ]; then
+               set_transport tcp
+               dbg "starting to test tcp-login to target ${target} portal ${portal}"
+               try_login;
+       fi
+}
+
+check_iscsid()
+{
+       #check if iscsid is running
+       pidof iscsid &>/dev/null
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               echo "iscsid is not running"
+               echo "Exiting..."
+               exit 1
+       fi
+}
+
+check_iscsid
+initialize
+parse_cmdline "$@"
+discover
diff --git a/bko/live/ubuntu/U9.10/iscsi/tools/iscsiadm b/bko/live/ubuntu/U9.10/iscsi/tools/iscsiadm
new file mode 100755 (executable)
index 0000000..dd05ea1
Binary files /dev/null and b/bko/live/ubuntu/U9.10/iscsi/tools/iscsiadm differ
diff --git a/bko/live/ubuntu/U9.10/iscsi/tools/iscsid b/bko/live/ubuntu/U9.10/iscsi/tools/iscsid
new file mode 100755 (executable)
index 0000000..8405fff
Binary files /dev/null and b/bko/live/ubuntu/U9.10/iscsi/tools/iscsid differ
diff --git a/bko/live/ubuntu/U9.10/iscsi/tools/iscsistart b/bko/live/ubuntu/U9.10/iscsi/tools/iscsistart
new file mode 100755 (executable)
index 0000000..da5ca2d
Binary files /dev/null and b/bko/live/ubuntu/U9.10/iscsi/tools/iscsistart differ
diff --git a/bko/live/ubuntu/U9.10/iscsi/tools/isosize b/bko/live/ubuntu/U9.10/iscsi/tools/isosize
new file mode 100755 (executable)
index 0000000..ae09dcc
Binary files /dev/null and b/bko/live/ubuntu/U9.10/iscsi/tools/isosize differ
diff --git a/bko/live/ubuntu/U9.10/run-init b/bko/live/ubuntu/U9.10/run-init
new file mode 100755 (executable)
index 0000000..e0dc396
Binary files /dev/null and b/bko/live/ubuntu/U9.10/run-init differ
diff --git a/bko/live/ubuntu/U9.10/vmlinuz b/bko/live/ubuntu/U9.10/vmlinuz
new file mode 100644 (file)
index 0000000..c74304f
Binary files /dev/null and b/bko/live/ubuntu/U9.10/vmlinuz differ