On 06/19/2009 12:50 AM, David Huff wrote:
this script gets run by the preprocesser and setup a floppy disk image
containing the answers file
will also setup a pxe envrionment if tftp parameter is supplied.
Hi David,
Most of my comments would probably be "automatically" fixed when you port it to
Python (e.g. whitespace issues).
---
client/tests/kvm/scripts/unattended.sh | 157 ++++++++++++++++++++++++++++++++
1 files changed, 157 insertions(+), 0 deletions(-)
create mode 100755 client/tests/kvm/scripts/unattended.sh
diff --git a/client/tests/kvm/scripts/unattended.sh b/client/tests/kvm/scripts/unattended.sh
new file mode 100755
index 0000000..9624887
--- /dev/null
+++ b/client/tests/kvm/scripts/unattended.sh
@@ -0,0 +1,157 @@
+#!/bin/bash
+#
+# unattended.sh - sets up environment for an unattended install for kvm_autotest
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Written by:
+# David Huff<dhufff@xxxxxxxxxx>
+# Darryl L. Pierce<dpierce@xxxxxxxxxx>
+#
+# 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; version 2 of the License.
+#
+# 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., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+ME=$(basename "$0")
+log() { printf '%s: %s\n' "$*">&2; }
+die() { log "Aborting: $*"; exit 1; }
+debug() { if $debugging; then log "[DEBUG] $*"; fi }
+
+debugging=true
+
+set -e
+
+# creates a floppy disk image and adds unattended config file
+# this is prefered over vvfat b/c of know issues with fat16
+# uses loop back mout b/c -i wasent available unitil mtools> 4.0
+# $CONFIG file to put on floppy disk image
+create_floppy_disk () {
+ local size="144"
+ local filename="images/$KVM_TEST_floppy"
mixture of tabs and spaces (all over)
+
+ #create floppy disk image
+ debug "Creating floppy disk: filename=${filename} size=${size}"
+ qemu-img create -f raw $filename "${size}M"> /dev/null 2>&1
qemu-img might not be in found. use ./qemu-img
+ if [ $? != 0 ]; then die "Unable to create disk image: $filename"; fi
+
+ mkfs.msdos $filename
+ if [ $? != 0 ]; then die "Unable to format disk image: $filename"; fi
+
+ #mount floppy disk image
+ mp=$(mktemp -d floppytmp.XXXXXX)
+ mount -t vfat -v -o loop $filename $mp
+ if [ $? != 0 ]; then die "Unable to mount disk image: $filename to: $mp"; fi
+
+ #copy config file to disk
+ if [[ "$CONFIG" =~ \.ks\$ ]] || [[ "$CONFIG" =~ \.cfg\$ ]]; then
+ cp $CONFIG $mp/ks.cfg
+ elif [[ "$CONFIG" =~ \.sif\$ ]]; then
+ cp $CONFIG $mp/winnt.sif
+ else
+ cp $CONFIG $mp
+ fi
+
+ #unmount floppy
+ df | grep $mp> /dev/null 2>&1&& umount -v $mp
+ rmdir $mp
+}
+
+
+# setup pxeboot evironment
+# $PXE - iso image
+# $ARGS - kernel arguments
+setup_pxeboot () {
+ local workdir="images/$KVM_TEST_tftp"
+ local iso=$PXE
+ local pxedefault=$workdir/pxelinux.cfg/default
+ local pxelinux="/usr/lib/syslinux/pxelinux.0"
+ local cdlocation="images/pxeboot/"
+
+ # Check pxelinux.0 exists.
+ if [ ! -f /usr/share/syslinux/pxelinux.0 -a ! -f /usr/lib/syslinux/pxelinux.0 ]; then
+ die "Warning: pxelinux.0 not found, Make sure syslinux or pxelinux is installed on this system."
+ fi
+
+ #create clean tftpboot dir
+ if [ -d $workdir ]; then
+ log "$ME: subdirectory $workdir exists already. overwriting"
+ rm -rf $workdir
+ fi
+
+ mkdir -p $workdir/pxelinux.cfg
+
+ # pxelinux bootloader.
+ if [ -f /usr/share/syslinux/pxelinux.0 ]; then
+ cp /usr/share/syslinux/pxelinux.0 $workdir
+ elif [ -f /usr/lib/syslinux/pxelinux.0 ]; then
+ cp /usr/lib/syslinux/pxelinux.0 $workdir
+ else
+ die "Warning: pxelinux.0 not found, Make sure syslinux or pxelinux is installed on this system."
+ fi
+
+ # get vmlinz and initrd form image
+ mp=$(mktemp -d cdtmp.XXXXXX)
+ mount -t iso9660 -v -o ro,loop "$iso" $mp
+ if [ $? != 0 ]; then die "Unable to mount cd image: $iso to: $mp"; fi
+
+
+ # Does it look like an ISO?
+ if [ ! -d $mp/$cdlocation ]; then
+ die "The ISO image does not look like a ISO image to me."
+ fi
+
+ cp $mp/$cdlocation/initrd.img $mp/$cdlocation/vmlinuz $workdir
+ df | grep $mp> /dev/null 2>&1&& umount -v $mp
+ rmdir $mp
+
+ # set default kernel arguments if none were provided
+ if [ -z "$ARGS" ]; then
+ local $ARGS=""
Should be ARGS=""
+ fi
+
+ local definition="DEFAULT pxeboot"
+ definition="${definition}\nTIMEOUT 20"
+ definition="${definition}\nPROMPT 0"
+ definition="${definition}\nLABEL pxeboot"
+ definition="${definition}\n KERNEL vmlinuz"
+ definition="${definition}\n APPEND initrd=initrd.img $ARGS"
+
+ debug "pxeboot definition=\n${definition}"
+ printf "${definition}\n"> $pxedefault
+}
+
+CONFIG=$KVM_TEST_unattended_file
+NAME=$KVM_TEST_image
+PXE=isos/$KVM_TEST_cdrom
+ARGS=$KVM_TEST_kernel_args
I think it would be nice to get all KVM_TEST_ params here and pass them as
arguments to local (this file) functions.
+
+
+# check to see we are root
+if [ $( id -u ) -ne 0 ]; then
+ die "Must run as root"
+fi
+
+# Require "CONFIG_FILE"
+if [[ ! -e $CONFIG ]]; then
+ die "no unattended config file found: "$CONFIG""
+fi
+
+log "using unattended config file: $CONFIG"
+
+# create teh floppy image
typo: the.
Regards,
Uri.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html