mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-05 23:50:48 +00:00
refactor: consolidate OpenClaw config setup to shared helper
- Add setup_openclaw_config() to shared/common.sh - Replace ~350 lines of duplicate config code across 10 files - Uses callback pattern for provider-specific upload/run operations Score: 14 (Impact: 7, Confidence: 8, Risk: 4)
This commit is contained in:
parent
f9dd9a7bf5
commit
0cab5827de
11 changed files with 115 additions and 346 deletions
|
|
@ -50,37 +50,9 @@ inject_env_vars_ssh "$DO_SERVER_IP" upload_file run_server \
|
|||
"ANTHROPIC_BASE_URL=https://openrouter.ai/api"
|
||||
|
||||
# 9. Configure openclaw
|
||||
log_warn "Configuring openclaw..."
|
||||
|
||||
run_server "$DO_SERVER_IP" "rm -rf ~/.openclaw && mkdir -p ~/.openclaw"
|
||||
|
||||
GATEWAY_TOKEN=$(openssl rand -hex 16)
|
||||
|
||||
OPENCLAW_CONFIG_TEMP=$(mktemp)
|
||||
chmod 600 "$OPENCLAW_CONFIG_TEMP"
|
||||
cat > "$OPENCLAW_CONFIG_TEMP" << EOF
|
||||
{
|
||||
"env": {
|
||||
"OPENROUTER_API_KEY": "${OPENROUTER_API_KEY}"
|
||||
},
|
||||
"gateway": {
|
||||
"mode": "local",
|
||||
"auth": {
|
||||
"token": "${GATEWAY_TOKEN}"
|
||||
}
|
||||
},
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model": {
|
||||
"primary": "openrouter/${MODEL_ID}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
upload_file "$DO_SERVER_IP" "$OPENCLAW_CONFIG_TEMP" "/root/.openclaw/openclaw.json"
|
||||
rm "$OPENCLAW_CONFIG_TEMP"
|
||||
setup_openclaw_config "$OPENROUTER_API_KEY" "$MODEL_ID" \
|
||||
"upload_file $DO_SERVER_IP" \
|
||||
"run_server $DO_SERVER_IP"
|
||||
|
||||
echo ""
|
||||
log_info "DigitalOcean droplet setup completed successfully!"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue