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
This commit is contained in:
parent
4d9fcd472e
commit
7c204c62b2
@ -26,16 +26,32 @@ Timer che esegue il cleanup **ogni ora alle XX:10** (es. 10:10, 11:10, 12:10...)
|
|||||||
|
|
||||||
## 🚀 Installazione
|
## 🚀 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
|
```bash
|
||||||
cd /opt/ids
|
cd /opt/ids
|
||||||
|
|
||||||
# Esegui setup automatico
|
# Esegui setup automatico (installa dipendenze + configura timer)
|
||||||
sudo ./deployment/setup_cleanup_timer.sh
|
sudo ./deployment/setup_cleanup_timer.sh
|
||||||
|
|
||||||
# Output:
|
# Output:
|
||||||
|
# [1/7] Installazione dipendenze Python...
|
||||||
|
# [2/7] Creazione directory log...
|
||||||
|
# ...
|
||||||
# ✅ Cleanup timer installato e avviato con successo!
|
# ✅ Cleanup timer installato e avviato con successo!
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Nota**: Lo script installa automaticamente le dipendenze Python necessarie.
|
||||||
|
|
||||||
## 📊 Monitoraggio
|
## 📊 Monitoraggio
|
||||||
|
|
||||||
### Stato Timer
|
### Stato Timer
|
||||||
|
|||||||
@ -19,31 +19,42 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
echo "🔧 Setup IDS Cleanup Timer..."
|
echo "🔧 Setup IDS Cleanup Timer..."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# 1. Crea directory log
|
# 1. Installa dipendenze Python
|
||||||
echo "[1/6] Creazione directory log..."
|
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
|
mkdir -p /var/log/ids
|
||||||
chmod 755 /var/log/ids
|
chmod 755 /var/log/ids
|
||||||
|
|
||||||
# 2. Rendi eseguibili gli script
|
# 3. Rendi eseguibili gli script
|
||||||
echo "[2/6] Permessi esecuzione script..."
|
echo "[3/7] Permessi esecuzione script..."
|
||||||
chmod +x "$SCRIPT_DIR/run_cleanup.sh"
|
chmod +x "$SCRIPT_DIR/run_cleanup.sh"
|
||||||
chmod +x "$SCRIPT_DIR/../python_ml/cleanup_detections.py"
|
chmod +x "$SCRIPT_DIR/../python_ml/cleanup_detections.py"
|
||||||
|
|
||||||
# 3. Copia service file
|
# 4. Copia service file
|
||||||
echo "[3/6] Installazione service file..."
|
echo "[4/7] Installazione service file..."
|
||||||
cp "$SCRIPT_DIR/systemd/ids-cleanup.service" /etc/systemd/system/
|
cp "$SCRIPT_DIR/systemd/ids-cleanup.service" /etc/systemd/system/
|
||||||
cp "$SCRIPT_DIR/systemd/ids-cleanup.timer" /etc/systemd/system/
|
cp "$SCRIPT_DIR/systemd/ids-cleanup.timer" /etc/systemd/system/
|
||||||
|
|
||||||
# 4. Reload systemd
|
# 5. Reload systemd
|
||||||
echo "[4/6] Reload systemd daemon..."
|
echo "[5/7] Reload systemd daemon..."
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
# 5. Abilita timer
|
# 6. Abilita timer
|
||||||
echo "[5/6] Abilitazione timer..."
|
echo "[6/7] Abilitazione timer..."
|
||||||
systemctl enable ids-cleanup.timer
|
systemctl enable ids-cleanup.timer
|
||||||
|
|
||||||
# 6. Avvia timer
|
# 7. Avvia timer
|
||||||
echo "[6/6] Avvio timer..."
|
echo "[7/7] Avvio timer..."
|
||||||
systemctl start ids-cleanup.timer
|
systemctl start ids-cleanup.timer
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user