forked from BallAerospace/COSMOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cosmos-control.sh
executable file
·62 lines (59 loc) · 1.78 KB
/
cosmos-control.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
#!/usr/bin/env bash
usage() {
echo "Usage: $1 [cosmos, start, stop, cleanup, build, deploy]" >&2
echo "* cosmos: run a cosmos command ('cosmos help' for more info)" 1>&2
echo "* start: start the minimal docker run for cosmos" >&2
echo "* stop: stop the running dockers for cosmos" >&2
echo "* restart: stop and start the minimal docker run for cosmos" >&2
echo "* cleanup: cleanup network and volumes for cosmos" >&2
echo "* build: build the containers for cosmos" >&2
echo "* run: run the prebuilt containers for cosmos" >&2
echo "* deploy: deploy the containers to localhost repository" >&2
echo "* util: various helper commands" >&2
echo "* encode: encode a string to base64" >&2
echo "* hash: hash a string using SHA-256" >&2
exit 1
}
if [[ "$#" -eq 0 ]]; then
usage $0
fi
case $1 in
cosmos)
# Start (and remove when done --rm) the cosmos-base container with the current working directory
# mapped as volume (-v) /cosmos/local and container working directory (-w) also set to /cosmos/local.
# This allows tools running in the container to have a consistent path to the current working directory.
# Run the command "ruby /cosmos/bin/cosmos" with all parameters starting at 2 since the first is 'cosmos'
docker run --rm -v $(pwd):/cosmos/local -w /cosmos/local cosmos-base ruby /cosmos/bin/cosmos ${@:2}
;;
start)
scripts/linux/cosmos_setup.sh
scripts/linux/cosmos_build.sh
docker-compuse up -d
;;
stop)
docker-compose down
;;
restart)
docker-compose down
docker-compose up -d
;;
cleanup)
docker-compose down -v
;;
build)
scripts/linux/cosmos_setup.sh
scripts/linux/cosmos_build.sh
;;
run)
docker-compuse up -d
;;
deploy)
scripts/linux/cosmos_deploy.sh
;;
util)
scripts/linux/cosmos_util.sh $2 $3
;;
*)
usage $0
;;
esac