-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexec.sh
43 lines (35 loc) · 988 Bytes
/
exec.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# [-c <container default=python] [<command to run>]
# If no command specificied, opens an interactive bash shell inside the running container
CONTAINER=python
while getopts ":c:" flag
do
echo flg="${flag}"
echo opt="${OPTARG}"
case "${flag}" in
c)
CONTAINER=${OPTARG}
;;
esac
done
# All of the options
COMMAND=$@
# If an alternate container was passed
if [ "$1" = "-c" ]
then
# Remove container option
COMMAND=${@:3}
fi
DOCKER="docker compose exec -it ${CONTAINER} bash"
# If COMMAND is non-empty
if [ ! -z "$COMMAND" ]
then
# we will run the command instead of opening a bash shell
DOCKER=$DOCKER' -c '
fi
# Just so we don't see the warning that PYTHON_CONTAINER_COMAND is unset
export PYTHON_CONTAINER_COMAND="echo \"executing: '${COMMAND[@]}'\""
$PYTHON_CONTAINER_COMAND
# EXEC_COMMAND=($DOCKER "${COMMAND}")
# (cd ./docker && "${EXEC_COMMAND[@]}")
echo $DOCKER"'${COMMAND}'"
(cd ./docker && $DOCKER"${COMMAND}")