This repository has been archived by the owner on May 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·98 lines (81 loc) · 2.79 KB
/
deploy.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
#!/bin/bash
pwd=`pwd`
# Update repos
sudo apt update
# Do full upgrade of system
sudo apt full-upgrade -y
# Remove leftover packages and purge configs
sudo apt autoremove -y --purge
# Install required packages
sudo apt install -y ufw vim wget curl build-essential unzip openssl libssl-dev apache2 php libapache2-mod-php php-gd libgd-dev unzip php-bcmath php-amqp php-curl php-cli php-zip php-mbstring
# Setup firewall
sudo ufw --force enable
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw default deny incoming
sudo ufw default allow outgoing
# Install zerotier
sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
curl -s https://install.zerotier.com | sudo bash
# Setup Central Logging
git clone [email protected]:stonX-IT490/logging.git ~/logging
cd ~/logging
chmod +x deploy.sh
./deploy.sh
cd ~/
# Setup Nagios Server
cd ~
export VER="4.4.7"
wget https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-$VER/nagios-$VER.tar.gz
tar xvzf nagios-$VER.tar.gz
cd nagios-$VER
./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make install-groups-users
sudo usermod -a -G nagios www-data
sudo make all
sudo make install
sudo make install-daemoninit
sudo make install-commandmode
sudo make install-config
sudo make install-webconf
sudo a2enmod rewrite cgi
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo chown www-data:www-data /usr/local/nagios/etc/htpasswd.users
sudo chmod 640 /usr/local/nagios/etc/htpasswd.users
# Install Nagios Plugins Bundle
cd ~
VER="2.4.0"
wget https://github.com/nagios-plugins/nagios-plugins/releases/download/release-$VER/nagios-plugins-$VER.tar.gz
tar xvf nagios-plugins-$VER.tar.gz
cd nagios-plugins-$VER
./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make
sudo make install
# Install Nagios NRPE - Remote Monitoring Plugin
cd ~
VER="4.0.3"
wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-$VER/nrpe-$VER.tar.gz
tar xvf nrpe-$VER.tar.gz
cd nrpe-$VER
./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make check_nrpe
sudo make install-plugin
# Configuring Nagios
echo 'cfg_dir=/usr/local/nagios/etc/servers' >> /usr/local/nagios/etc/nagios.cfg
sudo mkdir /usr/local/nagios/etc/servers
touch /usr/local/nagios/etc/objects/contacts.cfg
echo '
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}' >> /usr/local/nagios/etc/objects/commands.cfg
echo 'command[check_service]=sudo /usr/local/nagios/libexec/check_service -s $ARG1$'
echo '' > /usr/local/nagios/etc/objects/localhost.cfg
sudo cp $pwd/config/* /usr/local/nagios/etc/servers/
# Allow Nagios in Firewall
sudo ufw allow 80
sudo ufw reload
# Start Nagios Service
sudo systemctl restart apache2
sudo systemctl start nagios.service