diff options
-rwxr-xr-x | xci/scripts/vm/build-dib-os.sh | 2 | ||||
-rwxr-xr-x | xci/scripts/vm/start-new-vm.sh | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/xci/scripts/vm/build-dib-os.sh b/xci/scripts/vm/build-dib-os.sh index 78eaff2d..2f788006 100755 --- a/xci/scripts/vm/build-dib-os.sh +++ b/xci/scripts/vm/build-dib-os.sh @@ -7,7 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -set -e +set -ex # This only works on ubuntu hosts lsb_release -i | grep -q -i ubuntu || { echo "This script only works on Ubuntu distros"; exit 1; } diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh index c374071c..991637a6 100755 --- a/xci/scripts/vm/start-new-vm.sh +++ b/xci/scripts/vm/start-new-vm.sh @@ -8,7 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -set -e +set -ex lsb_release -i | grep -q -i ubuntu || { echo "This script only works on Ubuntu distros"; exit 1; } @@ -38,8 +38,18 @@ declare -r BASE_PATH=$(dirname $(readlink -f $0) | sed "s@/xci/.*@@") echo "Preparing new virtual machine '${NAME}'..." # NOTE(hwoarang) This should be removed when we move the dib images to a central place +_retries=20 echo "Building '${OS}' image (tail build.log for progress and failures)..." -$BASE_PATH/xci/scripts/vm/build-dib-os.sh ${OS} > build.log 2>&1 +while [[ $_retries -ne 0 ]]; do + if pgrep build-dib-os.sh &>/dev/null; then + echo "There is another dib process running... ($_retries retries left)" + sleep 60 + (( _retries = _retries - 1 )) + else + $BASE_PATH/xci/scripts/vm/build-dib-os.sh ${OS} > build.log 2>&1 + break + fi +done [[ ! -e ${OS}.qcow2 ]] && echo "${OS}.qcow2 not found! This should never happen!" && exit 1 |