forked from bcgov/von-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage
executable file
·97 lines (83 loc) · 2.39 KB
/
manage
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
#!/bin/bash
export MSYS_NO_PATHCONV=1
export DOCKERHOST=${APPLICATION_URL-$(docker run --rm --net=host codenvy/che-ip)}
set -e
SCRIPT_HOME="$( cd "$( dirname "$0" )" && pwd )"
export COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-von}"
# =================================================================================================================
# Usage:
# -----------------------------------------------------------------------------------------------------------------
usage () {
cat <<-EOF
Usage: $0 [command] [options]
Commands:
build - Build the docker images for the project.
You need to do this first.
up - Starts all containers and docker-compose logs.
Use ctrl-c to exit logging. Use "down" or "stop" to stop the run.
Examples:
$0 start
$0 start <ip_proxy_1>,<ip_proxy_2>,<ip_proxy_3>,<ip_proxy_4> &
start - Same as up
logs - Display the logs from the docker compose run (ctrl-c to exit).
cli - Start client container
down - Brings down the services and removes the volumes (storage) and containers.
rm - Same as down
stop - Stops the services. This is a non-destructive process. The volumes and containers
are not deleted so they will be reused the next time you run start.
rebuild - Rebuild the docker images.
EOF
exit 1
}
# -----------------------------------------------------------------------------------------------------------------
# Functions:
# -----------------------------------------------------------------------------------------------------------------
initEnv() {
export RUST_LOG=${RUST_LOG:-warning}
IP=""
IPS=""
if [[ $1 == *","* ]]; then
IPS="$1"
else
IP="$1"
fi
export IP="$IP" IPS="$IPS"
}
pushd ${SCRIPT_HOME} >/dev/null
case "$1" in
start|up)
initEnv "$2"
docker-compose up -d webserver node1 node2 node3 node4
docker-compose logs -f
;;
start-combined)
initEnv "$2"
docker-compose up -d webserver nodes
docker-compose logs -f
;;
cli)
initEnv "$2"
docker-compose run --rm client
;;
logs)
initEnv "$2"
docker-compose logs -f
;;
stop)
initEnv
docker-compose stop
;;
down|rm)
initEnv
docker-compose down -v
;;
build)
docker build -t von-network-base .
;;
rebuild)
docker-compose build -t von-network-base --no-cache
;;
*)
usage;;
esac
popd >/dev/null