-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·61 lines (58 loc) · 2.17 KB
/
setup.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
#!/bin/bash
# Created by : Akhid Yanuar A.F
# Github : github.com/yanuarakhid
#
# 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 3 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Nagios 4 Instalation Setup
# Updating Repository
echo -e "\e[32mUpdating Repository\e[39m"
apt update
# Instalation Dependencies
echo -e "\e[32mInstalling Dependencies\e[39m"
apt install -y apache2 figlet apache2-utils php build-essential autoconf gcc libc6 make wget unzip make libssl-dev wget bc gawk dc snmp libnet-snmp-perl gettext
echo -e "\e[32mCreating Nagios User and Group\e[39m"
useradd nagios && groupadd nagcmd
usermod -a -G nagcmd nagios && usermod -a -G nagcmd www-data
echo -e "\e[32mBegin Install and Build Nagios\e[39m"
cp nagioscore.tar.gz /tmp
cp nagios-plugins.tar.gz /tmp
cd /tmp
tar xzf nagioscore.tar.gz
cd nagioscore-nagios-4.4.6/
./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=/etc/apache2/sites-enabled/
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
a2enmod rewrite && a2enmod cgi
echo -e "\e[32mCreate Nagios Admin Password\e[39m"
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
cd ..
tar zxf nagios-plugins.tar.gz
cd nagios-plugins-release-2.3.3/
./tools/setup
./configure
make
make install
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
systemctl enable nagios
systemctl start nagios
systemctl restart apache2
cd ~
figlet "Installation Completed !"
echo -e "\e[32mYou can access the nagios web interface by accessing http://ip-address/nagios"
echo -e "Login with username=nagiosadmin and password=[you made before]\e[39m"