============================================================
       INSTALLATION GUIDE - FLEET NODE AGENT
============================================================

This script is meant to be installed on each remote node
(e.g., Raspberry Pi, MMDVM host). [cite: 11]

------------------------------------------------------------
0. IMPORTANT: ROOT PRIVILEGES
------------------------------------------------------------
All installation steps must be executed as the "root" user.
Before starting, elevate your privileges by running:
   sudo su

------------------------------------------------------------
1. PRE-REQUISITES & INSTALLATION
------------------------------------------------------------
Ensure Python 3 is installed. [cite: 12]

Install dependencies:
   sudo git clone https://git.arifvg.it/iv3jdv/fleet-node-agent.git /opt/fleet-node-agent
   cd /opt/fleet-node-agent
   sudo python3 -m venv venv
   source venv/bin/activate
   pip install -r requirements.txt [cite: 12]

------------------------------------------------------------
2. CONFIGURATION (CRITICAL STEPS)
------------------------------------------------------------
A) MAIN CONFIG:
   cp node_config.json.example node_config.json
   Edit 'node_config.json' with a unique 'client_id' and
   your MQTT broker credentials. [cite: 13]

B) MONITORING PROCESSES (process_list.txt):
   cp process_list.txt.example process_list.txt
   Add the names of services you want to monitor (one per line). [cite: 8]
   Example: mmdvmhost

C) REMOTE EDITING FILES (file_list.txt):
   cp file_list.txt.example file_list.txt
   Add the full absolute paths of the .ini files you want 
   to edit remotely from the dashboard. [cite: 10]
   Example: /etc/MMDVMHost.ini

D) OPTIONAL:
   Install 'RPi.GPIO' if you want hardware reset. [cite: 14]

E) MULTIPLE PROFILES (Dynamic Profiles):
   In 'node_config.json', you can define custom setup profiles
   under the "profiles" block. The web dashboard will automatically 
   generate a dedicated button for each profile you define here.
   If you don't need this feature, simply leave it empty:
   "profiles": {}

F) HARDWARE RESET CONFIGURATION:
   In 'node_config.json' under "settings", define your hardware 
   reset method to recover stuck modems automatically:
   - For USB modems: set "usb_reset_id" (e.g., "0483:374b").
   - For GPIO HATs: set "gpio_reset_pin" (e.g., 21).
   Leave "usb_reset_id" empty ("") to force GPIO usage.

------------------------------------------------------------
3. RUNNING AS A SERVICE (SYSTEMD)
------------------------------------------------------------
1. cp fleet-agent.service /etc/systemd/system/
2. systemctl daemon-reload
3. systemctl enable fleet-agent
4. systemctl start fleet-agent


============================================================
       GUIDA ALL'INSTALLAZIONE - AGENTE REMOTO
============================================================

Questo script va installato su ogni nodo remoto 
(es. Raspberry Pi, MMDVM host). [cite: 11]

------------------------------------------------------------
0. IMPORTANTE: PRIVILEGI DI ROOT
------------------------------------------------------------
Tutti i passaggi di installazione devono essere eseguiti 
come utente "root". Prima di iniziare, eleva i tuoi privilegi:
   sudo su

------------------------------------------------------------
1. REQUISITI E INSTALLAZIONE
------------------------------------------------------------
Assicurarsi di avere Python 3 installato. [cite: 15]

Installazione:
   sudo git clone https://git.arifvg.it/iv3jdv/fleet-node-agent.git /opt/fleet-node-agent
   cd /opt/fleet-node-agent
   sudo python3 -m venv venv
   source venv/bin/activate
   pip install -r requirements.txt [cite: 15]

------------------------------------------------------------
2. CONFIGURAZIONE (PASSAGGI CRITICI)
------------------------------------------------------------
A) CONFIGURAZIONE PRINCIPALE:
   cp node_config.json.example node_config.json
   Modifica 'node_config.json' inserendo un 'client_id'
   univoco e i dati del server MQTT. [cite: 16]

B) MONITORAGGIO PROCESSI (process_list.txt):
   cp process_list.txt.example process_list.txt
   Aggiungi i nomi dei servizi da monitorare (uno per riga). [cite: 8]
   Esempio: mmdvmhost

C) EDITING FILE REMOTO (file_list.txt):
   cp file_list.txt.example file_list.txt
   Aggiungi i percorsi assoluti dei file .ini che desideri
   poter modificare remotamente dalla dashboard. [cite: 10]
   Esempio: /etc/MMDVMHost.ini

D) OPZIONALE:
   Installa 'RPi.GPIO' per il reset hardware. [cite: 17]

E) PROFILI MULTIPLI (Dynamic Profiles):
   In 'node_config.json', puoi definire profili personalizzati
   sotto il blocco "profiles". La dashboard web genererà in 
   automatico un tasto dedicato per ogni profilo inserito.
   Se non ti serve questa funzione, lascialo vuoto:
   "profiles": {}

F) CONFIGURAZIONE RESET HARDWARE:
   In 'node_config.json' sotto "settings", definisci il metodo 
   di reset per sbloccare i modem bloccati:
   - Per modem USB: imposta "usb_reset_id" (es. "0483:374b").
   - Per HAT GPIO: imposta "gpio_reset_pin" (es. 21).
   Lascia "usb_reset_id" vuoto ("") per forzare l'uso del GPIO.

------------------------------------------------------------
3. ESECUZIONE COME SERVIZIO (SYSTEMD)
------------------------------------------------------------
1. cp fleet-agent.service /etc/systemd/system/
2. systemctl daemon-reload
3. systemctl enable fleet-agent
4. systemctl start fleet-agent
============================================================
