-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·52 lines (41 loc) · 1.61 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
#!/bin/bash
set -e
# Add kibana as command if needed
if [[ "$1" == -* ]]; then
set -- kibana "$@"
fi
if [ -z "$ELASTICSEARCH_URL" ] && [ -z "$ELASTICSEARCH_PORT_9200_TCP" ] && [ -n "$ES_CLUSTER" ] && [ -n "$ES_CLUSTER_REGION" ]; then
export ELASTICSEARCH_HOST=$(aws es describe-elasticsearch-domain --region $ES_CLUSTER_REGION --domain-name $ES_CLUSTER --output text --query 'DomainStatus.Endpoint')
if [ -z "$ELASTICSEARCH_HOST" ]; then
echo >&2 'warning: could not find the es cluster for the region given'
echo >&2
exit 1
fi
export ELASTICSEARCH_URL="https://$ELASTICSEARCH_HOST"
if [ -z "$KIBANA_INDEX" ]; then
export KIBANA_INDEX='.kibana-4'
fi
fi
# Run as user "kibana" if the command is "kibana"
if [ "$1" = 'kibana' ]; then
if [ "$ELASTICSEARCH_URL" -o "$ELASTICSEARCH_PORT_9200_TCP" ]; then
: ${ELASTICSEARCH_URL:='http://elasticsearch:9200'}
sed -ri "s!^(elasticsearch_url:).*!\1 '$ELASTICSEARCH_URL'!" /opt/kibana/config/kibana.yml
else
echo >&2 'warning: missing ELASTICSEARCH_PORT_9200_TCP or ELASTICSEARCH_URL'
echo >&2 ' Did you forget to --link some-elasticsearch:elasticsearch'
echo >&2 ' or -e ELASTICSEARCH_URL=http://some-elasticsearch:9200 ?'
echo >&2
fi
if [ -n "$ES_CLUSTER" ]; then
sed -ri "s!^(\#? ?transport:).*!transport: \"AWS\"!" /opt/kibana/config/kibana.yml
fi
if [ -n "$ES_CLUSTER_REGION" ]; then
sed -ri "s!^(\#? ?region:).*!region: '$ES_CLUSTER_REGION'!" /opt/kibana/config/kibana.yml
fi
if [ -n "$KIBANA_INDEX" ]; then
sed -ri "s!^(\#? ?kibana_index:).*!kibana_index: '$KIBANA_INDEX'!" /opt/kibana/config/kibana.yml
fi
set -- gosu kibana "$@"
fi
exec "$@"