Spaces:
Paused
Paused
| set -e | |
| REPO_ID="wenyin/openclaw" | |
| FILE_NAME="clawpanel.zip" | |
| APP_DIR="/app" | |
| echo "🔄 正在准备环境..." | |
| # 1. 尝试从远程获取备份 | |
| python3 -c " | |
| from huggingface_hub import hf_hub_download | |
| import os | |
| try: | |
| path = hf_hub_download(repo_id='$REPO_ID', filename='$FILE_NAME', repo_type='dataset', token=os.getenv('HF_TOKEN')) | |
| print(f'HF_PATH:{path}') | |
| except Exception as e: | |
| print('HF_NOT_FOUND') | |
| " > /tmp/hf_result.txt | |
| HF_PATH=$(grep "HF_PATH:" /tmp/hf_result.txt | cut -d':' -f2) | |
| if [ -n "$HF_PATH" ]; then | |
| echo "📦 发现备份,正在覆盖安装..." | |
| rm -rf "$APP_DIR"/* | |
| unzip -o "$HF_PATH" -d "$APP_DIR" | |
| cd "$APP_DIR" | |
| npm install --omit=dev --registry https://registry.npmmirror.com | |
| else | |
| echo "🚀 全新安装..." | |
| git clone https://github.com/qingchencloud/clawpanel.git . | |
| npm install --include=dev --registry https://registry.npmmirror.com | |
| npm run build | |
| npm prune --omit=dev | |
| fi | |
| # ─── 🔑 自动化修复:绑定 CLI 路径 ─── | |
| # ClawPanel 使用 SQLite 存储设置,我们直接修改数据库避开“只读模式” | |
| DB_PATH="$APP_DIR/data/database.sqlite" | |
| if [ -f "$DB_PATH" ]; then | |
| echo "🛠️ 正在自动配置 CLI 绑定..." | |
| # 强制将 openclaw_cli_path 设置为 /usr/local/bin/openclaw | |
| # 注意:表名和键名基于 ClawPanel 常用结构,如果版本更新请检查 | |
| sqlite3 "$DB_PATH" "INSERT OR REPLACE INTO settings (key, value) VALUES ('openclaw_cli_path', '/usr/local/bin/openclaw');" || echo "数据库写入跳过" | |
| fi | |
| # 2. 启动服务 | |
| service cron start | |
| echo "✨ 启动 ClawPanel..." | |
| exec npm run serve -- --port 7860 --host 0.0.0.0 |