#!/bin/sh set -e # ساخت فایل کانفیگ از متغیرهای محیطی cat > /home/node/.openclaw/openclaw.json << EOF { "env": { "OPENROUTER_API_KEY": "${OPENROUTER_API_KEY}", "GOOGLE_GENERATIVE_AI_API_KEY": "${GOOGLE_AI_API_KEY}" }, "gateway": { "mode": "local", "bind": "all", "port": 18789, "auth": { "mode": "token", "token": "${OPENCLAW_GATEWAY_TOKEN}" }, "trustedProxies": ["0.0.0.0/0"], "controlUi": { "enabled": true, "allowInsecureAuth": true, "dangerouslyDisableDeviceAuth": true } }, "channels": { "telegram": { "enabled": true, "botToken": "${TELEGRAM_BOT_TOKEN}", "allowFrom": ["${TELEGRAM_ALLOWED_USER_ID}"] } }, "agents": { "defaults": { "model": { "primary": "google/gemini-2.0-flash", "fallbacks": [ "openrouter/openai/gpt-oss-120b:free", "google/gemini-1.5-flash" ] }, "models": { "google/gemini-2.0-flash": {}, "google/gemini-1.5-flash": {}, "google/gemini-1.5-pro": {}, "openrouter/openai/gpt-oss-120b:free": {}, "openrouter/google/gemini-2.0-flash-exp:free": {}, "openrouter/meta-llama/llama-3.3-70b-instruct:free": {} } } } } EOF echo "✅ Config file created" # اجرای gateway در پس‌زمینه npx openclaw gateway --port 18789 --token "${OPENCLAW_GATEWAY_TOKEN}" & GATEWAY_PID=$! echo "✅ Gateway started (PID: $GATEWAY_PID)" # صبر میکنیم تا gateway روی port 18789 بیاد بالا echo "⏳ Waiting for gateway on port 18789..." for i in $(seq 1 30); do if nc -z 127.0.0.1 18789 2>/dev/null; then echo "✅ Gateway is ready!" break fi echo " attempt $i/30..." sleep 1 done # فوروارد port 7860 به 18789 socat TCP-LISTEN:7860,fork,reuseaddr TCP:127.0.0.1:18789 & echo "✅ socat started (7860 -> 18789)" # نگه داشتن container زنده wait $GATEWAY_PID