-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-entrypoint.sh
148 lines (128 loc) · 6.26 KB
/
docker-entrypoint.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
#!/bin/bash
set -e
cd /usr/share/kibana/bin
CURRENT_PLUGINS=$(kibana-plugin list)
if [ "$OPENDISTRO_ALERTING" != "" ]; then
# If not installed, install
if [[ $CURRENT_PLUGINS != *"opendistroAlertingKibana"* ]]; then
kibana-plugin install https://d3g5vo6xdbdb9a.cloudfront.net/downloads/kibana-plugins/opendistro-alerting/opendistroAlertingKibana-1.12.0.2.zip
fi
else
# If installed, uninstall
if [[ $CURRENT_PLUGINS == *"opendistroAlertingKibana"* ]]; then
kibana-plugin remove opendistroAlertingKibana
fi
fi
if [ "$OPENDISTRO_ANOMALYDETECTION" != "" ]; then
# If not installed, install
if [[ $CURRENT_PLUGINS != *"opendistroAnomalyDetectionKibana"* ]]; then
kibana-plugin install https://d3g5vo6xdbdb9a.cloudfront.net/downloads/kibana-plugins/opendistro-anomaly-detection/opendistroAnomalyDetectionKibana-1.12.0.0.zip
fi
else
# If installed, uninstall
if [[ $CURRENT_PLUGINS == *"opendistroAnomalyDetectionKibana"* ]]; then
kibana-plugin remove opendistroAnomalyDetectionKibana
fi
fi
if [ "$OPENDISTRO_GANTTCHART" != "" ]; then
# If not installed, install
if [[ $CURRENT_PLUGINS != *"opendistroGanttChartKibana"* ]]; then
kibana-plugin install https://d3g5vo6xdbdb9a.cloudfront.net/downloads/kibana-plugins/opendistro-gantt-chart/opendistroGanttChartKibana-1.12.0.0.zip
fi
else
# If installed, uninstall
if [[ $CURRENT_PLUGINS == *"opendistroGanttChartKibana"* ]]; then
kibana-plugin remove opendistroGanttChartKibana
fi
fi
if [ "$OPENDISTRO_INDEXMANAGEMENT" != "" ]; then
# If not installed, install
if [[ $CURRENT_PLUGINS != *"opendistroIndexManagementKibana"* ]]; then
kibana-plugin install https://d3g5vo6xdbdb9a.cloudfront.net/downloads/kibana-plugins/opendistro-index-management/opendistroIndexManagementKibana-1.12.0.0.zip
fi
else
# If installed, uninstall
if [[ $CURRENT_PLUGINS == *"opendistroIndexManagementKibana"* ]]; then
kibana-plugin remove opendistroIndexManagementKibana
fi
fi
if [ "$OPENDISTRO_NOTEBOOKS" != "" ]; then
# If not installed, install
if [[ $CURRENT_PLUGINS != *"opendistroNotebooksKibana"* ]]; then
kibana-plugin install https://d3g5vo6xdbdb9a.cloudfront.net/downloads/kibana-plugins/opendistro-notebooks/opendistroNotebooksKibana-1.12.0.0.zip
fi
else
# If installed, uninstall
if [[ $CURRENT_PLUGINS == *"opendistroNotebooksKibana"* ]]; then
kibana-plugin remove opendistroNotebooksKibana
fi
fi
if [ "$OPENDISTRO_QUERYWORKBENCH" != "" ]; then
# If not installed, install
if [[ $CURRENT_PLUGINS != *"opendistroQueryWorkbenchKibana"* ]]; then
kibana-plugin install https://d3g5vo6xdbdb9a.cloudfront.net/downloads/kibana-plugins/opendistro-query-workbench/opendistroQueryWorkbenchKibana-1.12.0.0.zip
fi
else
# If installed, uninstall
if [[ $CURRENT_PLUGINS == *"opendistroQueryWorkbenchKibana"* ]]; then
kibana-plugin remove opendistroQueryWorkbenchKibana
fi
fi
if [ "$OPENDISTRO_REPORTS" != "" ]; then
# If not installed, install
if [[ $CURRENT_PLUGINS != *"opendistroReportsKibana"* ]]; then
kibana-plugin install https://d3g5vo6xdbdb9a.cloudfront.net/downloads/kibana-plugins/opendistro-reports/linux/x64/opendistroReportsKibana-1.12.0.0.zip
fi
else
# If installed, uninstall
if [[ $CURRENT_PLUGINS == *"opendistroReportsKibana"* ]]; then
kibana-plugin remove opendistroReportsKibana
fi
fi
if [ "$OPENDISTRO_TRACEANALYTICS" != "" ]; then
# If not installed, install
if [[ $CURRENT_PLUGINS != *"opendistroTraceAnalyticsKibana"* ]]; then
kibana-plugin install https://d3g5vo6xdbdb9a.cloudfront.net/downloads/kibana-plugins/opendistro-trace-analytics/opendistroTraceAnalyticsKibana-1.12.0.0.zip
fi
else
# If installed, uninstall
if [[ $CURRENT_PLUGINS == *"opendistroTraceAnalyticsKibana"* ]]; then
kibana-plugin remove opendistroTraceAnalyticsKibana
fi
fi
if [ -z "$ELASTICSEARCH_USER" ] || [ -z "$ELASTICSEARCH_PASSWORD" ]; then
echo >&2 'error: ELASTICSEARCH_USER or/and ELASTICSEARCH_PASSWORD environment variables were not configured'
echo >&2 ' these two docker environment variables must be configured before running the container'
exit 1
fi
# For the sed command, we don't use directly the '-i' option because it moves (mv)
# the output file under the hood. That might generate problems when kibana.yml
# is mounted in a volume.
# Generate the temporary file for changing kibana.yml.
TMPFILE=$(mktemp)
if [ "$ANONYMOUS_USER" != "" ]; then
sed '/opendistro_security.auth.anonymous_auth_enabled/d' /opt/kibana/config/kibana.yml > $TMPFILE && cat $TMPFILE > /opt/kibana/config/kibana.yml
printf "opendistro_security.auth.anonymous_auth_enabled: \"$ANONYMOUS_USER\"\n" >> /opt/kibana/config/kibana.yml
fi
sed '/opendistro_security.basicauth.login.brandimage/d' /opt/kibana/config/kibana.yml > $TMPFILE && cat $TMPFILE > /opt/kibana/config/kibana.yml
if [ "$LOGIN_BRANDIMAGE" != "" ]; then
printf "opendistro_security.basicauth.login.brandimage: \"$LOGIN_BRANDIMAGE\"\n" >> /opt/kibana/config/kibana.yml
else
printf "opendistro_security.basicauth.login.brandimage: 'https://raw.githubusercontent.com/Bitergia/bitergia-analytics-odfe-kibana/master/assets/bitergia_login_logo.png'\n" >> /opt/kibana/config/kibana.yml
fi
sed '/opendistro_security.basicauth.login.title/d' /opt/kibana/config/kibana.yml > $TMPFILE && cat $TMPFILE > /opt/kibana/config/kibana.yml
if [ "$LOGIN_TITLE" != "" ]; then
printf "opendistro_security.basicauth.login.title: \"$LOGIN_TITLE\"\n" >> /opt/kibana/config/kibana.yml
else
printf "opendistro_security.basicauth.login.title: Please login to Bitergia Analytics Dashboard\n" >> /opt/kibana/config/kibana.yml
fi
sed '/opendistro_security.basicauth.login.subtitle/d' /opt/kibana/config/kibana.yml > $TMPFILE && cat $TMPFILE > /opt/kibana/config/kibana.yml
if [ "$LOGIN_SUBTITLE" != "" ]; then
printf "opendistro_security.basicauth.login.subtitle: \"$LOGIN_SUBTITLE\"\n" >> /opt/kibana/config/kibana.yml
else
printf 'opendistro_security.basicauth.login.subtitle: If you have forgotten your username or password, please contact the Bitergia staff\n' >> /opt/kibana/config/kibana.yml
fi
# Removing the temporary file
rm $TMPFILE
# Execute kibana
/usr/local/bin/kibana-docker