#!/usr/bin/env bash set -euo pipefail # ============================================================================= # Nexus Agent (nexus-agent) — Instalador Linux/macOS # ============================================================================= # Pregunta al usuario qué agentes locales desea instalar y configura el # nexus-agent como servicio systemd. Si no se elige ningún agente, opera # únicamente como túnel hacia SecuryBlack Cloud. # ============================================================================= TOKEN="" ENDPOINT="https://ingest.securyblack.com:443" INSTALL_DIR="/usr/local/bin" CONFIG_DIR="/etc/securyblack" RELEASE_URL="https://github.com/securyblack/nexus-agent/releases/latest/download" # ─── Colores ──────────────────────────────────────────────────────────────── RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' CYAN='\033[0;36m' NC='\033[0m' # No Color info() { echo -e "${CYAN}[INFO]${NC} $*"; } ok() { echo -e "${GREEN}[OK]${NC} $*"; } warn() { echo -e "${YELLOW}[WARN]${NC} $*"; } err() { echo -e "${RED}[ERR]${NC} $*" >&2; } # ─── Helpers ──────────────────────────────────────────────────────────────── detect_arch() { local arch arch="$(uname -m)" case "$arch" in x86_64) echo "x86_64-unknown-linux-gnu" ;; aarch64) echo "aarch64-unknown-linux-gnu" ;; *) err "Arquitectura no soportada: $arch"; exit 1 ;; esac } ask_yes_no() { local prompt="$1" local resp read -rp "$prompt [S/n]: " resp /dev/null; then curl -fsSL "$DOWNLOAD_URL" -o "$BINARY_PATH" elif command -v wget &>/dev/null; then wget -q "$DOWNLOAD_URL" -O "$BINARY_PATH" else err "Se requiere curl o wget." exit 1 fi chmod +x "$BINARY_PATH" ok "Binario instalado en $BINARY_PATH" # ─── Instalar agentes seleccionados ───────────────────────────────────────── if $INSTALL_OXIPULSE; then info "Instalando OxiPulse" if command -v oxipulse &>/dev/null || [[ -f /etc/oxipulse/config.toml ]]; then warn "OxiPulse parece estar ya instalado. Saltando." else # Invocar instalador oficial de OxiPulse en modo local_agent OXI_URL="https://install.oxipulse.dev" if curl -fsSL "$OXI_URL" &>/dev/null; then info "Invocando instalador oficial de OxiPulse ..." bash -c "$(curl -fsSL $OXI_URL)" -- --mode local_agent --token "$TOKEN" ok "OxiPulse instalado." else warn "No se pudo contactar el instalador de OxiPulse. Instálalo manualmente." fi fi fi if $INSTALL_FERROSENTRY; then info "Instalando FerroSentry" FS_URL="${RELEASE_URL}/ferro-sentry-${ARCH}" FS_DIR="/usr/local/bin" FS_BIN="${FS_DIR}/ferro-sentry" FS_DATA="/etc/ferro-sentry" mkdir -p "$FS_DATA" info "Descargando FerroSentry ..." if curl -fsSL "$FS_URL" -o "$FS_BIN" 2>/dev/null; then chmod +x "$FS_BIN" cat > "${FS_DATA}/config.toml" </dev/null; then chmod +x "$CF_BIN" cat > "${CF_DATA}/config.toml" < "${CONFIG_DIR}/agent.toml" < "$SERVICE_FILE" <