85 lines
4.4 KiB
Bash
Executable File
85 lines
4.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# ══════════════════════════════════════════════════════════════════════════════
|
|
# ARGOS SOC — Bootstrap Installer (one-liner)
|
|
# Tecnotel Servizi SRL — Ubuntu 24.04 / 26.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
|
|
SUPPORTED_VERSIONS=("24.04" "26.04")
|
|
VERSION_OK=0
|
|
for v in "${SUPPORTED_VERSIONS[@]}"; do
|
|
[[ "$VERSION_ID" == "$v" ]] && VERSION_OK=1
|
|
done
|
|
if [[ "$ID" != "ubuntu" || $VERSION_OK -eq 0 ]]; then
|
|
error "Richiesto Ubuntu 24.04 o 26.04 LTS (trovato: $ID $VERSION_ID)."
|
|
fi
|
|
info "Sistema rilevato: Ubuntu $VERSION_ID LTS"
|
|
|
|
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
|