This commit introduces detailed documentation for deploying the Intrusion Detection System (IDS) on AlmaLinux 9, including setup scripts, MikroTik router configuration, and update procedures via git. It also includes the syslog parser script for processing router logs and saving them to PostgreSQL. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: b2b01a4a-55da-4f33-9143-6bf0399e0a03 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/c9ITWqD
96 lines
3.4 KiB
Bash
96 lines
3.4 KiB
Bash
#!/bin/bash
|
||
|
||
# Script di installazione IDS su AlmaLinux 9
|
||
# Eseguire con: chmod +x setup_almalinux.sh && sudo ./setup_almalinux.sh
|
||
|
||
# Colori per output
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
BLUE='\033[0;34m'
|
||
NC='\033[0m'
|
||
|
||
echo -e "${BLUE}🛡️ INSTALLAZIONE IDS - INTRUSION DETECTION SYSTEM${NC}"
|
||
echo "===================================================="
|
||
|
||
# Verifica esecuzione come root
|
||
if [ "$EUID" -ne 0 ]; then
|
||
echo -e "${RED}❌ Esegui questo script come root (sudo)${NC}"
|
||
exit 1
|
||
fi
|
||
|
||
# 1. Aggiorna sistema
|
||
echo -e "\n${BLUE}📦 Aggiornamento sistema AlmaLinux 9...${NC}"
|
||
dnf update -y
|
||
|
||
# 2. Installa dipendenze sistema
|
||
echo -e "\n${BLUE}📦 Installazione dipendenze sistema...${NC}"
|
||
dnf install -y epel-release
|
||
dnf install -y python3.11 python3.11-pip nodejs npm postgresql-server postgresql-contrib git
|
||
|
||
# 3. Installa Node.js 20 (LTS)
|
||
echo -e "\n${BLUE}📦 Installazione Node.js 20...${NC}"
|
||
dnf module reset nodejs -y
|
||
dnf module enable nodejs:20 -y
|
||
dnf install -y nodejs
|
||
|
||
# 4. Inizializza PostgreSQL
|
||
echo -e "\n${BLUE}🗄️ Inizializzazione PostgreSQL...${NC}"
|
||
if [ ! -d "/var/lib/pgsql/data/base" ]; then
|
||
postgresql-setup --initdb
|
||
systemctl enable postgresql
|
||
systemctl start postgresql
|
||
echo -e "${GREEN}✅ PostgreSQL inizializzato${NC}"
|
||
else
|
||
echo -e "${YELLOW}ℹ️ PostgreSQL già inizializzato${NC}"
|
||
fi
|
||
|
||
# 5. Configura PostgreSQL
|
||
echo -e "\n${BLUE}🔧 Configurazione PostgreSQL...${NC}"
|
||
sudo -u postgres psql -c "CREATE DATABASE ids_database;" 2>/dev/null || echo "Database già esistente"
|
||
sudo -u postgres psql -c "CREATE USER ids_user WITH PASSWORD 'ids_password_change_me';" 2>/dev/null || echo "Utente già esistente"
|
||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE ids_database TO ids_user;" 2>/dev/null
|
||
|
||
# Configura pg_hba.conf per connessioni locali
|
||
PG_HBA="/var/lib/pgsql/data/pg_hba.conf"
|
||
if ! grep -q "ids_user" "$PG_HBA"; then
|
||
echo "local ids_database ids_user md5" >> "$PG_HBA"
|
||
echo "host ids_database ids_user 127.0.0.1/32 md5" >> "$PG_HBA"
|
||
systemctl restart postgresql
|
||
fi
|
||
|
||
# 6. Crea utente IDS
|
||
echo -e "\n${BLUE}👤 Creazione utente ids...${NC}"
|
||
if ! id "ids" &>/dev/null; then
|
||
useradd -m -s /bin/bash ids
|
||
echo -e "${GREEN}✅ Utente ids creato${NC}"
|
||
else
|
||
echo -e "${YELLOW}ℹ️ Utente ids già esistente${NC}"
|
||
fi
|
||
|
||
# 7. Crea directory di lavoro
|
||
echo -e "\n${BLUE}📁 Creazione directory di lavoro...${NC}"
|
||
mkdir -p /opt/ids
|
||
chown -R ids:ids /opt/ids
|
||
|
||
echo -e "\n${GREEN}✅ INSTALLAZIONE BASE COMPLETATA!${NC}"
|
||
echo ""
|
||
echo -e "${YELLOW}📋 PROSSIMI PASSI:${NC}"
|
||
echo -e " 1. Clona il repository da git.alfacom.it:"
|
||
echo -e " ${BLUE}cd /opt/ids${NC}"
|
||
echo -e " ${BLUE}sudo -u ids git clone https://git.alfacom.it/your-repo/ids.git .${NC}"
|
||
echo ""
|
||
echo -e " 2. Configura environment variables:"
|
||
echo -e " ${BLUE}sudo -u ids nano /opt/ids/.env${NC}"
|
||
echo ""
|
||
echo -e " 3. Installa dipendenze Node.js:"
|
||
echo -e " ${BLUE}cd /opt/ids && sudo -u ids npm install${NC}"
|
||
echo ""
|
||
echo -e " 4. Installa dipendenze Python:"
|
||
echo -e " ${BLUE}cd /opt/ids/python_ml && sudo -u ids pip3.11 install -r requirements.txt${NC}"
|
||
echo ""
|
||
echo -e " 5. Esegui lo script di configurazione crontab:"
|
||
echo -e " ${BLUE}cd /opt/ids/deployment && sudo ./setup_crontab.sh${NC}"
|
||
echo ""
|
||
echo -e "${GREEN}🎉 Sistema pronto per il deployment!${NC}"
|