#!/bin/bash # ----------------------------------------------------------------------------- # Copyright (c) 2007..2009 - RZ Uni FR # Copyright (c) 2007..2009 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING # # If you have any feedback please consult http://openslx.org/feedback and # send your suggestions, praise, or complaints to feedback@openslx.org # # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # run-virt.sh # - This is the generic wrapper for the several virtualization solutions. # The idea is to setup a set of variables used by at least two different # tools and then include the specific plugin which configures the speci- # fied virtualization tool. # ----------------------------------------------------------------------------- # Sanity checks ############################################################################### # check for running in graphical environment otherwise no much use here [ -z "$DISPLAY" ] && echo -e "\n\tStart only within a graphical desktop!\n" \ && exit 1 # test if the xml path/file is valid (gotten via commandline first parameter) xml=$1 [ -e "${xml}" ] || { echo -e "\n\tNo XML file given!\n"; exit 1; } # path to the xml file(just take the path to the xml file) imagepath=${xml%/*} # Read needed variables from XML file ############################################################################### # file name of the image imagename=$(grep -i "/dev/null| grep -ve "^$") xres=$(echo "${hostres}" | awk '{print $3}') yres=$(echo "${hostres}" | awk '{print $7}') # set hostname: using original hostname and adding string "-vm" hostname="VM-${HOST}" # name of the container (virtual machine image file) diskfile="${vmdir}/${imagename}" # functions used throughout the script ############################################################################### # check for files filecheck () { #filecheck=$(LANG=us ls -lh ${diskfile} 2>&1) #writelog "Filecheck:\n${filecheck}\n" : } # function to write to stdout and logfile writelog () { # write to stdout echo -e "$1" # log into file echo -e "$1" >>run-virt.log } # setup the rest of the environment and run the virtualization tool just confi- # gured ################################################################################ # The PATH... export PATH="${PATH}:/var/X11R6/bin:/usr/X11R6/bin" # logo for console cat </dev/null amixer -q sset PCM 28 unmute 2>/dev/null amixer -q sset Headphone 28 unmute 2>/dev/null amixer -q sset Front 0 mute 2>/dev/null writelog "finished\n" # copy guest configuration config.xml to be accessed via virtual floppy cp ${xml} /var/lib/virt/vmchooser/fd-loop/config.xml # check if virtual machine container file exists filecheck echo ${virt_mach} # get all virtual machine specific stuff from the respective include file if [ -e /etc/opt/openslx/run-${virt_mach}.include ] ; then . /etc/opt/openslx/run-${virt_mach}.include ${VIRTCMD} ${VIRTCMDOPTS} writelog "Bye.\n" exit 0 else writelog "Failed because of missing ${virt_mach} plugin." exit 1 fi