diff options
author | Michael Janczyk | 2010-04-21 20:18:30 +0200 |
---|---|---|
committer | Michael Janczyk | 2010-04-21 20:18:30 +0200 |
commit | 11e4e00b3464c75f6540ed74fa7bcf4663ec047c (patch) | |
tree | cad334a94a15cd1c919761b62f3b20efc14c826e /os-plugins | |
parent | Merge branch 'master' into vmgrid (diff) | |
download | core-11e4e00b3464c75f6540ed74fa7bcf4663ec047c.tar.gz core-11e4e00b3464c75f6540ed74fa7bcf4663ec047c.tar.xz core-11e4e00b3464c75f6540ed74fa7bcf4663ec047c.zip |
clean exit and port redirect bugfix and cosmetics
Diffstat (limited to 'os-plugins')
-rw-r--r-- | os-plugins/plugins/virtualbox/files/run-virt.include | 32 | ||||
-rw-r--r-- | os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 25 |
2 files changed, 34 insertions, 23 deletions
diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 119b1e16..2091f79e 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -70,7 +70,7 @@ if echo ${imgname} | grep -qiE "vdi|vmdk|vhd" && [ ${diskless} -eq 0 ]; then imgfmt=$(echo ${imgname##*.} | tr [a-z] [A-Z]) elif [ ${diskless} -eq 0 ]; then writelog "${imgname} is not a valid image format (vdi|vmdk|vhd), exiting!" - exit 1 + cleanexit 1 fi # TODO: maybe rewrite, to reduce checks, merge it with network option, @@ -92,7 +92,7 @@ case "${vmostype}" in if [ ${vtflag} -ne 1 ]; then writelog "You are trying to boot a 64 bit OS without a VT enabled CPU" writelog "This is not supported, exiting!" - exit 1 + cleanexit 1 fi # check if host is only 32 bit, then use only 1 cpu (only 1 supported) if echo "${host_arch}" | grep -qE "i.86"; then @@ -138,12 +138,12 @@ if echo "${imgmode}" | grep -q rw; then if [ -e "${vmpath}.lock" ]; then writelog "This rw image is already in use: ${vmpath}, exiting!" writelog "Remove lock if you are sure that this is not the case" - exit 1 + cleanexit 1 # image rw? elif ! [ -w ${vmpath} ]; then writelog "You defined mode rw, but image ${vmpath} is not rw! \c" writelog "Please correct, exiting!" - exit 1 + cleanexit 1 fi # add lock touch "${vmpath}.lock" @@ -199,7 +199,7 @@ else if [ "${mem}" -lt "256" ] || [ "${hostmem}" -lt "256" ]; then writelog "Memory out of range: ${mem} MB (guest) / ${hostmem} MB (host)!" writelog "Min. 256 MB for host and guest!" - exit 1 + cleanexit 1 fi fi @@ -244,7 +244,7 @@ case ${boot} in else writelog "${virtualbox_tftpdir}/pxelinux.0 not found!" writelog "Network boot won't work, exiting!" - exit 1 + cleanexit 1 fi for i in $(ls ${virtualbox_tftpdir}); do ln -sf ${virtualbox_tftpdir}/${i} ${confdir}/TFTP/${i} @@ -258,7 +258,7 @@ case ${boot} in esac # external GUI -vrdpport="590${VM_ID}" +vrdpport=${remotedesktopport} # TODO: nur bei vmchooser # TODO: most of the following does not make much sense yet ... @@ -295,7 +295,9 @@ writelog "Diskimage:" writelog "\tMachine UUID:\t\t$machineuuid" [ ${diskless} -eq 0 ] && writelog "\tDisk UUID:\t\t$diskuuid" writelog "Virtual Hardware:" -[ ${vtflag} -eq 1 ] && writelog "\tVT enabled CPU" +writelog "\tCPU cores:\t\t${cpu_cores}\c" +[ ${vtflag} -eq 0 ] && writelog "" +[ ${vtflag} -eq 1 ] && writelog " (VT enabled CPU)" writelog "\tGuest RAM:\t\t${mem} MB" # echo nur wenn hostmem gesetzt [ -n "${hostmem}" ] && writelog "\tHost RAM:\t\t${hostmem} MB" @@ -341,8 +343,9 @@ if [ ${diskless} -eq 1 ]; then fi # define redirects -if [ -n "${redirects}" ]; then +if [ ${redirects} -ge 1 ]; then (( i=1 )) + writelog "\tGuest redirects:\t\c" while [ ${i} -le ${redirects} ]; do extradataitem='<ExtraDataItem name="VBoxInternal/Devices' extradataitem="${extradataitem}/${network_card}/0/LUN#0/Config" @@ -351,10 +354,13 @@ if [ -n "${redirects}" ]; then extradatahostport="HostPort\" value=\"${redirect_hport[$i]}\"/>" extradataguestport="GuestPort\" value=\"${redirect_gport[$i]}\"/>" sed -i "s,</ExtraData>, ${extradataitem}${extradataguestport}\n\ - ${extradataitem}${extradatahostport}\n\ - ${extradataitem}${extradataprotocol}\n\ - </ExtraData>," "${machconfig}" - writelog "\tGuest ${redirect_name[$i]} port:\t\t${redirect_hport[$i]}" + ${extradataitem}${extradatahostport}\n\ + ${extradataitem}${extradataprotocol}\n\ + </ExtraData>," "${machconfig}" + writelog "${tabspace}${redirect_name[$i]} port: ${redirect_hport[$i]}" + tabspace='\t\t\t\t' + (( i=$i+1 )) + done fi ################################################################################ diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 4fdd4af0..9b9adb44 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -49,6 +49,17 @@ writelog () { echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log } +# remove config dirs when exit +cleanexit () { + if echo "${RMDIRS}" 2>/dev/null | grep -q ${vmgrid_virt}; then + writelog "${vmgrid_virt} exited. Cleanning up... \c" + rm -rf ${RMDIRS} >/dev/null 2>&1 + writelog "done" + fi + + exit "$1" +} + ################################################################################ ### Get XML file and dir ################################################################################ @@ -349,6 +360,7 @@ ide="TRUE" scsi="FALSE" hddrv="ide" audio="false" +remotedesktopport="590${VM_ID}" # add rw share sharepath="${vmgrid_rwmnt}/folders/${vm_shortname}" @@ -384,7 +396,7 @@ fi if [ ${headless} -eq 0 ]; then if [ -z "${VIRTCMD}" ]; then writelog "Grapical mode not available, exiting!" - exit 1 + cleanexit 1 fi writelog "Starting ${vmgrid_virt} in graphical mode..." ${VIRTCMD} ${VIRTCMDOPTS} 2>/dev/null @@ -394,7 +406,7 @@ elif [ -n "${VIRTCMDHL}" ]; then ${VIRTCMDHL} ${VIRTCMDOPTSHL} 2>/dev/null else writelog "${vmgrid_virt}: No headless mode defined, exiting!" - exit 1 + cleanexit 1 fi # postrun for scripts after virtualization finishes @@ -402,12 +414,5 @@ if [ -n "${POSTRUN}" ]; then eval ${POSTRUN} >/dev/null 2>&1 fi -# remove config dirs when finished -if echo "${RMDIRS}" 2>/dev/null | grep -q ${vmgrid_virt}; then - writelog "${vmgrid_virt} exited. Cleanning up... \c" - rm -rf ${RMDIRS} >/dev/null 2>&1 - writelog "done" -fi - -echo -e "Bye." +cleanexit 0 exit 0 |