ids.alfacom.it/deployment/update_from_git.sh
marco370 fcd4bbf2b2 Add comprehensive deployment and configuration guides for the IDS system
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
2025-11-15 11:30:55 +00:00

81 lines
2.3 KiB
Bash

#!/bin/bash
# Script per aggiornare il sistema IDS da git.alfacom.it
# Eseguire con: sudo -u ids ./update_from_git.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}🔄 AGGIORNAMENTO SISTEMA IDS DA GIT${NC}"
echo "===================================="
IDS_DIR="/opt/ids"
cd "$IDS_DIR" || exit 1
# Backup configurazione locale
echo -e "\n${BLUE}💾 Backup configurazione locale...${NC}"
if [ -f ".env" ]; then
cp .env .env.backup
echo -e "${GREEN}✅ .env salvato in .env.backup${NC}"
fi
# Verifica modifiche locali
echo -e "\n${BLUE}🔍 Verifica modifiche locali...${NC}"
if ! git diff-index --quiet HEAD --; then
echo -e "${YELLOW}⚠️ Ci sono modifiche locali non committate${NC}"
echo -e "${YELLOW} Esegui 'git status' per vedere i dettagli${NC}"
read -p "Vuoi procedere comunque? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Pull da git
echo -e "\n${BLUE}📥 Download aggiornamenti da git.alfacom.it...${NC}"
git fetch origin
git pull origin main
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Aggiornamenti scaricati con successo${NC}"
else
echo -e "${RED}❌ Errore durante il download${NC}"
exit 1
fi
# Ripristina configurazione locale
if [ -f ".env.backup" ]; then
cp .env.backup .env
echo -e "${GREEN}✅ Configurazione locale ripristinata${NC}"
fi
# Aggiorna dipendenze Node.js
echo -e "\n${BLUE}📦 Aggiornamento dipendenze Node.js...${NC}"
npm install
# Aggiorna dipendenze Python
echo -e "\n${BLUE}📦 Aggiornamento dipendenze Python...${NC}"
cd python_ml
/usr/bin/python3.11 -m pip install -r requirements.txt
cd ..
# Aggiorna schema database
echo -e "\n${BLUE}🗄️ Aggiornamento schema database...${NC}"
npm run db:push
# Restart servizi
echo -e "\n${BLUE}🔄 Restart servizi...${NC}"
./deployment/restart_all.sh
echo -e "\n${GREEN}✅ AGGIORNAMENTO COMPLETATO!${NC}"
echo ""
echo -e "${YELLOW}📋 VERIFICA:${NC}"
echo -e " • Controlla log backend: ${BLUE}tail -f /var/log/ids/backend.log${NC}"
echo -e " • Controlla log frontend: ${BLUE}tail -f /var/log/ids/frontend.log${NC}"
echo -e " • Testa API backend: ${BLUE}curl http://localhost:8000/health${NC}"
echo -e " • Testa frontend: ${BLUE}curl http://localhost:5000${NC}"