#!/bin/bash set -e # --- 🔧 NETWORK FIX (CRITICAL) --- # Forces Node.js to use IPv4. Without this, Discord connection fails. export NODE_OPTIONS="--dns-result-order=ipv4first" # --------------------------------- # --- CONFIGURATION --- MODEL_ID="nvidia/nemotron-3-nano-30b-a3b:free" MODEL_NAME="Nvidia Nemotron (Free)" # --- CHECKS --- if [ -z "$OPENROUTER_API_KEY" ]; then echo "❌ ERROR: OPENROUTER_API_KEY secret is missing." exit 1 fi if [ -z "$DISCORD_TOKEN" ]; then echo "❌ ERROR: DISCORD_TOKEN secret is missing." exit 1 fi echo "🦞 Configuring OpenClaw with Discord (IPv4 Mode)..." # --- GENERATE CONFIG --- cat > /root/.openclaw/openclaw.json << EOF { "gateway": { "mode": "local", "bind": "lan", "port": 7860, "trustedProxies": ["0.0.0.0/0"], "auth": { "mode": "token", "token": "${SETUP_PASSWORD}" }, "controlUi": { "allowInsecureAuth": true } }, "channels": { "discord": { "enabled": true, "token": "${DISCORD_TOKEN}" } }, "models": { "providers": { "custom_openrouter": { "api": "openai-completions", "baseUrl": "https://openrouter.ai/api/v1", "apiKey": "${OPENROUTER_API_KEY}", "models": [ { "id": "${MODEL_ID}", "name": "${MODEL_NAME}", "contextWindow": 32000, "cost": { "input": 0, "output": 0 } } ] } } }, "agents": { "defaults": { "model": { "primary": "custom_openrouter/${MODEL_ID}" } } } } EOF # Fix Permissions chmod 700 /root/.openclaw chmod 600 /root/.openclaw/openclaw.json echo "✅ Configuration complete. Starting Gateway..." exec openclaw gateway run --port 7860