diff options
author | Dirk von Suchodoletz | 2009-02-27 00:12:52 +0100 |
---|---|---|
committer | Dirk von Suchodoletz | 2009-02-27 00:12:52 +0100 |
commit | 2b91732ec30ee20c6533d0d9719ce0dd83fe3306 (patch) | |
tree | 08035a656e76e5a44221f274e6cefb8abef2a749 /os-plugins/plugins/vmchooser/files/run-virt.sh | |
parent | fix dirks typo (diff) | |
download | core-2b91732ec30ee20c6533d0d9719ce0dd83fe3306.tar.gz core-2b91732ec30ee20c6533d0d9719ce0dd83fe3306.tar.xz core-2b91732ec30ee20c6533d0d9719ce0dd83fe3306.zip |
Cleanups, mini-fix and comments ...
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2651 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/plugins/vmchooser/files/run-virt.sh')
-rw-r--r-- | os-plugins/plugins/vmchooser/files/run-virt.sh | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index 8ba8ea75..005bf8f8 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -32,57 +32,58 @@ xml=$1 # Read needed variables from XML file ############################################################################### -# file name of the image +# File name of the image imagename=$(grep -io "<image_name param=.*\"" ${xml} | awk -F "\"" '{ print $2 }') diskfile=$imagename [ -e $diskfile ] || { echo -e "\n\tImage file $diskfile not found!"; exit 1; } -# short description of the image (as present in the vmchooser menu line) +# Short description of the image (as present in the vmchooser menu line) short_description=$(grep -o "short_description param=.*\"" ${xml} | \ sed -e "s/&.*;/; /g" | awk -F "\"" '{print $2}') -# if ${short_description} not defined use ${image_name} +# If ${short_description} not defined use ${image_name} short_description=${short_description:-"${image_name}"} displayname=${short_description} -# type of virtual machine to run +# Type of virtual machine to run virt_mach=$(grep -o "virtualmachine param=.*\"" ${xml} | \ sed -e "s/&.*;/; /g" | awk -F "\"" '{print $2}') -# make a guess from the filename extension if ${virt_mach} is empty (not set +# Make a guess from the filename extension if ${virt_mach} is empty (not set # within the xml file) if [ -z ${virt_mach} ] ; then - case "${imagename##*.}" in - vmdk|VMDK) + case "$(echo ${imagename##*.}|tr [A-Z] [a-z])" in + vmdk) virt_mach="vmware" ;; - img|IMG|qcow*|QCOW*) + img|qcow*) virt_mach="qemukvm" ;; - vbox|VBOX) - virt_mach="qemukvm" + vbox) + virt_mach="virtualbox" + ;; + *) + echo "Unknown image type, bailing out" ;; esac fi -# definition of the client system +# Definition of the client system vmostype=$(grep -io "<os param=.*\"" ${xml} | awk -F "\"" '{ print $2 }') -# definition of the networking the client system is connected to +# Definition of the networking the client system is connected to network_kind=$(grep -io "<network param=.*\"" ${xml} | awk -F "\"" '{ print $2 }') -# serial port defined (e.g. "ttyS0" or "autodetect") +# Serial port defined (e.g. "ttyS0" or "autodetect") serial=$(grep -io "<serial port=.*\"" ${xml} | awk -F "\"" '{ print $2 }') -# declaration of default variables +# Declaration of default variables ############################################################################### -# standard variables - -# get total amount of memory installed in your machine +# Get total amount of memory installed in your machine totalmem=$(expr $(grep -i "memtotal" /proc/meminfo | awk '{print $2}') / 1024) -# configuring ethernet mac address: first four bytes are fixed (00:50:56:0D) +# Configuring ethernet mac address: first four bytes are fixed (00:50:56:0D) # the last two bytes are taken from the first local network adaptor of the host # system mac=$(/sbin/ifconfig eth0 | grep eth0 | sed -e "s/ //g" \ @@ -90,42 +91,38 @@ mac=$(/sbin/ifconfig eth0 | grep eth0 | sed -e "s/ //g" \ echo "$totalmem, $mac" -# virtual fd/cd/dvd and drive devices, floppy b: for configuration -#floppya is always false, if we have a floppy device or not isn't -#important. +# Virtual fd/cd/dvd and drive devices, floppy b: for configuration file (xml) floppya="FALSE" floppyb="TRUE" floppybname="/etc/vmware/loopimg/fd.img" cdr_1="FALSE" cdr_2="FALSE" -# ide is expected default, test for the virtual disk image type should +# IDE is expected default, test for the virtual disk image type should # be done while creating the runscripts ... ide="TRUE" scsi="FALSE" hddrv="ide" -# display resolution +# Display resolution within the host system hostres=$(xvidtune -show 2>/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" +# Set hostname: using original hostname and adding string "-vm" hostname="VM-${HOST}" -# functions used throughout the script +# Functions used throughout the script ############################################################################### -# check for files +# Check for important files used 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}') @@ -144,7 +141,7 @@ filecheck () exit 1 fi - # readable? + # readable by calling user if ! [ -r "${diskfile}" >/dev/null 2>&1 \ -o -r "${diskfile}" >/dev/null 2>&1 ]; then writelog "Vmware Image Problem:\c " @@ -168,35 +165,35 @@ filecheck () fi } -# function to write to stdout and logfile +# Function to write to stdout and logfile writelog () { - # write to stdout + # Write to stdout echo -e "$1" - # log into file + # Log into file echo -e "$1" >>run-virt.log } -# setup the rest of the environment and run the virtualization tool just confi- +# 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 +# Logo for console cat <<EOL - .----.--.--.-----.--.--.--------.--.--.--.---.-.----.-----. - | _| | | | | | | | | | _ | _| -__| - |__| |_____|__|__|\___/|__|__|__|________|___._|__| |_____| - Script for preparing virtual machine environment ... + .----.--.--.-----.--.--.--.----.-----. + | _| | | | | | | _|_ _| + |__| |_____|__|__|\___/|__|__| |_| +OpenSLX script for preparing virtual machine environment ... EOL -# adjust volume +# Adjust sound volume writelog "Unmuting sound...\c " amixer -q sset Master 28 unmute 2>/dev/null amixer -q sset PCM 28 unmute 2>/dev/null @@ -204,14 +201,14 @@ 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 +# Copy guest configuration (with added information) 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 +# Check if virtual machine container file exists filecheck - -# get all virtual machine specific stuff from the respective include file +# 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} |