diff --git a/src/icinga2/constants-service.conf b/src/icinga2/constants-service.conf index 0bb5011..9b581fa 100644 --- a/src/icinga2/constants-service.conf +++ b/src/icinga2/constants-service.conf @@ -8,10 +8,10 @@ # # --- Service Metadata --- -ZAMBA_SERVICE_NAME="Icinga2 Monitoring Stack (MariaDB Edition)" -ZAMBA_SERVICE_DESC="Installiert Icinga2, Icingaweb2, Director, Nginx, MariaDB, InfluxDB2 und Grafana." +ZAMBA_SERVICE_NAME="Icinga2 Stack mit IcingaDB" +ZAMBA_SERVICE_DESC="Installiert Icinga2, IcingaDB, Icingaweb2, Director, Nginx, MariaDB, Redis, InfluxDB2 und Grafana." # Tags zur besseren Filterung und Verwaltung des Containers -SERVICE_TAGS="monitoring,icinga,grafana,influxdb,nginx,mariadb" +SERVICE_TAGS="monitoring,icinga,icingadb,grafana,influxdb,nginx,mariadb,redis" # --- LXC Container Configuration --- diff --git a/src/icinga2/install-service.sh b/src/icinga2/install-service.sh index 723c390..358b310 100644 --- a/src/icinga2/install-service.sh +++ b/src/icinga2/install-service.sh @@ -3,8 +3,7 @@ # Zamba LXC Toolbox - Service Installer # Service: icinga-stack # -# Description: Führt die Installation und Konfiguration des Icinga2 Stacks mit MariaDB durch. -# Dieses Skript ist eigenständig und verwendet nur Standard-OS-Befehle. +# Description: Führt die Installation und Konfiguration des Icinga2 Stacks mit IcingaDB durch. # # --- Internal Helper Functions --- @@ -18,7 +17,7 @@ _generate_local_password() { _install() { echo "" echo "=================================================" - echo " Phase 1: Installation der Pakete (MariaDB Edition)" + echo " Phase 1: Installation der Pakete (IcingaDB Edition)" echo "=================================================" echo "" @@ -51,25 +50,29 @@ _install() { echo "[INFO] Hauptkomponenten werden installiert (PHP Version: ${PHP_VERSION})." apt-get install -y \ - icinga2 icinga2-ido-mysql \ + icinga2 \ nginx php${PHP_VERSION}-fpm php${PHP_VERSION}-mysql php${PHP_VERSION}-intl php${PHP_VERSION}-xml php${PHP_VERSION}-gd php${PHP_VERSION}-ldap php${PHP_VERSION}-imagick \ mariadb-server mariadb-client \ + redis-server \ influxdb2 \ grafana \ imagemagick \ icingaweb2 icingacli \ icinga-php-library \ icingaweb2-module-reactbundle \ - icinga-director + icinga-director \ + icingadb \ + icingadb-redis \ + icingadb-web echo "[INFO] Systemd Services werden aktiviert." - systemctl enable --now icinga2 mariadb nginx php${PHP_VERSION}-fpm influxdb grafana-server + systemctl enable --now icinga2 mariadb redis-server nginx php${PHP_VERSION}-fpm influxdb grafana-server icingadb } _configure() { echo "" echo "=================================================" - echo " Phase 2: Konfiguration der Komponenten (MariaDB Edition)" + echo " Phase 2: Konfiguration der Komponenten (IcingaDB Edition)" echo "=================================================" echo "" @@ -77,7 +80,7 @@ _configure() { echo "[INFO] Passwörter und API-Keys werden generiert." ICINGAWEB_DB_PASS=$(_generate_local_password 24) DIRECTOR_DB_PASS=$(_generate_local_password 24) - ICINGA_IDO_DB_PASS=$(_generate_local_password 24) + ICINGADB_PASS=$(_generate_local_password 24) ICINGA_API_USER_PASS=$(_generate_local_password 24) ICINGAWEB_ADMIN_PASS=$(_generate_local_password 16) GRAFANA_ADMIN_PASS=$(_generate_local_password 16) @@ -87,15 +90,15 @@ _configure() { echo "[INFO] MariaDB wird konfiguriert." mysql -e "CREATE DATABASE IF NOT EXISTS icingaweb2 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" mysql -e "CREATE DATABASE IF NOT EXISTS director CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" - mysql -e "CREATE DATABASE IF NOT EXISTS icinga_ido CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" + mysql -e "CREATE DATABASE IF NOT EXISTS icingadb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" mysql -e "CREATE USER IF NOT EXISTS 'icingaweb2'@'localhost' IDENTIFIED BY '${ICINGAWEB_DB_PASS}';" mysql -e "CREATE USER IF NOT EXISTS 'director'@'localhost' IDENTIFIED BY '${DIRECTOR_DB_PASS}';" - mysql -e "CREATE USER IF NOT EXISTS 'icinga_ido'@'localhost' IDENTIFIED BY '${ICINGA_IDO_DB_PASS}';" + mysql -e "CREATE USER IF NOT EXISTS 'icingadb'@'localhost' IDENTIFIED BY '${ICINGADB_PASS}';" mysql -e "GRANT ALL PRIVILEGES ON icingaweb2.* TO 'icingaweb2'@'localhost';" mysql -e "GRANT ALL PRIVILEGES ON director.* TO 'director'@'localhost';" - mysql -e "GRANT ALL PRIVILEGES ON icinga_ido.* TO 'icinga_ido'@'localhost';" + mysql -e "GRANT ALL PRIVILEGES ON icingadb.* TO 'icingadb'@'localhost';" mysql -e "FLUSH PRIVILEGES;" # 3. InfluxDB 2 konfigurieren @@ -117,12 +120,12 @@ _configure() { # 5. Icinga2 Konfigurationsdateien schreiben echo "[INFO] Icinga2 Konfigurationsdateien werden geschrieben." - bash -c "cat > /etc/icinga2/features-available/ido-mysql.conf" < /etc/icinga2/features-available/icingadb.conf" < /etc/icinga2/conf.d/api-users.conf" < /etc/icinga2/zones.conf" < /etc/icingadb/config.yml" < /etc/icingaweb2/resources.ini" <&2; exit 1; fi if [ ! -f "$IWEB_SCHEMA" ]; then echo "[ERROR] IcingaWeb-Schema nicht gefunden: $IWEB_SCHEMA" >&2; exit 1; fi if [ ! -f "$DIRECTOR_SCHEMA" ]; then echo "[ERROR] Director-Schema nicht gefunden: $DIRECTOR_SCHEMA" >&2; exit 1; fi - - if ! mysql -e "use icinga_ido; show tables;" | grep -q "icinga_dbversion"; then - echo "[INFO] Importiere Icinga IDO-Schema..." - mysql icinga_ido < "$IDO_SCHEMA" - fi + if [ ! -f "$ICINGADB_SCHEMA" ]; then echo "[ERROR] IcingaDB-Schema nicht gefunden: $ICINGADB_SCHEMA" >&2; exit 1; fi if ! mysql -e "use icingaweb2; show tables;" | grep -q "icingaweb_user"; then echo "[INFO] Importiere IcingaWeb2-Schema..." @@ -289,8 +293,13 @@ _setup() { mysql director < "$DIRECTOR_SCHEMA" fi + if ! mysql -e "use icingadb; show tables;" | grep -q "icingadb_schema_migration"; then + echo "[INFO] Importiere IcingaDB-Schema..." + mysql icingadb < "$ICINGADB_SCHEMA" + fi + echo "[INFO] Icinga2 Features werden aktiviert." - icinga2 feature enable ido-mysql api influxdb2-writer >/dev/null + icinga2 feature enable icingadb api influxdb2-writer >/dev/null echo "[INFO] Erstelle Icinga Web 2 Kernkonfiguration." bash -c "cat > /etc/icingaweb2/config.ini" < /etc/icingaweb2/authentication.ini" < /etc/icingaweb2/roles.ini" < /etc/icingaweb2/modules/monitoring/config.ini" < /etc/icingaweb2/modules/monitoring/backends.ini" < /etc/icingaweb2/modules/director/config.ini" <