# 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; }
# 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; }
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