From 7c204c62b2473d36c5675dab9c47981d96b22c0c Mon Sep 17 00:00:00 2001 From: marco370 <48531002-marco370@users.noreply.replit.com> Date: Tue, 25 Nov 2025 10:49:08 +0000 Subject: [PATCH] Add automatic Python dependency installation to setup script Modify deployment/setup_cleanup_timer.sh to automatically install Python dependencies, and update deployment/CLEANUP_DETECTIONS_GUIDE.md to reflect this change and add prerequisites. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 824b5d8d-e4c7-48ef-aff9-60efb91a2082 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/L6QSDnx --- deployment/CLEANUP_DETECTIONS_GUIDE.md | 18 ++++++++++++- deployment/setup_cleanup_timer.sh | 35 +++++++++++++++++--------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/deployment/CLEANUP_DETECTIONS_GUIDE.md b/deployment/CLEANUP_DETECTIONS_GUIDE.md index d5044ed..09fd088 100644 --- a/deployment/CLEANUP_DETECTIONS_GUIDE.md +++ b/deployment/CLEANUP_DETECTIONS_GUIDE.md @@ -26,16 +26,32 @@ Timer che esegue il cleanup **ogni ora alle XX:10** (es. 10:10, 11:10, 12:10...) ## 🚀 Installazione +### Prerequisiti +Assicurati di avere le dipendenze Python installate: +```bash +# Installa dipendenze (se non già fatto) +sudo pip3 install psycopg2-binary python-dotenv + +# Oppure usa requirements.txt +sudo pip3 install -r python_ml/requirements.txt +``` + +### Setup Automatico ```bash cd /opt/ids -# Esegui setup automatico +# Esegui setup automatico (installa dipendenze + configura timer) sudo ./deployment/setup_cleanup_timer.sh # Output: +# [1/7] Installazione dipendenze Python... +# [2/7] Creazione directory log... +# ... # ✅ Cleanup timer installato e avviato con successo! ``` +**Nota**: Lo script installa automaticamente le dipendenze Python necessarie. + ## 📊 Monitoraggio ### Stato Timer diff --git a/deployment/setup_cleanup_timer.sh b/deployment/setup_cleanup_timer.sh index e343e18..21739cb 100755 --- a/deployment/setup_cleanup_timer.sh +++ b/deployment/setup_cleanup_timer.sh @@ -19,31 +19,42 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" echo "🔧 Setup IDS Cleanup Timer..." echo "" -# 1. Crea directory log -echo "[1/6] Creazione directory log..." +# 1. Installa dipendenze Python +echo "[1/7] Installazione dipendenze Python..." +pip3 install -q psycopg2-binary python-dotenv || { + echo "⚠️ Installazione pip fallita, provo con requirements.txt..." + pip3 install -q -r "$SCRIPT_DIR/../python_ml/requirements.txt" || { + echo "❌ Errore installazione dipendenze!" + echo "💡 Esegui manualmente: sudo pip3 install psycopg2-binary python-dotenv" + exit 1 + } +} + +# 2. Crea directory log +echo "[2/7] Creazione directory log..." mkdir -p /var/log/ids chmod 755 /var/log/ids -# 2. Rendi eseguibili gli script -echo "[2/6] Permessi esecuzione script..." +# 3. Rendi eseguibili gli script +echo "[3/7] Permessi esecuzione script..." chmod +x "$SCRIPT_DIR/run_cleanup.sh" chmod +x "$SCRIPT_DIR/../python_ml/cleanup_detections.py" -# 3. Copia service file -echo "[3/6] Installazione service file..." +# 4. Copia service file +echo "[4/7] Installazione service file..." cp "$SCRIPT_DIR/systemd/ids-cleanup.service" /etc/systemd/system/ cp "$SCRIPT_DIR/systemd/ids-cleanup.timer" /etc/systemd/system/ -# 4. Reload systemd -echo "[4/6] Reload systemd daemon..." +# 5. Reload systemd +echo "[5/7] Reload systemd daemon..." systemctl daemon-reload -# 5. Abilita timer -echo "[5/6] Abilitazione timer..." +# 6. Abilita timer +echo "[6/7] Abilitazione timer..." systemctl enable ids-cleanup.timer -# 6. Avvia timer -echo "[6/6] Avvio timer..." +# 7. Avvia timer +echo "[7/7] Avvio timer..." systemctl start ids-cleanup.timer echo ""