#!/usr/bin/env sh set -e mkdir -p /data/config /data/workspace /data/state # 如果配置了 HF_DATASET_REPO,启用自动同步 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 # 设置 Hugging Face API Key(如果没有单独设置,使用 HF_TOKEN) 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" <