#!/bin/bash

# find where rol is installed
ROL_PATH=`python -c "import os; import RoboticsLanguage; print os.path.dirname(os.path.abspath(RoboticsLanguage.__file__)) + '/..'"`

# start the docker
# remove rol
# install rol using the mapping of the rol installation folder
if [ ! "$(docker ps -q -f name=DevelopmentRoboticsLanguage)" ]; then
  docker run -it --rm -v $ROL_PATH:/home/roboticslanguage/RoboticsLanguage --workdir=/home/roboticslanguage/RoboticsLanguage --name=DevelopmentRoboticsLanguage roboticslanguage/rol bash -c "sudo pip -q uninstall --yes RoboticsLanguage; cd /home/roboticslanguage/RoboticsLanguage; sudo pip install -e .; bash"
else
  docker exec -i -t DevelopmentRoboticsLanguage /bin/bash
fi
