From ebd0e340cd7be0779e0530fedc1f0e7aab76b779 Mon Sep 17 00:00:00 2001
From: Julien Bonjean <julien@bonjean.info>
Date: Fri, 15 May 2009 10:57:05 -0400
Subject: [PATCH] [#1422] Added automatic VM shutdown when building on more
 than one VM

---
 tools/build-system/launch-build-machine.sh | 36 +++++++++++++---------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/tools/build-system/launch-build-machine.sh b/tools/build-system/launch-build-machine.sh
index 30f47ec621..6b3570db38 100755
--- a/tools/build-system/launch-build-machine.sh
+++ b/tools/build-system/launch-build-machine.sh
@@ -7,7 +7,7 @@
 # Author: Julien Bonjean (julien@bonjean.info) 
 #
 # Creation Date: 2009-04-20
-# Last Modified: 2009-05-14 17:57:35 -0400
+# Last Modified: 2009-05-15 10:50:55 -0400
 #####################################################
 
 #
@@ -89,20 +89,6 @@ echo "    | SFLPhone build system |"
 echo "    \\***********************/"
 echo
 
-cd ${SCRIPTS_DIR}
-
-if [ "$?" -ne "0" ]; then
-        echo " !! Cannot cd to working directory"
-        exit -1
-fi
-
-WHO=`whoami`
-
-if [ "${WHO}" != "${USER}" ]; then
-        echo "!! Please use user ${USER} to run this script"
-        exit -1;
-fi
-
 for PARAMETER in $*
 do
 	case ${PARAMETER} in
@@ -145,6 +131,26 @@ do
 	esac
 done
 
+# if more than one VM will be launched, automatically stop running VMs
+if [ "${#MACHINES[@]}" -gt "1" ]; then
+	VBoxManage list runningvms | tail -n +5 | awk '{print $1}' | xargs -i VBoxManage controlvm {} poweroff
+fi
+
+# change to working directory
+cd ${SCRIPTS_DIR}
+
+if [ "$?" -ne "0" ]; then
+        echo " !! Cannot cd to working directory"
+        exit -1
+fi
+
+WHO=`whoami`
+
+if [ "${WHO}" != "${USER}" ]; then
+        echo "!! Please use user ${USER} to run this script"
+        exit -1;
+fi
+
 # logging
 mkdir ${PACKAGING_RESULT_DIR} 2>/dev/null
 if [ ${DO_LOGGING} ]; then
-- 
GitLab