-
Notifications
You must be signed in to change notification settings - Fork 0
/
toolbox.sh
executable file
·107 lines (96 loc) · 2.05 KB
/
toolbox.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
cd `dirname $0`
if [ -z ${VOLUME_DIR+x} ]; then
export VOLUME_DIR=`pwd`
fi
export MINTOS_DOCKER_DIR=`pwd`
export VOLUME_DIR="$MINTOS_DOCKER_DIR"
CONTAINER_TOOLBOX_ID=`docker ps --format '{{.ID}}\t{{.Names}}' | grep mintos_web_1 | cut -f1`
function ssh_to()
{
if [ -z $1 ]; then
# Connect to toolbox
docker exec -t -i $CONTAINER_TOOLBOX_ID /bin/bash
else
# search container
CONTAINER=`docker ps --format 'table {{.Names}}' | grep $1 | tr -d ' '`
if [ -e $CONTAINER ]
then
echo "Container '$1' is not running!. Please select container from this list:"
docker ps
else
docker exec -t -i $CONTAINER /bin/bash
fi
fi
}
function execute_arbitrary(){
if [ -t 1 ] ; then
docker exec -t -i $CONTAINER_TOOLBOX_ID $@
RET=$?
else
echo "$Name Warning: running in a non-interactive environment. Some features may not work"
docker exec $CONTAINER_TOOLBOX_ID $@
RET=$?
fi
return $RET
}
function command_boot()
{
# Start the developer environment
docker-compose -f docker-compose.yml up &
echo -n "Waiting for the services to initialize.. "
while [[ ! $(docker ps | grep mintos_web_1) ]] ; do
echo -n "."
sleep 1
done
echo ""
echo "composer install --prefer-source --no-interaction" | docker exec -i mintos_web_1 /bin/bash
echo ""
}
function command_tests(){
echo " ./bin/phpunit tests" | docker exec -i mintos_web_1 /bin/bash
}
function command_rebuild() {
echo "Building image web"
docker build --no-cache -t web .
docker-compose -f docker-compose.yml build
}
function command_shutdown()
{
docker-compose -f docker-compose.yml down $@
}
while (( "$#" )); do
case "$1" in
boot|up)
shift
command_boot $@
exit
;;
rebuild)
command_rebuild;
exit;
;;
exec)
shift
execute_arbitrary $@
exit $?
;;
down)
shift
command_shutdown $@
exit
;;
tests)
command_tests
exit
;;
ssh|connect)
ssh_to $2
exit
;;
*)
COMMAND=$@
exit $?
;;
esac
done