-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathengine.sh
executable file
·53 lines (46 loc) · 1.13 KB
/
engine.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
#!/usr/bin/env bash
# usage:
# ./engine.sh up
# ./start.sh +dev up
# ./engine.sh +dev +ache up -d
# ./engine.sh config
# ./engine.sh stop
# ./engine.sh down
# ./engine.sh restart mydig_ws
cmd="-f docker-compose.yml"
yml="" # additional yml files
operation_up=false
# find out if it is operation up
for arg in $@; do
if [ "${arg}" == "up" ]; then
operation_up=true
echo "" > .engine.status
fi
done
if [ "$operation_up" == true ]; then
# add parameter from env file
source ./.env
for arg in $(echo $DIG_ADD_ONS | tr "," "\n"); do
cmd="$cmd -f docker-compose.${arg}.yml"
yml="$yml -f docker-compose.${arg}.yml"
done
else
# add parameter from .engine.status
cmd="$cmd $(head -n 1 .engine.status)"
fi
# add parameter from command line
for arg in $@; do
if [[ "${arg:0:1}" == "+" ]]; then
arg=${arg:1} # remove plus sign
cmd="$cmd -f docker-compose.${arg}.yml"
yml="$yml -f docker-compose.${arg}.yml"
else
cmd="$cmd ${arg}"
fi
done
if [ "$operation_up" == true ]; then
echo "$yml" > .engine.status
fi
cmd="docker-compose $cmd"
#echo $cmd
eval $cmd