-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.sh
executable file
·121 lines (108 loc) · 2.54 KB
/
run.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/sh
PORT="8000"
IMAGE="ostis/ostis"
VERSION="0.5.0"
# Container paths
OSTIS_PATH="/ostis"
OSTIS_SCRIPTS_PATH="${OSTIS_PATH}/scripts"
# Local paths
APP_PATH=${PWD}
KB_PATH="${APP_PATH}/kb"
PROBLEM_SOLVER_PATH="${APP_PATH}/problem-solver"
SCRIPTS_PATH="${APP_PATH}/scripts"
SCRIPT_FLAGS=""
DEFAULT_FLAGS="--all"
help()
{
cat << EOM
This is a tool for running container with OSTIS.
USAGE:
./run.sh [OPTIONS]
OPTIONS:
--help -h Print help message
--port -p Set a custom port
--app Set a custom path to the app directory(By default, it is expected, that inside the app you have all default directories for kb, problem-solver etc)
--kb Set a custom path to kb directory
--solver Set a custom path to problem-solvers directory
--startflags --sf To set container startup flags(using ${DEFAULT_FLAGS} by default). Usage: --startflags "[OSTIS FLAGS]" (quotes are necessary for multiple flags!)
OSTIS FLAGS:
--help -h Print help message
--all -a Run all services
--sc-mashine --scm Rebuild sc-machine
--build_kb --kb Rebuild kb
--sc-web --web Run sc-web only
--sctp Run sctp only
EOM
}
while [ $# -ne 0 ]
do
case "$1" in
--help | -h)
help
exit 0
;;
--port | -p)
if [ -z "$2" ]
then
echo "Cannot handle empty port value!"
help
exit 1
else
PORT="$2"
fi
;;
--app)
if [ -z "$2" ]
then
echo "Cannot handle empty app path value!"
help
exit 1
else
APP_PATH="$2"
KB_PATH="${APP_PATH}/kb"
PROBLEM_SOLVER_PATH="${APP_PATH}/problem-solver"
fi
;;
--kb)
if [ -z "$2" ]
then
echo "Cannot handle empty kb path value!"
help
exit 1
else
KB_PATH="$2"
fi
;;
--solver)
if [ -z "$2" ]
then
echo "Cannot handle empty problem-solver path value!"
help
exit 1
else
PROBLEM_SOLVER_PATH="$2"
fi
;;
--startflags | --sf)
if [ -z "$2" ]
then
echo "Cannot handle empty startup flags!"
help
exit 1
else
SCRIPT_FLAGS="$2"
fi
esac
shift
done
if [ -z "${SCRIPT_FLAGS}" ]
then
SCRIPT_FLAGS="${DEFAULT_FLAGS}"
fi
docker run -t -i \
-v ${KB_PATH}:${OSTIS_PATH}/kb \
-v ${PROBLEM_SOLVER_PATH}:${OSTIS_PATH}/problem-solver \
-p ${PORT}:8000 \
${IMAGE}:${VERSION} \
${OSTIS_SCRIPTS_PATH}/ostis ${SCRIPT_FLAGS}
exit