forked from chaoss/grimoirelab
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint-secured.sh
85 lines (73 loc) · 2.79 KB
/
entrypoint-secured.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
#!/bin/bash
# Start ElasticSearch, MariaDB and Kibana, wait for them to be listening,
# and launch SirMordred with the options in the CMD line of the Dockerfile
echo "Starting container:" $(hostname)
# Start Elasticsearch
echo "Starting Elasticsearch"
sudo chown -R elasticsearch.elasticsearch /var/lib/elasticsearch
sudo /etc/init.d/elasticsearch start
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start Elasticsearch: $status"
exit $status
fi
echo "Waiting for Elasticsearch to start..."
sudo netstat -cvulntp |grep -m 1 ".*:9200.*LISTEN.*"
echo "Elasticsearch started"
sudo /usr/share/elasticsearch/plugins/search-guard-6/tools/sgadmin.sh -cd /usr/share/elasticsearch/plugins/search-guard-6/sgconfig -icl -key /etc/elasticsearch/kirk-key.pem -cert /etc/elasticsearch/kirk.pem -cacert /etc/elasticsearch/root-ca.pem -nhnv
status=$?
if [ $status -ne 0 ]; then
echo "Failed to configure Elasticsearch / SearchGuard: $status"
exit $status
fi
echo "Elasticsearch / SearchGuard configured."
# Start MariaDB
echo "Starting MariaDB"
sudo /etc/init.d/mysql start
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start MariaDB: $status"
exit $status
fi
echo "Waiting for MariaDB to start..."
sudo netstat -cvulntp |grep -m 1 ".*:3306.*LISTEN.*"
echo "MariaDB started"
# Start Kibiter (ensure passwd is the one in /kibanauser.pass)
sed -i "s/elasticsearch.password: \"XXX\"/elasticsearch.password: \"$(cat /kibanauser.pass)\"/" ${KB}-linux-x86_64/config/kibana.yml
echo "Starting Kibiter"
${KB}-linux-x86_64/bin/kibana > kibana.log 2>&1 &
echo "Waiting for Kibiter to start..."
#sleep .2
#sudo netstat -cvulntp |grep -m 1 ".*:5601.*LISTEN.*"
#until $(curl -k --output /dev/null --silent --head --fail "http://127.0.0.1:5601/login#?_g=()" ); do
until $(curl -k --output /dev/null --silent --head --fail "https://admin:[email protected]:5601/" ); do
printf '.'
sleep 2
done
echo "Kibiter started"
if [[ $RUN_MORDRED ]] && [[ $RUN_MORDRED = "NO" ]]; then
echo
echo "All services up, not running SirMordred because RUN_MORDRED = NO"
echo "Get a shell running docker exec, for example:"
echo "docker exec -it" $(hostname) "env TERM=xterm /bin/bash"
else
sleep 1
# Start SirMordred
echo "Starting SirMordred to build a GrimoireLab dashboard"
echo "This will usually take a while..."
/usr/local/bin/sirmordred $*
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start SirMordred: $status"
exit $status
fi
echo
echo "SirMordred done, dasboard produced, check https://localhost:5601"
echo
echo "To make this shell finish, type <CTRL> C"
echo "but the container will still run services in the background,"
echo "including Kibiter and Elasticsearch, so you can still operate the dashboard."
fi
echo
echo "To make the whole container finish, type 'docker kill " $(hostname) "'"
sleep 5000d