45 lines
1.6 KiB
Bash

#!/bin/bash
PHP_VER=8.1
# Apache Setup
sudo systemctl disable nginx
sudo systemctl stop nginx
sudo systemctl enable apache2 --now
sudo certbot certonly -d demo-devops-monitoring.konnect.dev --apache
cd /etc/apache2/sites-available/
sudo nano monitoring.conf
sudo a2ensite monitoring
sudo systemctl reload apache2
# Install Icinga2
sudo apt install apt-transport-https wget gnupg curl
curl https://packages.icinga.com/icinga.key | sudo apt-key add -
echo "deb http://packages.icinga.com/ubuntu icinga-$(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/icinga2.list
echo "deb-src http://packages.icinga.com/ubuntu icinga-$(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/icinga2.list
sudo apt update
sudo apt install php${PHP_VER}-dba php${PHP_VER}-ldap php${PHP_VER}-json php${PHP_VER}-intl php${PHP_VER}-pdo-mysql php${PHP_VER}-imagick php${PHP_VER}-dom
sudo apt install icinga2 icingaweb2 monitoring-plugins icinga2-ido-mysql icinga2-ido-mysql
sudo addgroup --system icingaweb2
sudo usermod -a -G icingaweb2 www-data
sudo systemctl restart apache2
sudo icingacli setup token create
sudo systemctl enable --now icinga2
sudo systemctl enable --now apache2
sudo systemctl enable --now mysql
# SQL Commands to run
# CREATE DATABASE icingawebdb;
# GRANT ALL PRIVILEGES ON icingawebdb.* TO icingaweb@localhost IDENTIFIED BY 'password';
# GRANT ALL PRIVILEGES ON icinga2.* TO 'icinga2'@'localhost';
# exit
sudo icinga2 feature enable ido-mysql
sudo icinga2 feature enable command
sudo systemctl restart icinga2
sudo icinga2 api setup
# http://<ip_address>/icingaweb2/setup
sudo icingacli setup token create