From 1494db66df318d2417d1c36605aec49ebb24b2b8 Mon Sep 17 00:00:00 2001 From: Dirk von Suchodoletz Date: Tue, 17 Feb 2009 20:17:53 +0000 Subject: General run-virt.sh script called by vmchooser (see r2583 too). git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2590 95ad53e4-c205-0410-b2fa-d234c58c8868 --- os-plugins/plugins/vmchooser/files/run-virt.sh | 167 +++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 os-plugins/plugins/vmchooser/files/run-virt.sh (limited to 'os-plugins/plugins/vmchooser/files/run-virt.sh') diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh new file mode 100644 index 00000000..ac17d391 --- /dev/null +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -0,0 +1,167 @@ +#!/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. +# ----------------------------------------------------------------------------- + +# The PATH... +export PATH="${PATH}:/var/X11R6/bin:/usr/X11R6/bin" + +# Read needed variables from XML file +################################################################################ +xml=$1 + +# 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" + #TODO: don't understand the sence in it + noimage=$(echo ${filecheck} | grep -i "no such file or directory" | wc -l) + rightsfile=${diskfile} + + # check if link + # TODO: mistake with 2nd rightsfile if its in another directory? + if [ -L "${diskfile}" ]; then + # take link target + rightsfile=$(ls -lh ${diskfile} 2>&1 | awk -F "-> *" '{print $2}') + rightsfile=${vmdir}/${rightsfile} + filecheck=$(LANG=us ls -lh ${rightsfile} 2>&1) + fi + + # does file exist + if [ "${noimage}" -ge "1" ]; then + writelog "Vmware Image Problem:\c " + writelog "\tThe image you've specified doesn't exist." + writelog "Filecheck says:\c " + writelog "\t\t${diskfile}:\n\t\t\tNo such file or directory" + writelog "Hint:\c " + writelog "\t\t\tCompare spelling of the image with your options.\n" + exit 1 + fi + + # readable? + if ! [ -r "${diskfile}" >/dev/null 2>&1 \ + -o -r "${diskfile}" >/dev/null 2>&1 ]; then + writelog "Vmware Image Problem:\c " + writelog "\tThe image you've specified has wrong rights." + writelog "Filecheck says:\t\t$(echo ${filecheck} \ + | awk '{print $1" "$3" "$4}') ${rightsfile}" + writelog "Hint:\t\t\tChange rights with: chmod a+r ${rightsfile}\n" + exit 1 + fi + + # writable (for persistent-mode)? + if ! [ -w "${diskfile}" >/dev/null 2>&1 \ + -o -w "${diskfile}" >/dev/null 2>&1 ] \ + && [ "${np}" = "independent-persistent" ]; then + writelog "Vmware Image Problem:\c " + writelog "\tThe image you have specified has wrong rights." + writelog "Filecheck says:\t\t$(echo ${filecheck} \ + | awk '{print $1" "$3" "$4}') ${rightsfile}" + writelog "Hint:\t\t\tUse nonpersistent-mode or change rights to rw\n" + exit 1 + fi +} + + +# setup the rest of the environment and run the virtualization tool just confi- +# gured +################################################################################ + +# adjust volume +writelog "Unmuting sound...\c " +amixer -q sset Master 28 unmute 2>/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 + +# get all virtual machine specific stuff from the respective include file +. /etc/opt/openslx/run-${virt_mach}.include +${VIRTCMD} ${VIRTCMDOPTS} + +writelog "Bye.\n" +exit 0 -- cgit v1.2.3-55-g7522