All of lore.kernel.org
 help / color / mirror / Atom feed
From: Uri Lublin <uril@redhat.com>
To: David Huff <dhuff@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] added unattended.sh script
Date: Sun, 28 Jun 2009 14:15:14 +0300	[thread overview]
Message-ID: <4A4750C2.3040705@redhat.com> (raw)
In-Reply-To: <1245361860-26726-4-git-send-email-dhuff@redhat.com>

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@redhat.com>
> +#	Darryl L. Pierce<dpierce@redhat.com>
> +#
> +# 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.

  reply	other threads:[~2009-06-28 11:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-18 21:50 [KVM_AUTOTEST] unattended installs take 2 David Huff
2009-06-18 21:50 ` [PATCH] Added floppy and tftp options to qemu command David Huff
2009-06-18 21:50 ` [PATCH] modified config file to run unattended install David Huff
2009-06-18 21:50 ` [PATCH] added unattended.sh script David Huff
2009-06-28 11:15   ` Uri Lublin [this message]
2009-06-18 21:50 ` [PATCH] Added two sample unattended config files, Fedora and Windows David Huff
2009-06-19  7:07   ` Yaniv Kaul
2009-06-28 10:14   ` Uri Lublin
2009-06-18 21:51 ` [PATCH] Modified boot test in kvm_test.py David Huff
2009-06-19  7:01 ` [KVM_AUTOTEST] unattended installs take 2 Yaniv Kaul
2009-06-22  5:10 ` Lucas Meneghel Rodrigues
2009-06-22 13:13   ` David Huff
2009-06-22 16:01     ` Lucas Meneghel Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A4750C2.3040705@redhat.com \
    --to=uril@redhat.com \
    --cc=dhuff@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.