Download start-openclaw from AZILS/open: direct link, hf CLI and curl.
- Browser
- Download file 2.8 kB
-
https://huggingface.co/spaces/AZILS/open/resolve/main/start-openclaw
- Command line
-
hf download hf://spaces/AZILS/open/start-openclaw
-
curl -L -o start-openclaw https://huggingface.co/spaces/AZILS/open/resolve/main/start-openclaw
2.8 kB
| #!/bin/bash | |
| set -e | |
| rm -f /root/.openclaw/openclaw.json | |
| mkdir -p /root/.openclaw/sessions | |
| mkdir -p /root/.openclaw/workspace | |
| # 根据 Secrets 自动选择 provider | |
| if [ -n "$GEMINI_API_KEY" ]; then | |
| PROVIDER="google" | |
| API_KEY_VAR="$GEMINI_API_KEY" | |
| BASE_URL_VAR="https://generativelanguage.googleapis.com/v1beta" | |
| MODEL_VAR="$MODEL" | |
| PRIMARY_MODEL="google/$MODEL_VAR" | |
| API_TYPE="google-generative-ai" | |
| else | |
| PROVIDER="openai" | |
| API_KEY_VAR="$OPENAI_API_KEY" | |
| CLEAN_BASE=$(echo "$OPENAI_API_BASE" | sed "s|/chat/completions||g" | sed "s|/v1/|/v1|g" | sed "s|/v1$|/v1|g") | |
| BASE_URL_VAR="$CLEAN_BASE" | |
| MODEL_VAR="$MODEL" | |
| PRIMARY_MODEL="openai/$MODEL_VAR" | |
| API_TYPE="openai-completions" | |
| fi | |
| cat > /root/.openclaw/openclaw.json <<EOF | |
| { | |
| "models": { | |
| "providers": { | |
| "$PROVIDER": { | |
| "baseUrl": "$BASE_URL_VAR", | |
| "apiKey": "$API_KEY_VAR", | |
| "api": "$API_TYPE", | |
| "models": [{ "id": "$MODEL_VAR", "name": "$MODEL_VAR", "contextWindow": 128000 }] | |
| } | |
| } | |
| }, | |
| "agents": { | |
| "defaults": { | |
| "model": { | |
| "primary": "$PRIMARY_MODEL" | |
| } | |
| } | |
| }, | |
| "gateway": { | |
| "mode": "local", | |
| "bind": "lan", | |
| "port": $PORT, | |
| "trustedProxies": ["0.0.0.0/0", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"], | |
| "auth": { | |
| "mode": "token", | |
| "token": "$OPENCLAW_GATEWAY_PASSWORD" | |
| }, | |
| "controlUi": { | |
| "allowInsecureAuth": true, | |
| "allowedOrigins": ["*"] | |
| } | |
| }, | |
| "channels": { | |
| "telegram": { | |
| "enabled": true, | |
| "botToken": "$TELEGRAM_BOT_TOKEN" | |
| } | |
| } | |
| } | |
| EOF | |
| echo "=== openclaw.json content ===" | |
| cat /root/.openclaw/openclaw.json | |
| echo "=== end ===" | |
| # 启动网关(后台运行) | |
| openclaw gateway run --port $PORT & | |
| GATEWAY_PID=$! | |
| # 等待网关完全启动 | |
| sleep 8 | |
| # 自动批准 Telegram 配对(支持表格和旧格式) | |
| echo "Starting Telegram auto-pairing..." | |
| for i in {1..10}; do | |
| PAIR_OUTPUT=$(openclaw pairing list 2>/dev/null || true) | |
| echo "Attempt $i: pairing list output:" | |
| echo "$PAIR_OUTPUT" | |
| CODE="" | |
| CODE=$(echo "$PAIR_OUTPUT" | grep -oP 'Pairing code: \K[A-Z0-9]{7,}' | head -1) | |
| if [ -z "$CODE" ]; then | |
| CODE=$(echo "$PAIR_OUTPUT" | awk '/^│ Code/ {getline; split($0, a, "│"); gsub(/^ +| +$/, "", a[2]); if (a[2] ~ /^[A-Z0-9]{7,}$/) print a[2]}' | head -1) | |
| fi | |
| if [ -z "$CODE" ]; then | |
| CODE=$(echo "$PAIR_OUTPUT" | grep -oE '[A-Z0-9]{7,}' | grep -v "PAIRING" | grep -v "REQUEST" | head -1) | |
| fi | |
| if [ -n "$CODE" ]; then | |
| echo "Found pairing code: $CODE" | |
| openclaw pairing approve telegram "$CODE" | |
| echo "Approval sent. Bot should now respond." | |
| break | |
| else | |
| echo "No pending pairing code found (attempt $i/10). Waiting 5 seconds..." | |
| sleep 5 | |
| fi | |
| done | |
| wait $GATEWAY_PID |