#!/bin/bash set -e echo "=== BI Agentes Startup ===" # Check for Netbird setup key if [ -n "$NETBIRD_SETUP_KEY" ]; then echo "Connecting to Netbird network..." echo "Management URL: ${NETBIRD_MANAGEMENT_URL:-https://netbird.cambioreal.com}" # Start netbird daemon directly (not via systemd - doesn't work in containers) MGMT_URL="${NETBIRD_MANAGEMENT_URL:-https://netbird.cambioreal.com}" # Run netbird daemon in background netbird service run & sleep 3 # Connect using setup key and management URL netbird up --setup-key "$NETBIRD_SETUP_KEY" --management-url "$MGMT_URL" & # Wait for connection echo "Waiting for Netbird connection..." sleep 10 # Check connection status netbird status || echo "Netbird connection pending..." else echo "WARNING: NETBIRD_SETUP_KEY not set. Database connection may fail." fi echo "Starting BI Agentes server..." exec node server.js