diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e0d65bb --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.backup/ +__pycache__/ +*.pyc +.DS_Store diff --git a/README.md b/README.md index 67fd242..668a08f 100644 --- a/README.md +++ b/README.md @@ -4,25 +4,61 @@ Tecnotel Servizi SRL — [www.tecnotelsrl.com](https://www.tecnotelsrl.com) Repository pubblico contenente l'installer di prima fase e il Web Setup Wizard di ARGOS SOC. +## Installazione rapida (one-liner) + +Su una macchina Ubuntu 24.04 LTS vergine, esegui: + +```bash +curl -fsSL https://argos-update.tecnotelsrl.com/tecnotel/argos-setup/raw/branch/main/bootstrap.sh | sudo bash +``` + +Il bootstrap scaricherà il repository e avvierà `first-setup.sh`. + +## Installazione manuale + +Se preferisci eseguire gli step separatamente: + +```bash +sudo apt update && sudo apt install -y git +git clone https://argos-update.tecnotelsrl.com/tecnotel/argos-setup.git /opt/argos-setup-pkg +cd /opt/argos-setup-pkg +sudo bash first-setup.sh +``` + ## Contenuto | File | Scopo | |---|---| -| `first-setup.sh` | Installer ambiente di prima fase: sistema base, utenti, firewall, virtualenv, nginx. | -| `setup_server.py` | Backend Flask del Web Installer (porta 8888). | -| `setup.html` | Frontend del Web Installer, wizard in 5 step. | -| `gen_config.py` | Helper per generazione iniziale di `argos.json`. | +| `bootstrap.sh` | One-liner installer: scarica il repo e avvia first-setup.sh | +| `first-setup.sh` | Installer ambiente base: sistema, utenti, firewall, nginx temp, avvia wizard web | +| `setup_server.py` | Backend Python del Web Installer (porta 8888, self-contained) | +| `setup.html` | Frontend del Web Installer — wizard in 6 step | +| `gen_config.py` | Helper per generazione iniziale di `argos.json` | ## Flusso d'installazione -1. Il cliente esegue `first-setup.sh` per predisporre l'ambiente base (Ubuntu 24.04). -2. Al termine dello script viene avviato il Web Installer su `http://IP:8888`. -3. Il wizard completa la configurazione: cliente, rete/SSL, SIEM, utente admin. -4. Al termine del wizard, `argos-setup` richiede la licenza ARGOS per sbloccare il clone del repository privato `tecnotel/argos` e completare l'installazione dei componenti runtime. +1. Il cliente esegue il bootstrap (o il clone manuale + first-setup.sh). +2. `first-setup.sh` predispone l'ambiente base Ubuntu 24.04 (pacchetti, utente argos, cartelle, firewall) e avvia il Web Installer su `http://IP:8888`. +3. Il cliente apre il browser e segue il wizard in 6 step: + 1. **Licenza ARGOS** — il wizard mostra il `machine_id` di questo server. Il cliente lo invia a Tecnotel, riceve `license.json`, lo carica nel wizard. + 2. **Informazioni cliente** (nome, dominio, logo) + 3. **Rete & SSL** (hostname, certificato) + 4. **SIEM** (OpenSearch) + 5. **Utente admin** + 6. **Riepilogo & Installazione** — il wizard clona il repository privato `tecnotel/argos` usando il token della licenza, crea virtualenv, configura servizi e avvia ARGOS SOC. + +Al termine il Web Installer viene disattivato automaticamente e la porta 8888 chiusa. + +## Requisiti + +- Ubuntu 24.04 LTS (verificato dallo script) +- Accesso root (sudo) +- Connessione internet verso `argos-update.tecnotelsrl.com` +- Una licenza ARGOS valida emessa da Tecnotel per il `machine_id` del server ## Repository correlati -- [`tecnotel/argos`](https://argos-update.tecnotelsrl.com/tecnotel/argos) — codice runtime di ARGOS SOC (privato). +- [`tecnotel/argos`](https://argos-update.tecnotelsrl.com/tecnotel/argos) — codice runtime di ARGOS SOC (privato, accessibile solo con licenza). ## Versioning diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..28ccd29 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# ══════════════════════════════════════════════════════════════════════════════ +# ARGOS SOC — Bootstrap Installer (one-liner) +# Tecnotel Servizi SRL — Ubuntu 24.04 LTS +# +# Uso tramite one-liner: +# curl -fsSL https://argos-update.tecnotelsrl.com/tecnotel/argos-setup/raw/branch/main/bootstrap.sh | sudo bash +# +# Oppure manuale (raccomandato per verifica): +# curl -fsSLo /tmp/argos-bootstrap.sh https://argos-update.tecnotelsrl.com/tecnotel/argos-setup/raw/branch/main/bootstrap.sh +# less /tmp/argos-bootstrap.sh # verifica cosa fa +# sudo bash /tmp/argos-bootstrap.sh +# ══════════════════════════════════════════════════════════════════════════════ +set -euo pipefail + +RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m' +BLUE='\033[0;34m'; CYAN='\033[0;36m'; NC='\033[0m' +info() { echo -e "${CYAN}[INFO]${NC} $1"; } +success() { echo -e "${GREEN}[OK]${NC} $1"; } +warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } +error() { echo -e "${RED}[ERROR]${NC} $1" >&2; exit 1; } + +# ── Check privilegi e OS ────────────────────────────────────────────────────── +[[ $EUID -ne 0 ]] && error "Eseguire come root (sudo)." + +if [[ ! -f /etc/os-release ]]; then + error "OS non riconosciuto: /etc/os-release mancante." +fi +. /etc/os-release +if [[ "$ID" != "ubuntu" || "$VERSION_ID" != "24.04" ]]; then + error "Richiesto Ubuntu 24.04 LTS (trovato: $ID $VERSION_ID)." +fi + +echo "" +echo -e "${BLUE}╔══════════════════════════════════════════════════╗${NC}" +echo -e "${BLUE}║ ARGOS SOC — Bootstrap Installer ║${NC}" +echo -e "${BLUE}║ Tecnotel Servizi SRL ║${NC}" +echo -e "${BLUE}╚══════════════════════════════════════════════════╝${NC}" +echo "" + +# ── Variabili ──────────────────────────────────────────────────────────────── +SETUP_REPO_URL="https://argos-update.tecnotelsrl.com/tecnotel/argos-setup.git" +SETUP_DIR="/opt/argos-setup-pkg" + +# ── Install git se mancante ────────────────────────────────────────────────── +if ! command -v git >/dev/null 2>&1; then + info "Git non installato — installo..." + apt-get update -qq + apt-get install -y -qq git + success "Git installato" +else + info "Git gia' presente ($(git --version | awk '{print $3}'))" +fi + +# ── Scarica o aggiorna argos-setup ─────────────────────────────────────────── +if [[ -d "$SETUP_DIR/.git" ]]; then + info "argos-setup gia' presente in $SETUP_DIR — aggiorno..." + git -C "$SETUP_DIR" pull --ff-only origin main + success "argos-setup aggiornato" +else + info "Scarico argos-setup da $SETUP_REPO_URL..." + rm -rf "$SETUP_DIR" + git clone --depth=1 "$SETUP_REPO_URL" "$SETUP_DIR" + success "argos-setup scaricato in $SETUP_DIR" +fi + +# ── Verifica presenza file attesi ──────────────────────────────────────────── +for f in first-setup.sh setup_server.py setup.html; do + if [[ ! -f "$SETUP_DIR/$f" ]]; then + error "File $f mancante in $SETUP_DIR — repo argos-setup incompleto?" + fi +done + +# ── Lancia first-setup.sh ──────────────────────────────────────────────────── +info "Avvio installer principale..." +echo "" +cd "$SETUP_DIR" +exec bash ./first-setup.sh diff --git a/first-setup.sh b/first-setup.sh old mode 100644 new mode 100755 index 9d2b704..77bbb42 --- a/first-setup.sh +++ b/first-setup.sh @@ -2,7 +2,7 @@ # ══════════════════════════════════════════════════════════════════════════════ # ARGOS SOC — Installer ambiente # Tecnotel Servizi SRL — Ubuntu 24.04 LTS -# Uso: sudo bash install.sh +# Uso: sudo bash first-setup.sh # ══════════════════════════════════════════════════════════════════════════════ set -euo pipefail @@ -14,20 +14,18 @@ warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; } section() { echo -e "\n${BLUE}══════════════════════════════════════${NC}"; echo -e "${BLUE} $1${NC}"; echo -e "${BLUE}══════════════════════════════════════${NC}"; } -[[ $EUID -ne 0 ]] && error "Eseguire come root: sudo bash install.sh" +[[ $EUID -ne 0 ]] && error "Eseguire come root: sudo bash first-setup.sh" . /etc/os-release [[ "$ID" != "ubuntu" || "$VERSION_ID" != "24.04" ]] && error "Richiesto Ubuntu 24.04 LTS" echo "" echo -e "${BLUE}╔══════════════════════════════════════════╗${NC}" -echo -e "${BLUE}║ ARGOS SOC — Installer v1.0.0 ║${NC}" +echo -e "${BLUE}║ ARGOS SOC — Setup ambiente base ║${NC}" echo -e "${BLUE}║ Tecnotel Servizi SRL ║${NC}" echo -e "${BLUE}╚══════════════════════════════════════════╝${NC}" echo "" -GITEA_REPO="https://3eefb5a2802e8c5a9395396b1bb98e2d5fe46101@argos-update.tecnotelsrl.com:3443/tecnotel/argos.git" - # ══════════════════════════════════════════════════════════════════════════════ section "1. Sistema base" # ══════════════════════════════════════════════════════════════════════════════ @@ -36,7 +34,7 @@ apt-get update -qq apt-get upgrade -y -qq apt-get install -y -qq \ curl wget git vim htop unzip jq \ - python3 python3-pip python3-venv \ + python3 python3-pip python3-venv python3-cryptography \ nginx certbot python3-certbot-nginx \ ufw fail2ban \ build-essential libssl-dev libffi-dev python3-dev \ @@ -92,33 +90,7 @@ chmod 755 /opt/argos/feeds success "Struttura /opt/argos/ creata" # ══════════════════════════════════════════════════════════════════════════════ -section "5. Clone repository" -# ══════════════════════════════════════════════════════════════════════════════ -git config --global --add safe.directory /opt/argos/app 2>/dev/null || true -if [[ -d /opt/argos/app/.git ]]; then - warn "Repository già presente — aggiorno" - git -C /opt/argos/app pull origin main -else - git clone "$GITEA_REPO" /opt/argos/app -fi -chown -R argos:argos /opt/argos/app -success "Repository clonato in /opt/argos/app/" - -# ══════════════════════════════════════════════════════════════════════════════ -section "6. Python virtualenv" -# ══════════════════════════════════════════════════════════════════════════════ -python3 -m venv /opt/argos/app/backend/venv -/opt/argos/app/backend/venv/bin/pip install --upgrade pip -q -if [[ -f /opt/argos/app/backend/requirements.txt ]]; then - /opt/argos/app/backend/venv/bin/pip install -r /opt/argos/app/backend/requirements.txt -q - success "Dipendenze Python installate" -else - warn "requirements.txt non trovato — installare manualmente dopo" -fi -chown -R argos:argos /opt/argos/app/backend/venv - -# ══════════════════════════════════════════════════════════════════════════════ -section "7. Firewall UFW" +section "5. Firewall UFW" # ══════════════════════════════════════════════════════════════════════════════ ufw --force reset >/dev/null ufw default deny incoming >/dev/null @@ -131,13 +103,13 @@ ufw --force enable >/dev/null success "Firewall UFW configurato" # ══════════════════════════════════════════════════════════════════════════════ -section "8. Fail2ban" +section "6. Fail2ban" # ══════════════════════════════════════════════════════════════════════════════ systemctl enable --now fail2ban >/dev/null 2>&1 success "Fail2ban attivo" # ══════════════════════════════════════════════════════════════════════════════ -section "9. Nginx temporaneo" +section "7. Nginx temporaneo" # ══════════════════════════════════════════════════════════════════════════════ rm -f /etc/nginx/sites-enabled/default cat > /etc/nginx/sites-available/argos-setup << 'NGINX' @@ -153,11 +125,18 @@ nginx -t && systemctl restart nginx success "Nginx temporaneo configurato" # ══════════════════════════════════════════════════════════════════════════════ -section "10. Web Installer" +section "8. Web Installer" # ══════════════════════════════════════════════════════════════════════════════ -# Copia file setup -cp /opt/argos/app/scripts/setup_server.py /opt/argos/setup/ -cp /opt/argos/app/scripts/setup.html /opt/argos/setup/ +# Copia file setup dalla directory dello script (argos-setup tarball) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +for f in setup_server.py setup.html gen_config.py; do + if [[ -f "$SCRIPT_DIR/$f" ]]; then + cp "$SCRIPT_DIR/$f" /opt/argos/setup/ + else + error "File $f non trovato in $SCRIPT_DIR — installare argos-setup completo" + fi +done +chown -R root:root /opt/argos/setup # Systemd service web installer cat > /etc/systemd/system/argos-setup.service << 'EOF' @@ -169,7 +148,7 @@ After=network.target Type=simple User=root WorkingDirectory=/opt/argos/setup -ExecStart=/opt/argos/app/backend/venv/bin/python3 /opt/argos/setup/setup_server.py +ExecStart=/usr/bin/python3 /opt/argos/setup/setup_server.py Restart=on-failure RestartSec=3 StandardOutput=journal diff --git a/setup.html b/setup.html index 2aca48b..80a8561 100644 --- a/setup.html +++ b/setup.html @@ -95,11 +95,12 @@ html,body{height:100%;background:var(--bg);color:var(--text);font-family:var(--s