-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.sh
executable file
·164 lines (129 loc) · 5.36 KB
/
bootstrap.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
#!/usr/bin/env bash
# Bootstrap script for DICE Monitoring Core Componets
#
#Copyright 2015, Institute e-Austria, Timisoara, Romania
# http://www.ieat.ro/
#Developers:
# * Gabriel Iuhasz, [email protected]
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at:
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#get kibana4 and install
#TODO Replace wget
#set FQDN for HOST
HostIP=$(ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://') #need to change to eth0 for non vagrant
echo "#Auto generated DICE Monitoring FQDN
$HostIP dice.dmon.internal dmoncontroller" >> /etc/hosts
echo "Installing kibana...."
cd ~/
#wget https://download.elasticsearch.org/kibana/kibana/kibana-4.1.2-linux-x64.tar.gz
wget https://download.elastic.co/kibana/kibana/kibana-4.4.1-linux-x64.tar.gz
tar xvf kibana-4.4.1-linux-x64.tar.gz
mkdir -p /opt/kibana
cp -R ~/kibana-4.4.1-linux-x64/* /opt/kibana/
echo "Registering Kibana as a service ...."
cd /etc/init.d && sudo wget https://gist.githubusercontent.com/thisismitch/8b15ac909aed214ad04a/raw/bce61d85643c2dcdfbc2728c55a41dab444dca20/kibana4
chmod +x /etc/init.d/kibana4
update-rc.d kibana4 defaults 96 9
#Start kibana after install
#service kibana4 start # Deprecated, now starts from REST API
# Install Java 8
echo "Installing Oracle Java 1.8 ...."
apt-get install python-software-properties -y
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
add-apt-repository ppa:webupd8team/java -y
apt-get update -y
apt-get install oracle-java8-installer -y
apt-get install ant -y
# TODO Replace wget command
#cd /tmp
#wget -q --no-check-certificate https://github.com/aglover/ubuntu-equip/raw/master/equip_java8.sh && bash equip_java8.sh
#VM level Setings
echo "Configuring VM level setings"
export ES_HEAP_SIZE=2g
sysctl -w vm.max_map_count=262144
swapoff -a
# TODO fix this so that it must be set before running bootstrap script
DMONHOME=/opt/DICE-Monitoring
if grep -q "DMONHOME" ~/.bashrc; then
echo "DMON home dir is already set"
else
echo "DMONHOME=/opt/DICE-Monitoring" >> ~/.bashrc
echo "DMON home dir set"
fi
# Install Elasticsearch 2.2.0
echo "Installing Elasticsearch ...."
cd /opt
wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.2.0/elasticsearch-2.2.0.tar.gz
tar zxf elasticsearch-2.2.0.tar.gz
ln -sf elasticsearch-2.2.0 elasticsearch
#delete config file
rm -f /opt/elasticsearch/config/elastcisearch.yml
#ln -sf /vagrant/elasticsearch.yml /opt/elasticsearch/config/elasticsearch.yml
# Install Marvel (posibly obsolete afther further testing)
echo "Installing Elasticsearch plugin marvel ....."
#For version of <ES2.2.0 and <kibana 4.1.2
#/opt/elasticsearch/bin/plugin -i elasticsearch/marvel/latest
/opt/elasticsearch/bin/plugin install license
/opt/elasticsearch/bin/plugin install marvel-agent
#/opt/elasticsearch/bin/ install watcher
/opt/kibana/bin/kibana plugin --install elasticsearch/marvel/2.2.0
/opt/kibana/bin/kibana plugin --install elastic/sense
echo "Setting up init script for dmon-es ..."
cp $DMONHOME/src/init/dmon-es /etc/init.d/dmon-es
cd /etc/init.d
chmod +x /etc/init.d/dmon-es
update-rc.d dmon-es defaults 96 9
# Install Logstash
echo "Installing Logstash..."
cd /opt
wget https://download.elastic.co/logstash/logstash/logstash-2.2.1.tar.gz
tar zxf logstash-2.2.1.tar.gz
ln -sf logstash-2.2.1 logstash
echo "Setting up init script for dmon-ls ..."
cp $DMONHOME/src/init/dmon-ls /etc/init.d/dmon-ls
cd /etc/init.d
chmod +x /etc/init.d/dmon-ls
update-rc.d dmon-ls defaults 96 9
cd /opt
#Setup Logrotate
echo "Setting up logrotate ..."
echo "/opt/DICE-Monitoring/src/logs/logstash.log{
size 20M
create 777 ubuntu ubuntu
rotate 4
}" >> /etc/logrotate.conf
cd /etc
logrotate -s /var/log/logstatus logrotate.conf
echo "Generating certificates for Logstash ..."
#HostIP=$(ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://') #need to change to eth0 for non vagrant
#backup open ssl
cp /etc/ssl/openssl.cnf /etc/ssl/openssl.backup
sed -i "/# Extensions for a typical CA/ a\subjectAltName = IP:$HostIP" /etc/ssl/openssl.cnf
#generate certificates
openssl req -config /etc/ssl/openssl.cnf -x509 -days 3650 -batch -nodes -newkey rsa:2048 -keyout /opt/DICE-Monitoring/src/keys/logstash-forwarder.key -out /opt/DICE-Monitoring/src/keys/logstash-forwarder.crt
#Create Backup Dir
echo "Creating backup Dir"
if [ ! -d "/opt/DmonBackup" ]; then
mkdir -p /opt/DmonBackup
fi
# fix permissions
echo "Setting permissions ...."
cd /opt
chown -R ubuntu.ubuntu logstash* elasticsearch*
chown -R ubuntu.ubuntu /opt
echo "Finishing touches ....."
mkdir -p /etc/logstash/conf.d
rm -rf /opt/logstash-2.2.1.tar.gz
rm -rf /opt/elasticsearch-2.2.0.tar.gz
rm -rf /home/ubuntu/kibana-4.4.1-linux-x64*
wget https://github.com/igabriel85/DICE-Monitoring/releases/download/logov01/kibana.svg
mv kibana.svg /opt/kibana/optimize/bundles/src/ui/public/images
echo "Bootstrapping done!"