#!/bin/bash set -e echo "🦞 Starting OpenClaw setup..." # 1. Tạo thư mục cần thiết mkdir -p /root/.openclaw/agents/main/sessions mkdir -p /root/.openclaw/workspace/skills mkdir -p /root/.openclaw/reports mkdir -p /root/.openclaw/logs # 2. Khôi phục dữ liệu từ Dataset python3 /app/sync.py restore || echo "No existing backup." # 3. Nạp Skills echo "📦 Đang nạp Skills..." cd /root/.openclaw/workspace npx clawhub@latest install reddit-readonly --force || true # Đã tạm tắt skill nofx vì không đăng ký được key # npx clawhub@latest install nofx-ai500-report --force || true if [ -d /app/skills ]; then cp -r /app/skills/* /root/.openclaw/workspace/skills/ 2>/dev/null || true echo "✅ Custom skills loaded." fi cd /app # 4. Cấu hình OpenClaw (Grok 4.1 Fast) cat > /root/.openclaw/openclaw.json <> /root/.openclaw/logs/backup.log 2>&1; done) & echo "🔄 Backup loop started." # ========================================== # 6. MỞ KHÓA CRON JOBS (HỆ THỐNG TỰ ĐỘNG) # ========================================== echo "⏳ Setting up automated tasks..." # Cài đặt cron service nếu chưa có (vì base image của Hugging Face có thể thiếu) apt-get update && apt-get install -y cron || true cat > /etc/cron.d/openclaw-tasks <> /root/.openclaw/logs/cron_signal.log 2>&1 # Run Technical Analysis every 2 hours 0 */2 * * * root curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $OPENCLAW_GATEWAY_PASSWORD" -d '{"prompt": "Perform detailed technical analysis for BTCUSDT and generate a markdown report."}' http://localhost:7860/v1/agents/main/run >> /root/.openclaw/logs/cron_ta.log 2>&1 # Run SEO Report every 6 hours 0 */6 * * * root curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $OPENCLAW_GATEWAY_PASSWORD" -d '{"prompt": "Generate a comprehensive SEO-optimized market report for the crypto community."}' http://localhost:7860/v1/agents/main/run >> /root/.openclaw/logs/cron_seo.log 2>&1 EOF chmod 0644 /etc/cron.d/openclaw-tasks crontab /etc/cron.d/openclaw-tasks service cron start echo "✅ Cron jobs activated!" # ========================================== export PORT=7860 echo "🚀 Starting gateway..." exec openclaw gateway run