-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_eyesofreport.sh
executable file
·426 lines (354 loc) · 16.1 KB
/
install_eyesofreport.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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
#!/bin/bash
#########################################
#
# Copyright (C) 2018 EyesOfNetwork Team
# DEV NAME : Jean-Philippe Levy Apr 2018
#
# VERSION 2.2
#
# LICENCE :
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#########################################
# global variables
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
YUM_EOR_OPTIONS=""
DOCKER_EOR="docker"
# make .sh executable
find $BASEDIR -name '*.sh' -exec chmod +x {} \;
# external softs
if [ ! -f "$BASEDIR/EXTERNAL_SOFTS/wildfly-9.0.1.Final.zip" ]; then
echo "File EXTERNAL_SOFTS/wildfly-9.0.1.Final.zip not found. Please follow EXTERNAL_SOFTS/README.txt before Eyes Of Report Installation";
echo -e "Eyes Of Report installation \e[31m[CANCELLED] \e[39m";
exit 1;
fi
if [ ! -f "$BASEDIR/EXTERNAL_SOFTS/jdk-7u79-linux-x64.tar.gz" ]; then
echo "File EXTERNAL_SOFTS/jdk-7u79-linux-x64.tar.gz not found. Please follow EXTERNAL_SOFTS/README.txt before Eyes Of Report Installation";
echo -e "Eyes Of Report installation \e[31m[CANCELLED] \e[39m";
exit 1;
fi
if [ ! -f "$BASEDIR/EXTERNAL_SOFTS/data-integration.zip" ]; then
echo "File EXTERNAL_SOFTS/data-integration.zip not found. Please follow EXTERNAL_SOFTS/README.txt before Eyes Of Report Installation";
echo -e "Eyes Of Report installation \e[31m[CANCELLED] \e[39m";
exit 1;
fi
echo "Merge external softwares in Eyes Of Report installation..."
cp $BASEDIR/EXTERNAL_SOFTS/wildfly-9.0.1.Final.zip $BASEDIR/REPORTING
cp $BASEDIR/EXTERNAL_SOFTS/jdk-7u79-linux-x64.tar.gz $BASEDIR/CORE
cp $BASEDIR/EXTERNAL_SOFTS/data-integration.zip $BASEDIR/ETL
# check previous installation
if [ -d /srv/eyesofreport ]; then
while true; do
read -p " Previous EyesOfReport installation exists on this machine. Do you want to remove it (y/n)? " yn
case $yn in
[Yy]*) rm -rf /srv/eyesofreport;break;;
[Nn]*) echo -e "Eyes Of Report installation \e[31m[CANCELLED] \e[39m";exit 1;;
*) echo "Please type y or n";;
esac
done
fi
# Create directories
echo "Eyes Of Report base folders..."
mkdir -p /var/lib/docker
mkdir /srv/eyesofreport
# Selinux
setenforce 0
sed -ie 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -ie 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
# Create eyessofreport yum repository
echo "Eyes Of Report local repo..."
mkdir -p /srv/eyesofreport/depot-1.0
ln -s /srv/eyesofreport/depot-1.0 /srv/eyesofreport/depot
# No internet create full local repo
if [ $# == 1 ]; then
if [ $1 == "--local" ]; then
YUM_EOR_OPTIONS="--disablerepo=* --enablerepo=localrepo"
# Install createrepo
if [ $(rpm -qa | grep -c deltarpm-3.6-3) -eq 0 ]; then
rpm -ivh $BASEDIR/CORE/createrepo/deltarpm-3.6-3.el7.x86_64.rpm
fi
if [ $(rpm -qa | grep -c libxml2-2.9.1-5.el7_1.2.x86_64) -eq 0 ]; then
rpm -ivh --replacefiles $BASEDIR/CORE/createrepo/libxml2-2.9.1-5.el7_1.2.x86_64.rpm
fi
if [ $(rpm -qa | grep -c libxml2-python-2.9.1-5) -eq 0 ]; then
rpm -ivh $BASEDIR/CORE/createrepo/libxml2-python-2.9.1-5.el7_1.2.x86_64.rpm
fi
if [ $(rpm -qa | grep -c python-deltarpm-3.6-3) -eq 0 ]; then
rpm -ivh $BASEDIR/CORE/createrepo/python-deltarpm-3.6-3.el7.x86_64.rpm
fi
if [ $(rpm -qa | grep -c createrepo-0.9.9-23) -eq 0 ]; then
rpm -ivh $BASEDIR/CORE/createrepo/createrepo-0.9.9-23.el7.noarch.rpm
fi
# Delete all rpm http and php installed on the machine
if [ $(rpm -qa | grep -c httpd-tools) -gt 0 ]; then
yum remove -y httpd 2&>1 /dev/null
fi
if [ $(rpm -qa | grep -c httpd) -gt 0 ]; then
yum remove -y httpd-tools 2&>1 /dev/null
fi
if [ $(rpm -qa | grep -c php-common) -gt 0 ]; then
yum remove -y php-common 2&>1 /dev/null
fi
if [ $(rpm -qa | grep -c php-pdo) -gt 0 ]; then
yum remove -y php-pdo 2&>1 /dev/null
fi
if [ $(rpm -qa | grep -c php-mysqlnd) -gt 0 ]; then
yum remove -y php-mysqlnd 2&>1 /dev/null
fi
if [ $(rpm -qa | grep -c php-cli) -gt 0 ]; then
yum remove -y php-cli 2&>1 /dev/null
fi
if [ $(rpm -qa | grep -c php-xmlrpc) -gt 0 ]; then
yum remove -y php-xmlrpc 2&>1 /dev/null
fi
if [ $(rpm -qa | grep -c php-xml) -gt 0 ]; then
yum remove -y php-xml 2&>1 /dev/null
fi
if [ $(rpm -qa | grep -c php-ldap) -gt 0 ]; then
yum remove -y php-ldap 2&>1 /dev/null
fi
if [ $(rpm -qa | grep -c php) -gt 0 ]; then
yum remove -y php 2&>1 /dev/null
fi
cp $BASEDIR/CORE/rpm/* /srv/eyesofreport/depot
# redhat installation
elif [ $1 == "--redhat" ]; then
DOCKER_EOR=""
yum install -y yum-utils createrepo
cp $BASEDIR/CORE/rpm/mod_auth_eon-5.0-1.eon.x86_64.rpm /srv/eyesofreport/depot
fi
# internet installation
else
yum install -y yum-utils createrepo
cp $BASEDIR/CORE/rpm/mod_auth_eon-5.0-1.eon.x86_64.rpm /srv/eyesofreport/depot
fi
# create local repo
echo "[localrepo]" > /etc/yum.repos.d/localrepo.repo
echo "name=Eyesofreport repository" >> /etc/yum.repos.d/localrepo.repo
echo "baseurl=file:///srv/eyesofreport/depot" >> /etc/yum.repos.d/localrepo.repo
echo "gpgcheck=0" >> /etc/yum.repos.d/localrepo.repo
createrepo -v /srv/eyesofreport/depot/ > /dev/null
echo -e "Eyes Of Report repository creation \e[92m[OK] \e[39m"
# install eyesofreport dependencies
echo "Eyes Of Report packages installation..."
yum install -y ${YUM_EOR_OPTIONS} perl net-tools nano ${DOCKER_EOR} unzip zip rsync bind-utils patch dos2unix firewalld wget net-snmp net-snmp-utils mariadb-server 2&> $BASEDIR/log_packet_install.log
yum install -y ${YUM_EOR_OPTIONS} httpd httpd-tools mod_auth_eon libxslt php-common php-mysqlnd php php-xml php-xmlrpc php-ldap 2&>> $BASEDIR/log_packet_install.log
# system configurations
systemctl enable firewalld
systemctl start firewalld
sed -i 's/^Defaults requiretty/#Defaults requiretty/g' /etc/sudoers
echo -e "\n# eorweb\napache ALL=NOPASSWD:/bin/systemctl * docker,/bin/systemctl * pentaho,/bin/systemctl * ,/bin/systemctl * snmpd,/bin/systemctl * wildfly" >> /etc/sudoers
# docker installation for redhat
if [ $DOCKER_EOR == "" ]; then
#Installation Docker
mkdir /usr/bin/install_docker
cp $BASEDIR/CORE/dockers/docker-1.11.0.tar /usr/bin/install_docker
cd /usr/bin/install_docker
tar xvf ./docker-1.11.0.tar
mv ./docker/* /usr/bin/
rm -rf /usr/bin/install_docker
cp $BASEDIR/CORE/dockers/docker.service /etc/systemd/system
systemctl daemon-reload
systemctl enable docker
yes | cp $BASEDIR/CORE/config /etc/systemd/system/multi-user.target.wants/mariadb.service
systemctl daemon-reload
else
sed -ie 's/--selinux-enabled//g' /etc/sysconfig/docker
systemctl enable docker > /dev/null
service docker start > /dev/null
service docker restart > /dev/null
fi
# mysql configurations
mysql_port=3306
snmpd_port=161
firewall-cmd --zone=public --add-port=$mysql_port/tcp --permanent > /dev/null
echo -e "Opening $mysql_port port on firewalld for mysql \e[92m[OK] \e[39m"
firewall-cmd --zone=public --add-port=$snmpd_port/tcp --permanent > /dev/null
firewall-cmd --zone=public --add-port=$snmpd_port/udp --permanent > /dev/null
echo -e "Opening $snmpd_port port on firewalld for snmp \e[92m[OK] \e[39m"
firewall-cmd --reload > /dev/null
echo -e "Firewalld reloaded \e[92m[OK] \e[39m"
yes | cp $BASEDIR/CORE/config/snmpd.conf /etc/snmp/
systemctl enable snmpd
systemctl enable mariadb
mkdir -p /run/httpd
echo -e "Eyes Of Report packages installation \e[92m[OK] \e[39m"
######### VERSION ##########
echo -e "EyesOfReport Linux Release 2.2 (Vinci)" > /etc/redhat-release
cat /etc/redhat-release > /etc/issue
echo 'Kernel \r on an \m' >> /etc/issue
echo '' >> /etc/issue
echo 'EyesOfReport access : http://'`ip add show |grep "inet " |grep -v "127.0.0.1" |head -n 1 |awk '{print $2}' |awk -F "/" '{print $1}'`'/' >> /etc/issue
echo 'EyesOfReport website : http://www.eyesofnetwork.com/' >> /etc/issue
echo '' >> /etc/issue
######### VERSION ##########
cd /srv/eyesofreport/
mkdir -p ./configuration
cp $BASEDIR/CONF/eyesofreport.sh ./configuration
echo "Extracting Java archive..."
tar xvzf $BASEDIR/CORE/jdk-7u79-linux-x64.tar.gz > /dev/null
ln -s /srv/eyesofreport/jdk1.7.0_79 /srv/eyesofreport/java
echo "export JAVA_HOME=/srv/eyesofreport/java" > /etc/profile.d/java.sh
echo "export PATH=\$PATH:/srv/eyesofreport/java/bin" >> /etc/profile.d/java.sh
chmod +x /etc/profile.d/java.sh
export JAVA_HOME=/srv/eyesofreport/java
export PATH=$PATH:/srv/eyesofreport/java/bin
echo -e "Java 7 installation \e[92m[OK] \e[39m"
########################################### MYSQL INITIALSATION ######################################
PURGE_EXPECT_WHEN_DONE=0
CURRENT_MYSQL_PASSWORD=''
NEW_MYSQL_PASSWORD='root66'
service mariadb start
if [ $(mysql -e "SELECT 1 as test" | grep -c 1 2> /dev/null ) -eq 1 ]; then
CURRENT_MYSQL_PASSWORD=''
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot mysql
else
echo "Don't take into account previous mysql error, it's a test"
if [ $(MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot mysql -e "SELECT 1 as test" | grep -c 1) -eq 1 ]; then
CURRENT_MYSQL_PASSWORD=$NEW_MYSQL_PASSWORD
mysql_tzinfo_to_sql /usr/share/zoneinfo | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot mysql > /dev/null
else
echo "You currently have mysql installation with root password. Please launch mysql_secure_installation and replace current root password by \"root,66\" only for the eyes of report installation duration. You could change root password after Eyes Of Report installation"
exit 1
fi
fi
cat $BASEDIR/CORE/databases/mysqlconf.txt > /etc/my.cnf
service mariadb restart
#
# Check if expect package installed
#
if [ $(rpm -qa | grep -c expect) -eq 0 ]; then
echo "Can't find expect. Trying install it..."
yum install -y ${YUM_EOR_OPTIONS} expect >> /dev/null
fi
SECURE_MYSQL=$(expect -c "
set timeout 3
spawn mysql_secure_installation
expect \"Enter current password for root (enter for none):\"
send \"$CURRENT_MYSQL_PASSWORD\r\"
expect \"Set root password?\"
send \"Y\r\"
expect \"New password:\"
send \"$NEW_MYSQL_PASSWORD\r\"
expect \"Re-enter new password:\"
send \"$NEW_MYSQL_PASSWORD\r\"
expect \"Remove anonymous users?\"
send \"Y\r\"
expect \"Disallow root login remotely?\"
send \"n\r\"
expect \"Remove test database and access to it?\"
send \"n\r\"
expect \"Reload privilege tables now?\"
send \"Y\r\"
expect eof
")
echo -e "Mysql configuration \e[92m[OK] \e[39m"
########################## INSTALL INITIAL DATABASES #########################
#Create databases
NEW_MYSQL_PASSWORD=root66
if [ $(MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot -e 'SHOW DATABASES' | grep -c 'global_nagiosbp') -eq 0 ]; then
echo "CREATE DATABASE global_nagiosbp;" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
fi
if [ $(MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot -e 'SHOW DATABASES' | grep -c 'thruk') -eq 0 ]; then
echo "CREATE DATABASE thruk;" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
fi
if [ $(MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot -e 'SHOW DATABASES' | grep -c 'eor_ods') -eq 0 ]; then
echo "CREATE DATABASE eor_ods;" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
fi
if [ $(MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot -e 'SHOW DATABASES' | grep -c 'eor_dwh') -eq 0 ]; then
echo "CREATE DATABASE eor_dwh;" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
fi
if [ $(MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot -e 'SHOW DATABASES' | grep -c 'eyesofreport') -eq 0 ]; then
echo "CREATE DATABASE eyesofreport;" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
fi
if [ $(MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot -e 'SHOW DATABASES' | grep -c 'bp_group_lilac') -eq 0 ]; then
echo "CREATE DATABASE bp_group_lilac;" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
fi
#Create eyesofreport user
if [ $(MYSQL_PWD=root66 mysql -e "select user from mysql.user where user = 'eyesofreport' and host = 'localhost'" | grep -c eyesofreport) -eq 0 ]; then
echo "CREATE USER 'eyesofreport'@'localhost' IDENTIFIED BY 'SaintThomas,2014'" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
fi
#Grant privileges to eyesofreport user
echo "GRANT ALL PRIVILEGES on global_nagiosbp.* to 'eyesofreport'@'localhost';" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
echo "GRANT ALL PRIVILEGES on thruk.* to 'eyesofreport'@'localhost';" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
echo "GRANT ALL PRIVILEGES on eor_ods.* to 'eyesofreport'@'localhost';" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
echo "GRANT ALL PRIVILEGES on eor_dwh.* to 'eyesofreport'@'localhost';" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
echo "GRANT ALL PRIVILEGES on eyesofreport.* to 'eyesofreport'@'localhost';" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
echo "GRANT ALL PRIVILEGES on bp_group_lilac.* to 'eyesofreport'@'localhost';" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
echo "FLUSH PRIVILEGES;" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot
#Import database script
MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot global_nagiosbp < $BASEDIR/CORE/databases/global_nagiosbp.sql
MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_ods < $BASEDIR/CORE/databases/eor_ods.sql
MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_dwh < $BASEDIR/CORE/databases/eor_dwh.sql
MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eyesofreport < $BASEDIR/CORE/databases/eyesofreport.sql
MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot bp_group_lilac < $BASEDIR/CORE/databases/bp_group_lilac.sql
#Fill time database
cd $BASEDIR/CORE/databases/
unzip ./d_time_dimension.zip > /dev/null
MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_dwh < $BASEDIR/CORE/databases/d_time_dimension.sql
echo "Time dimension index creation : this step should take a few time"
echo "CREATE INDEX idx_d_time_dimension_hour on d_time_dimension(epoch_hour) using btree" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_dwh
echo "CREATE INDEX idx_d_time_dimension_day on d_time_dimension(epoch_day) using btree" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_dwh
echo "CREATE INDEX idx_d_time_dimension_month on d_time_dimension(epoch_month) using btree" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_dwh
echo "CREATE INDEX idx_d_time_dimension_month_hour on d_time_dimension(epoch_month_hour) using btree" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_dwh
echo "CREATE INDEX td_dbdate_idx on d_time_dimension(db_datetime) using btree" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_dwh
echo "CREATE INDEX idx_d_time_dimension_year on d_time_dimension(year) using btree" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_dwh
echo "CREATE INDEX idx_d_time_dimension_month_num on d_time_dimension(month) using btree" | MYSQL_PWD=$NEW_MYSQL_PASSWORD mysql -uroot eor_dwh
echo -e "Technical databases installed \e[92m[OK] \e[39m"
########################################### Initialise basic containers #####################################
cd $BASEDIR/CORE/dockers
echo -e "Import container centos_systemd..."
unzip ./centos_1503.zip
docker load < $BASEDIR/CORE/dockers/centos_1503.tar
docker load < $BASEDIR/CORE/dockers/busybox.tar
OUT=$?
if [ ! $OUT -eq 0 ]; then
echo -e "Import container centos_systemd \e[31m[FAILED] \e[39m"
exit 1
else
echo -e "Import container centos_systemd \e[92m[OK] \e[39m"
fi
echo -e "Core installation \e[92m[FINISHED] \e[39m"
$BASEDIR/ETL/install_pentaho.sh
OUT=$?
if [ ! $OUT -eq 0 ]; then
echo -e " \e[31m[FAILED] \e[39m"
exit 1
else
echo -e "ETL part installation \e[92m[SUCCESS] \e[39m"
fi
$BASEDIR/REPORTING/install_reporting.sh
OUT=$?
if [ ! $OUT -eq 0 ]; then
echo -e " \e[31m[FAILED] \e[39m"
exit 1
else
echo -e "Reporting part installation \e[92m[SUCCESS] \e[39m"
fi
$BASEDIR/WEB/install_web.sh
OUT=$?
if [ ! $OUT -eq 0 ]; then
echo -e " \e[31m[FAILED] \e[39m"
exit 1
else
echo -e "EOR Web part installation \e[92m[SUCCESS] \e[39m"
echo -e "Eyes Of Report installation \e[92m[FINISHED] \e[39m"
fi
#Copy source creation folder in /srv/eyesofreport/
mkdir /srv/eyesofreport/external_connection
cp -r $BASEDIR/SOURCES/* /srv/eyesofreport/external_connection
while true; do
read -p " To finish the installation you need to reboot the machine. Do you want to reboot now? " yn
case $yn in
[Yy]*) reboot;break;;
[Nn]*) exit 0;;
*) echo "Please type y or n";;
esac
done