You are here

exec.sh in Realistic Dummy Content 7.2

#/bin/bash
#
# Executes a command on a container.
#
set -e

BASEPATH="$(pwd)"
SCRIPTNAME="$(basename "$0")"

if [ ! -f "$BASEPATH"/"$SCRIPTNAME" ]; then
  echo -e '[error] Please run this script from the developer directory of'
  echo -e '        realistic_dummy_content, like this:'
  echo -e ''
  echo -e '            cd /path/to/realistic_dummy_content/developer'
  echo -e "            ./$SCRIPTNAME"
  echo -e ''
  exit 1;
fi

if [ -z "$1" ]; then
  echo 'Please specify a container name as defined in docker-compose.yml.'
  exit 1
fi
if [ -z "$2" ]; then
  echo 'Please specify the command you would like to execute.'
fi

COMPOSECONTAINER="$1"
COMMAND="$2"

# The LXC driver does not support exec, see
# https://circleci.com/docs/docker/#docker-exec; the solution suggested in
# the documentation does not work, so we will try a different approach:
# Because Circle uses LXC and does not support exec, we'll use
# our run scripts instead. Instead of executing a command on an
# existing container, run-*.sh will create a new
# container linked to our database, run a command, and destroy the
# container thereafter.
./frameworks/"$COMPOSECONTAINER"/exec.sh "$COMMAND"

File

developer/exec.sh
View source
  1. #/bin/bash
  2. #
  3. # Executes a command on a container.
  4. #
  5. set -e
  6. BASEPATH="$(pwd)"
  7. SCRIPTNAME="$(basename "$0")"
  8. if [ ! -f "$BASEPATH"/"$SCRIPTNAME" ]; then
  9. echo -e '[error] Please run this script from the developer directory of'
  10. echo -e ' realistic_dummy_content, like this:'
  11. echo -e ''
  12. echo -e ' cd /path/to/realistic_dummy_content/developer'
  13. echo -e " ./$SCRIPTNAME"
  14. echo -e ''
  15. exit 1;
  16. fi
  17. if [ -z "$1" ]; then
  18. echo 'Please specify a container name as defined in docker-compose.yml.'
  19. exit 1
  20. fi
  21. if [ -z "$2" ]; then
  22. echo 'Please specify the command you would like to execute.'
  23. fi
  24. COMPOSECONTAINER="$1"
  25. COMMAND="$2"
  26. # The LXC driver does not support exec, see
  27. # https://circleci.com/docs/docker/#docker-exec; the solution suggested in
  28. # the documentation does not work, so we will try a different approach:
  29. # Because Circle uses LXC and does not support exec, we'll use
  30. # our run scripts instead. Instead of executing a command on an
  31. # existing container, run-*.sh will create a new
  32. # container linked to our database, run a command, and destroy the
  33. # container thereafter.
  34. ./frameworks/"$COMPOSECONTAINER"/exec.sh "$COMMAND"