This repository has been archived by the owner on Jan 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.sh
executable file
·98 lines (85 loc) · 2.17 KB
/
game.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
#!/bin/bash
##Variables
if [ "${OS}" == "Windows_NT" ]; then
OS_TYPE='windows';
DOCKER_COMPOSE_CMD='winpty docker-compose'
DOCKER_CMD='winpty docker'
elif [ "${OSTYPE}" == "linux-gnu" ]; then
OS_TYPE='linux';
DOCKER_COMPOSE_CMD='docker-compose'
DOCKER_CMD='docker'
else
OS_TYPE='macos';
DOCKER_COMPOSE_CMD='docker-compose'
DOCKER_CMD='docker'
fi
## Constants
GREEN_OUTPUT='\033[0;32m'
RED_OUTPUT='\033[0;31m'
YELLOW_OUTPUT='\033[1;33m'
CLEAR_OUTPUT='\033[0m'
## Colored output
pc() {
RES=""
case "$1" in
green)
RES="${GREEN_OUTPUT}$2${CLEAR_OUTPUT}"
;;
red)
RES="${RED_OUTPUT}$2${CLEAR_OUTPUT}"
;;
yellow)
RES="${YELLOW_OUTPUT}$2${CLEAR_OUTPUT}"
;;
*)
RES="${CLEAR_OUTPUT}$2${CLEAR_OUTPUT}"
;;
esac
printf "${RES}"
}
general_help() {
pc "green" "--build | -b "
pc "none" " - build docker container \n"
pc "green" "--run | -r "
pc "none" " - start current docker container \n"
pc "green" "--down | -d "
pc "none" " - stop current active docker container \n"
# pc "green" "--own | -o "
# pc "none" " - run your own command in container \n"
pc "green" "--node | -n "
pc "none" " - run your own command in nodejs container \n"
# pc "green" "--test | -t "
# pc "none" " - run tests on docker container \n"
}
case "$1" in
--build|-b)
eval ${DOCKER_COMPOSE_CMD} up -d --build
;;
--run|-r)
eval ${DOCKER_COMPOSE_CMD} up -d
;;
--down|-d)
eval ${DOCKER_COMPOSE_CMD} down
;;
--nginx)
eval ${DOCKER_CMD} down
;;
--node|-n)
eval ${DOCKER_CMD} exec -it node $2 $3 $4 $5 $6 $7 $8
;;
--watch|-w)
eval ${DOCKER_CMD} exec -it node npm run watch
;;
# --own|-o)
# own_commands $1 $2 $3 $4 $5 $6 $7 $8
# ;;
# --test|-t)
# eval ${DOCKER_CMD} exec -it dev sh docker/do_test.sh
# ;;
--help|-h)
general_help $1
;;
*)
echo $"Usage: $0 {--build[-b]|--run[-r]|--down[-d]|--own[-o]|--test[-t]} {for help: -h/-help} CMD"
exit 1
esac