#!/bin/bash
# This is invoked from the Buildings directory.
# Hence, we need to share one level up
cur_dir=`pwd`
bas_nam=`basename ${cur_dir}`
sha_dir=`dirname ${cur_dir}`
# If the current directory is part of the argument list,
# replace it with . as the docker may have a different file structure
arg_lis=`echo $@ | sed -e "s|${cur_dir}|.|g"`
docker run \
	  --mac-address=${MAC_ADDRESS} \
	  --detach=false \
	  --rm \
	  --user=developer \
	  -v ${sha_dir}:/mnt/shared \
	  ${DOCKER_USERNAME}/travis_ubuntu-1604_dymola-2017fd01-x86-64 /bin/bash -c \
	  "Xvfb :77  -extension RANDR & \
	  export DISPLAY=:77.0 && \
	  cd /mnt/shared/${bas_nam} && \
	  dymola ${arg_lis}"
