-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathpre-conf.sh
55 lines (47 loc) · 2.31 KB
/
pre-conf.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
#!/bin/bash
#reason of this script is that dockerfile only execute one command at the time but we need sometimes at the moment we create
#the docker image to run more that one software for expecified configuration like when you need mysql running to chnage or create
#database for the container ...
useradd --system --home /usr/local/nagios -M nagios
groupadd --system nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data
cd /tmp
wget http://switch.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.1.0/nagios-4.1.0rc1.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar -xvf nagios-4.1.0rc1.tar.gz
tar -xvf nagios-plugins-2.0.3.tar.gz
tar -xvf nrpe-2.15.tar.gz
#installing nagios
cd /tmp/nagios-4.1.0rc1
./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-mail=/usr/sbin/sendmail --with-httpd_conf=/etc/apache2/conf-available
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
mkdir -p /usr/local/nagios/var/spool
mkdir -p /usr/local/nagios/var/spool/checkresults
chown -R nagios:nagios /usr/local/nagios/var
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
#installing plugins
cd /tmp/nagios-plugins-2.0.3/
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules --enable-extra-opts
make
make install
cd /tmp/nrpe-2.15/
./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu
make all
make install-plugin
#to fix error relate to ip address of container apache2
echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf
ln -s /etc/apache2/conf-available/fqdn.conf /etc/apache2/conf-enabled/fqdn.conf
a2enmod cgi
htpasswd -b -c /usr/local/nagios/etc/htpasswd.users nagiosadmin admin
sed -i 's/#Include.*/Include conf-available\/nagios.conf/' /etc/apache2/sites-enabled/000-default.conf
rm -rf /tmp/* /var/tmp/*