summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/vmgrid/files/run-vmgrid.sh
diff options
context:
space:
mode:
authorMichael Janczyk2010-04-28 15:33:15 +0200
committerMichael Janczyk2010-04-28 15:33:15 +0200
commit6ee8363caa02411cbc6851e5f8ecfa407643e8f0 (patch)
tree99fde6e48f1f51e66b51cabad7f6c6945c9ad8cb /os-plugins/plugins/vmgrid/files/run-vmgrid.sh
parentdisable audio when using vmgrid (diff)
downloadcore-6ee8363caa02411cbc6851e5f8ecfa407643e8f0.tar.gz
core-6ee8363caa02411cbc6851e5f8ecfa407643e8f0.tar.xz
core-6ee8363caa02411cbc6851e5f8ecfa407643e8f0.zip
clean exit added + port redirects now via xml file
Diffstat (limited to 'os-plugins/plugins/vmgrid/files/run-vmgrid.sh')
-rw-r--r--os-plugins/plugins/vmgrid/files/run-vmgrid.sh46
1 files changed, 34 insertions, 12 deletions
diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh
index a684310b..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
################################################################################
@@ -289,11 +300,28 @@ vmostype=$(grep -io '<os param=.*"' ${xmlfile} | awk -F '"' '{ print $2 }' \
| tr [A-Z] [a-z])
# definition of the networking the client system is connected to
-network_kind=$(grep -io 'network param=.*"' ${xmlfile} \
+network_kind=$(grep -io '<network param=.*"' ${xmlfile} \
| awk -F '"' '{ print $2 }' | tr [A-Z] [a-z])
-network_card=$(grep -io 'netcard param=.*"' ${xmlfile} \
+network_card=$(grep -io '<netcard param=.*"' ${xmlfile} \
| awk -F '"' '{ print $2 }'| tr [A-Z] [a-z])
+# define redirects
+redirects=$(grep -ic '<redirect name=.*"' ${xmlfile})
+[ -z "${redirects}" ] && redirects=0
+(( i=1 ))
+while [ ${i} -le ${redirects} ]; do
+ # get only the $i-th line
+ redirect_name[$i]=$(grep -m ${i} -io '<redirect.*' ${xmlfile} | tail -n 1 \
+ | grep -o "name=\".*" | awk -F '"' '{ print $2 }')
+ redirect_proto[$i]=$(grep -m ${i} -io '<redirect.*' ${xmlfile} | tail -n 1 \
+ | grep -o "proto=\".*" | awk -F '"' '{ print $2 }')
+ redirect_hport[$i]=$(grep -m ${i} -io '<redirect.*' ${xmlfile} | tail -n 1 \
+ | grep -o "hostport=\".*" | awk -F '"' '{ print $2 }')
+ redirect_gport[$i]=$(grep -m ${i} -io '<redirect.*' ${xmlfile} | tail -n 1 \
+ | grep -o "guestport=\".*" | awk -F '"' '{ print $2 }')
+ (( i=$i+1 ))
+done
+
writelog "\tVirtualization:\t\t$xmlvirt"
writelog "\tVM name:\t\t$vm_name"
writelog "\tVM short name:\t\t$vm_shortname"
@@ -332,6 +360,7 @@ ide="TRUE"
scsi="FALSE"
hddrv="ide"
audio="false"
+remotedesktopport="590${VM_ID}"
# add rw share
sharepath="${vmgrid_rwmnt}/folders/${vm_shortname}"
@@ -367,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
@@ -377,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
@@ -385,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