diff --git a/agent-node/src/agent_node/main.py b/agent-node/src/agent_node/main.py index d8d31c9..c775a7c 100644 --- a/agent-node/src/agent_node/main.py +++ b/agent-node/src/agent_node/main.py @@ -238,4 +238,7 @@ time.sleep(10) if __name__ == '__main__': + if len(sys.argv) > 1 and sys.argv[1] == '--version': + print("Cortex Agent 1.0.0") + sys.exit(0) main() diff --git a/ai-hub/app/core/templates/provisioning/provision.sh.j2 b/ai-hub/app/core/templates/provisioning/provision.sh.j2 index a383046..723bf4d 100644 --- a/ai-hub/app/core/templates/provisioning/provision.sh.j2 +++ b/ai-hub/app/core/templates/provisioning/provision.sh.j2 @@ -41,14 +41,27 @@ echo "[*] Downloading agent core..." INSTALLER_URL="{{ base_url }}/api/v1/agent/binary/$BIN_ARCH" +USE_SOURCE=true if curl -sSLf "$INSTALLER_URL" -o cortex-agent; then - echo "✅ Downloaded standalone binary for $BIN_ARCH" chmod +x cortex-agent - BINARY_PATH="$INSTALL_DIR/cortex-agent" + mkdir -p "$INSTALL_DIR/tmp" + export TMPDIR="$INSTALL_DIR/tmp" + echo "[*] Verifying binary compatibility on this target OS..." + if ./cortex-agent --version >/dev/null 2>&1; then + echo "✅ Downloaded and verified standalone binary for $BIN_ARCH" + BINARY_PATH="$INSTALL_DIR/cortex-agent" + USE_SOURCE=false + else + echo "⚠️ Binary failed compatibility check (e.g. GLIBC version mismatch)." + rm -f cortex-agent + fi else - echo "⚠️ Standalone binary for $BIN_ARCH was not found (404). Falling back to Source + Venv..." + echo "⚠️ Standalone binary for $BIN_ARCH was not found (404) on Hub." +fi + +if [ "$USE_SOURCE" = true ]; then + echo "[*] Falling back to Python Source + Virtualenv execution..." SOURCE_URL="{{ base_url }}/api/v1/nodes/provision/{{ node_id }}?token={{ invite_token }}" - echo "[*] Downloading bootstrap source installer..." # Use python to run the legacy bootstrap installer which handles platform-native installs if ! curl -sSLf "$SOURCE_URL" | python3; then