diff options
author | Michael Janczyk | 2010-04-06 20:01:24 +0200 |
---|---|---|
committer | Michael Janczyk | 2010-04-06 20:01:24 +0200 |
commit | e437b8813f2a84ccffa3a75ba1f534b38ce72b9c (patch) | |
tree | fcc8c42ec290da4f343797d4eee4c03087fd01df /os-plugins/plugins/vmchooser/files/run-virt.sh | |
parent | Adding the runlevel linker again (having the upstart component for newer (diff) | |
download | core-e437b8813f2a84ccffa3a75ba1f534b38ce72b9c.tar.gz core-e437b8813f2a84ccffa3a75ba1f534b38ce72b9c.tar.xz core-e437b8813f2a84ccffa3a75ba1f534b38ce72b9c.zip |
cumulative commit of local branch, many changes regarding virtualization
Diffstat (limited to 'os-plugins/plugins/vmchooser/files/run-virt.sh')
-rw-r--r-- | os-plugins/plugins/vmchooser/files/run-virt.sh | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index 5733ee41..9bc31396 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -40,13 +40,14 @@ xml=$1 ################################################################################ # File name of the image -imagename=$(grep -io "<image_name param=.*\"" ${xml} | \ +imgname=$(grep -io "<image_name param=.*\"" ${xml} | \ awk -F "\"" '{ print $2 }') case ${xml} in /tmp/*) # we do not need folder name as it is already included by vmchooser - diskfile=$imagename + diskfile=$imgname + imgname=$(basename ${imgname}) ;; *) # Path to the image @@ -54,18 +55,25 @@ case ${xml} in [ -z $imgpath ] && \ { imgpath=$(readlink -f $xml); imgpath=${imgpath%/*.xml}; } # Diskfile is file including absolute path to it - diskfile=$imgpath/$imagename + diskfile=$imgpath/$imgname ;; esac +# TODO: change to new var vmpath, remove diskfile afterwards +vmpath=$diskfile [ -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=$(grep -o "short_description param=.*\"" ${xml} | \ +vm_name=$(grep -o "short_description param=.*\"" ${xml} | \ sed -e "s/&.*;/; /g" | awk -F "\"" '{print $2}') # If ${short_description} not defined use ${image_name} -short_description=${short_description:-"${image_name}"} -displayname=${short_description} +# if ${vm_name} not defined use ${imgname} +vm_name=${vm_name:-"${imgname%.*}"} +# define vm_shortname since vm_name can be very long +vm_shortname=$(echo ${imgname%.*} | sed -e "s, ,-,g") +displayname=${vm_name} +# remove blanks +vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") # Type of virtual machine to run virt_mach=$(grep -o "virtualmachine param=.*\"" ${xml} | \ @@ -74,7 +82,7 @@ virt_mach=$(grep -o "virtualmachine param=.*\"" ${xml} | \ # Make a guess from the filename extension if ${virt_mach} is empty (not set # within the xml file) if [ -z ${virt_mach} ] ; then - case "$(echo ${imagename##*.}|tr [A-Z] [a-z])" in + case "$(echo ${imgname##*.}|tr [A-Z] [a-z])" in vmdk) virt_mach="vmware" ;; @@ -104,6 +112,9 @@ parallel=$(grep -io '<parport param=.*"' ${xml} | awk -F '"' '{ print $2 }') # Declaration of default variables ############################################################################### +# VM-ID static (0D) +VM_ID="00" + # cpu cores cpu_cores="${cpu_cores}" @@ -114,9 +125,15 @@ totalmem=$(expr $(grep -i "memtotal" /proc/meminfo | awk '{print $2}') / 1024) permem=60 mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) -# 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 +# configuring ethernet mac address: first 3 bytes are fixed (00:50:56) +# 4th byte is the VM-ID (0D) +# last two bytes are taken from the bridge of the host +# define one MAC per guest +macguestpart="00:50:56:${VM_ID}" +machostpart=$($(which ifconfig) br0 | grep br0 | sed -e "s/ //g" | \ + awk -F ":" '{print $(NF-1)":"$NF}') +macaddr=$(echo "${macguestpart}:${machostpart}" | tr [a-z] [A-Z]) +#TODO: remove when vmware modified mac=$(/sbin/ifconfig eth0 | grep eth0 | sed -e "s/ //g" \ | awk -F ":" '{print $(NF-1)":"$NF}') @@ -144,6 +161,10 @@ ide="TRUE" scsi="FALSE" hddrv="ide" +# add rw share +sharepath="${HOME}" +sharename="home" + # Display resolution within the host system hostres=$(xvidtune -show 2>/dev/null| grep -ve "^$") xres=$(echo "${hostres}" | awk '{print $3}') @@ -222,11 +243,11 @@ writelog () # Logo for console cat <<EOL - - .----.--.--.-----.--.--.--.----.-----. - | _| | | | | | | _|_ _| - |__| |_____|__|__|\___/|__|__| |_| -OpenSLX script for preparing virtual machine environment ... + __ __ + .----.--.--.-----.___.--.--.|__|.----.| |_ + | _| | | |___| | || || _|| _| + |__| |_____|__|__| \___/ |__||__| |____| + OpenSLX virtual machine environment preparation script ... EOL @@ -243,15 +264,17 @@ writelog "finished\n" # Copy guest configuration (with added information) config.xml to be accessed # via virtual floppy # fixme -> to be changed (vmchooser adapts the file content!?) -echo "Please fix the config.xml generation" +#TODO: wozu echo? +#echo "Please fix the config.xml generation" cp ${xml} ${PLUGINCONFDIR}/fd-loop/config.xml # Check if virtual machine container file exists -filecheck +#filecheck # Get all virtual machine specific stuff from the respective include file -if [ -e ${PLUGINCONFROOT}/${virt_mach}/run-${virt_mach}.include ] ; then - . ${PLUGINCONFROOT}/${virt_mach}/run-${virt_mach}.include +if [ -e ${PLUGINCONFROOT}/${virt_mach}/run-virt.include ] ; then + self=${virt_mach} + . ${PLUGINCONFROOT}/${virt_mach}/run-virt.include # start a windowmanager for easier handling # (expect problems /w windows opening in background /w vmware without wm) for dm in xfwm4 metacity openbox blackbox kwin fvwm2 ; do @@ -266,7 +289,7 @@ if [ -e ${PLUGINCONFROOT}/${virt_mach}/run-${virt_mach}.include ] ; then fi done ${VIRTCMD} ${VIRTCMDOPTS} - writelog "Bye.\n" + writelog "Bye." exit 0 else writelog "Failed because of missing ${virt_mach} plugin." |