-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdservice.sh
executable file
·43 lines (36 loc) · 915 Bytes
/
dservice.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
#!/bin/bash
COMMAND=$1
DEV_ENV_DIR=$DEV_ENV_DIR
# DEV_ENV_DIR=/vagrant # default for the vagrant environment
if [ -z "$DEV_ENV_DIR" ]; then
echo "Error: Ensure you have set the 'DEV_ENV_DIR' environment variable"
exit 1
fi
start_services () {
for service in "$@"
do
docker compose -f $DEV_ENV_DIR/$service.yml up -d
done
}
stop_services () {
for service in "$@"
do
docker compose -f $DEV_ENV_DIR/$service.yml down
done
}
restart_services () {
for service in "$@"
do
docker compose -f $DEV_ENV_DIR/$service.yml restart
done
}
shift # already have the command, just read in the remaining args
if [ "$COMMAND" '==' "up" ] || [ "$COMMAND" '==' "start" ]; then
start_services $@
elif [ "$COMMAND" '==' "down" ] || [ "$COMMAND" '==' "stop" ]; then
stop_services $@
elif [ "$COMMAND" '==' "restart" ]; then
restart_services $@
else
echo "Error: Invalid option $COMMAND"
fi