| | #!/usr/bin/env sh |
| | set -e |
| |
|
| | mkdir -p /data/config /data/workspace /data/state |
| |
|
| | |
| | if [ -n "${HF_DATASET_REPO:-}" ] && [ -n "${HF_TOKEN:-}" ]; then |
| | echo "📦 已启用文件同步到 HF Dataset: $HF_DATASET_REPO" |
| | |
| | (while true; do |
| | sleep 3600 |
| | python3 /app/sync_files.py || true |
| | done) & |
| | fi |
| |
|
| | PORT_VALUE="${CLAWDBOT_GATEWAY_PORT:-${PORT:-7860}}" |
| |
|
| | CONFIG_PATH="${CLAWDBOT_CONFIG_PATH:-/data/config/clawdbot.json}" |
| |
|
| | TELEGRAM_ENABLED="false" |
| | if [ "${ENABLE_TELEGRAM:-0}" = "1" ] && [ -n "${TELEGRAM_BOT_TOKEN:-}" ]; then |
| | TELEGRAM_ENABLED="true" |
| | echo "✅ Telegram Bot 已启用" |
| | fi |
| |
|
| | |
| | if [ -z "${HUGGINGFACE_API_KEY:-}" ] && [ -n "${HF_TOKEN:-}" ]; then |
| | export HUGGINGFACE_API_KEY="$HF_TOKEN" |
| | echo "✅ 使用 HF_TOKEN 作为 Hugging Face API Key" |
| | fi |
| |
|
| | if [ ! -f "$CONFIG_PATH" ]; then |
| | cat >"$CONFIG_PATH" <<EOF |
| | { |
| | "channels": { |
| | "telegram": { |
| | "enabled": true, |
| | "botToken": "${TELEGRAM_BOT_TOKEN:-}", |
| | "dmPolicy": "pairing", |
| | "commands": { |
| | "native": false, |
| | "nativeSkills": false |
| | } |
| | } |
| | }, |
| | "gateway": { |
| | "mode": "local", |
| | "bind": "lan", |
| | "port": $PORT_VALUE, |
| | "auth": { |
| | "mode": "token", |
| | "token": "${CLAWDBOT_GATEWAY_TOKEN:-}" |
| | }, |
| | "controlUi": { |
| | "enabled": true, |
| | "allowInsecureAuth": true |
| | } |
| | }, |
| | "agents": { |
| | "defaults": { |
| | "workspace": "/data/workspace" |
| | } |
| | }, |
| | "models": { |
| | "providers": { |
| | "huggingface": { |
| | "apiKey": "${HUGGINGFACE_API_KEY:-}", |
| | "baseUrl": "https://api-inference.huggingface.co/v1", |
| | "models": [ |
| | { |
| | "id": "meta-llama/Meta-Llama-3-8B-Instruct", |
| | "name": "Llama 3 8B" |
| | } |
| | ] |
| | }, |
| | "groq": { |
| | "apiKey": "${GROQ_API_KEY:-}", |
| | "baseUrl": "https://api.groq.com/openai/v1", |
| | "models": [ |
| | { |
| | "id": "llama3-70b-8192", |
| | "name": "Llama 3 70B" |
| | }, |
| | { |
| | "id": "llama3-8b-8192", |
| | "name": "Llama 3 8B" |
| | } |
| | ] |
| | } |
| | } |
| | } |
| | } |
| | EOF |
| | fi |
| |
|
| | clawdbot doctor --yes || true |
| |
|
| | exec clawdbot gateway --bind lan --port "$PORT_VALUE" --allow-unconfigured --verbose |
| |
|