forked from bdelbosc/nuxeo-stacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxeoenv.sh
executable file
·321 lines (311 loc) · 8.35 KB
/
nuxeoenv.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#!/usr/bin/env bash
# Nuxeo stacks
#
set -e
PLAYBOOK_OPTS=""
usage() { echo "Usage: $0 [-i clid -d data -n nuxeo -b backend -s stack" 1>&2;
exit 1; }
get_opts() {
while getopts ":i:d:n:b:s:c:t:" o; do
case "${o}" in
i)
instance_clid=${OPTARG}
;;
d)
data_path=${OPTARG}
;;
n)
nuxeo_dist=${OPTARG}
;;
b)
backend=${OPTARG}
;;
s)
stacks=${OPTARG}
;;
c)
nuxeo_cluster=${OPTARG}
;;
t)
if [[ "FAST" == "$OPTARG" ]]; then
PLAYBOOK_OPTS="$PLAYBOOK_OPTS --tags test"
fi
;;
*)
usage
;;
esac
done
}
get_input() {
if [[ -z "${instance_clid}" ]]; then
instance_clid=$(whiptail --title "Nuxeo stacks" --inputbox "Enter the full path of a Nuxeo instance.clid file:" 10 60 "$PWD/instance.clid" 3>&1 1>&2 2>&3)
fi
if [[ ! -f ${instance_clid} ]]; then
>&2 echo "ABORT: Expecting a Nuxeo instance clid produced with nuxeoctl register, got: $instance_clid"
exit 2
fi
if [[ -z "${data_path}" ]]; then
data_path=$(whiptail --title "Nuxeo stacks" --inputbox "Enter the path to the Nuxeo environment to create:" 10 60 "/tmp/my-nuxeo-env" 3>&1 1>&2 2>&3)
fi
if [[ -x "$(command -v realpath)" ]]; then
data_path="${data_path//\~/$HOME}"
data_path=`realpath -m ${data_path}`
fi
if [[ -z "${nuxeo_dist}" ]]; then
nuxeo_dist=$(whiptail --title "Nuxeo stacks" --radiolist "Choose a Nuxeo distribution:" 14 60 6 \
nuxeolatest "Nuxeo latest " on \
nuxeo1010 "Nuxeo 10.10" off \
nuxeo910 "Nuxeo 9.10" off \
nuxeo810 "Nuxeo 8.10" off \
nuxeo710 "Nuxeo 7.10" off \
3>&1 1>&2 2>&3)
fi
if [[ -z "${nuxeo_cluster}" ]]; then
nuxeo_cluster=$(whiptail --title "Nuxeo stacks" --radiolist "Choose a Nuxeo cluster mode:" 10 60 3 \
no "Standalone instance " on \
2 "Cluster 2 nodes" off \
3 "Cluster 3 nodes" off \
3>&1 1>&2 2>&3)
fi
if [[ -z "${backend}" ]]; then
backend=$(whiptail --title "Nuxeo stacks" --radiolist "Choose a Nuxeo repository backend:" 10 60 3 \
mongo "MongoDB " on \
postgres "PostgreSQL" off \
none "Default H2" off \
3>&1 1>&2 2>&3)
fi
if [[ -z "${stacks}" ]]; then
stacks=$(whiptail --title "Nuxeo stacks" --checklist "Compose your stack:" 22 72 14 \
elastic "Elasticsearch (non embedded)" on \
redis "Redis" on \
kafka "Kafka (and Zookeeper)" off \
kafkaconfluent "Confluent Kafka stack with KSQL" off \
swm "Use the Nuxeo Stream WorkManager impl. " off \
minio "Use a Minio S3 like binarystore" off \
monitor "Nuxeo monitoring with Grafana" off \
stream "Nuxeo Stream monitoring" off \
kibana "Elasticsearch Kibana" off \
kafkahq "KafkaHQ a Kafka GUI" off \
prometheus "Prometheus monitoring" off \
jaeger "Jaeger distributed tracer" off \
zipkin "Zipkin distributed tracer" off \
kafkassl "Kafka in SASL_SSL" off \
netdata "Netdata monitoring" off \
3>&1 1>&2 2>&3)
fi
COMMAND="${0} -i \"${instance_clid}\" -d \"${data_path}\" -c ${nuxeo_cluster} -n ${nuxeo_dist} -b ${backend} -s '"${stacks}"'"
}
parse_input() {
if [[ ${nuxeo_dist} == *"nuxeolatestjx"* ]]; then
nuxeo=True
nuxeo_version=latestjx
elif [[ ${nuxeo_dist} == *"nuxeolatest"* ]]; then
nuxeo=True
nuxeo_version=latest
elif [[ ${nuxeo_dist} == *"nuxeo1010"* ]]; then
nuxeo=True
nuxeo_version=10.10
elif [[ ${nuxeo_dist} == *"nuxeo910"* ]]; then
nuxeo=True
nuxeo_version=9.10
elif [[ ${nuxeo_dist} == *"nuxeo810"* ]]; then
nuxeo=True
nuxeo_version=8.10
elif [[ ${nuxeo_dist} == *"nuxeo710"* ]]; then
nuxeo=True
nuxeo_version=7.10
else
nuxeo=False
nuxeo_version=latestjx
fi
if [[ ${backend} == *"mongo"* ]]; then
mongo=True
postgres=False
elif [[ ${backend} == *"postgres"* ]]; then
mongo=False
postgres=True
else
mongo=False
postgres=False
fi
if [[ ${stacks} == *"elastic"* ]]; then
elastic=True
if [[ ${stacks} == *"kibana"* ]]; then
kibana=True
else
kibana=False
fi
else
elastic=False
kibana=False
fi
if [[ ${stacks} == *"redis"* ]]; then
redis=True
else
redis=False
fi
if [[ ${stacks} == *"kafka"* ]]; then
kafkassl=False
kafka=True
zookeeper=True
if [[ ${stacks} == *"kafkassl"* ]]; then
kafkassl=True
else
kafkassl=False
fi
if [[ ${stacks} == *"kafkahq"* ]]; then
kafkahq=True
else
kafkahq=False
fi
else
kafkassl=False
kafka=False
zookeeper=False
kafkahq=False
fi
if [[ ${stacks} == *"kafkaconfluent"* ]]; then
kafkaconfluent=True
kafkassl=False
kafka=False
zookeeper=False
kafkahq=False
else
kafkaconfluent=False
fi
if [[ ${stacks} == *"stream"* ]]; then
stream=True
else
stream=False
fi
if [[ ${stacks} == *"swm"* ]]; then
swm=True
else
swm=False
fi
if [[ ${stacks} == *"monitor"* ]]; then
graphite=True
grafana=True
else
graphite=False
grafana=False
fi
if [[ ${stacks} == *"netdata"* ]]; then
netdata=True
else
netdata=False
fi
if [[ ${stacks} == *"prometheus"* ]]; then
prometheus=True
else
prometheus=False
fi
if [[ ${stacks} == *"jaeger"* ]]; then
jaeger=True
else
jaeger=False
fi
if [[ ${stacks} == *"zipkin"* ]]; then
zipkin=True
else
zipkin=False
fi
if [[ ${stacks} == *"minio"* ]]; then
minio=True
else
minio=False
fi
if [[ ${nuxeo_cluster} == *"2"* ]]; then
nuxeo_cluster_mode=True
nuxeo_nb_nodes=2
elif [[ ${nuxeo_cluster} == *"3"* ]]; then
nuxeo_cluster_mode=True
nuxeo_nb_nodes=3
else
nuxeo_cluster_mode=False
nuxeo_nb_nodes=1
fi
}
venv_init() {
if [[ `command -v ansible-playbook` ]]; then
return
fi
if [[ ! -r ./venv/ ]]; then
virtualenv ./venv
venv_activate
pip install ansible
fi
}
venv_activate() {
if [[ `command -v ansible-playbook` ]]; then
return
fi
[[ -f ./venv/bin/activate ]] && source ./venv/bin/activate
}
generate_compose() {
target_host="`cat hosts`"
if [[ X"$target_host" == "Xlocalhost" ]]; then
# No need to ssh when the target is localhost
ANSIBLE_OPT="--connection=local"
fi
set -x
ansible-playbook site.yml $ANSIBLE_OPT -i ./hosts -e "env_data_path=$data_path env_instance_clid=$instance_clid" \
-e "env_nuxeo=$nuxeo env_nuxeo_version=$nuxeo_version" \
-e "env_nuxeo_cluster=$nuxeo_cluster_mode env_nuxeo_nb_nodes=$nuxeo_nb_nodes" \
-e "env_mongo=$mongo env_postgres=$postgres env_redis=$redis env_minio=$minio" \
-e "env_elastic=$elastic env_kibana=$kibana" \
-e "env_graphite=$graphite -e env_grafana=$grafana" \
-e "env_kafka=$kafka env_kafkassl=$kafkassl env_zookeeper=$zookeeper env_kafkahq=$kafkahq env_kafkaconfluent=$kafkaconfluent"\
-e "env_stream=$stream env_netdata=$netdata env_swm=$swm" \
-e "env_prometheus=$prometheus env_jaeger=$jaeger env_zipkin=$zipkin" \
${PLAYBOOK_OPTS}
set +x
}
bye() {
echo
echo "---------------------------------------------------------------"
echo "# This Nuxeo Stack can be rebuilt with the following command:"
echo ${COMMAND}
echo "# Next steps:"
echo "cd ${data_path}"
echo "docker-compose up"
echo "http://nuxeo.docker.localhost/nuxeo -> Nuxeo Administrator/Administrator"
if [[ ${stacks} == *"monitor"* ]]; then
echo "http://grafana.docker.localhost/ -> Grafana admin/admin"
echo "http://graphite.docker.localhost/ -> Graphite root/root"
fi
if [[ ${stacks} == *"elastic"* ]]; then
echo "http://elastic.docker.localhost/ -> Elasticsearch"
fi
if [[ ${stacks} == *"kibana"* ]]; then
echo "http://kibana.docker.localhost/ -> Kibana"
fi
if [[ ${stacks} == *"minio"* ]]; then
echo "http://minio.docker.localhost/ -> Minio S3 like"
fi
if [[ ${stacks} == *"kafkahq"* ]]; then
echo "http://kafkahq.docker.localhost/ -> KafkaHQ"
fi
if [[ ${stacks} == *"prometheus"* ]]; then
echo "http://prometheus.docker.localhost/ -> Prometheus"
fi
if [[ ${stacks} == *"jaeger"* ]]; then
echo "http://jaeger.docker.localhost/ -> Jaeger"
fi
if [[ ${stacks} == *"zipkin"* ]]; then
echo "http://zipkin.docker.localhost/ -> Zipkin"
fi
if [[ ${stacks} == *"kafkaconfluent"* ]]; then
echo "http://schema.docker.localhost/ -> Confluent Avro Schema Registry"
echo "http://ksql.docker.localhost/ -> Confluent KSQL Server"
fi
}
# main
get_opts "$@"
get_input
parse_input
venv_init
venv_activate
generate_compose
bye