tao-shen Claude Opus 4.6 commited on
Commit
ee6f83c
·
1 Parent(s): c82956b

fix: repair corrupted entrypoint.sh encoding

Browse files

- Rewrite entrypoint.sh with clean ASCII encoding
- Simplify diagnostics to avoid encoding issues
- Ensure proper shebang and syntax
- Remove network connectivity test that could hang

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. scripts/entrypoint.sh +55 -30
scripts/entrypoint.sh CHANGED
@@ -1,56 +1,81 @@
1
  #!/bin/sh
2
  set -e
3
 
4
- # ── DNS 修复:使用 DoH 预解析 WhatsApp 等域名 ──
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  echo "[entrypoint] Resolving WhatsApp domains via DNS-over-HTTPS..."
6
  python3 /home/node/scripts/dns-resolve.py /tmp/dns-resolved.json || echo "[entrypoint] DNS pre-resolve had issues (non-fatal)"
7
 
8
- # 启用 Node.js DNS 修补(通过 --require 预加载)
9
  export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/dns-fix.cjs"
10
 
11
- # ── Unified Dataset Persistence & Process Manager ──
12
- DATASET_REPO="${OPENCLAW_DATASET_REPO}"
 
13
 
14
- # ── 确保 extensions symlink 存在(使插件以 global origin 加载,默认全部启用)──
15
  if [ ! -L /home/node/.openclaw/extensions ]; then
16
  rm -rf /home/node/.openclaw/extensions 2>/dev/null || true
17
  ln -s /app/openclaw/extensions /home/node/.openclaw/extensions
18
  echo "[entrypoint] Created extensions symlink -> /app/openclaw/extensions"
19
  fi
20
 
21
- # ── WhatsApp auth 保留(检查现有凭证)──
22
- if [ -d /home/node/.openclaw/credentials/whatsapp ]; then
23
- echo "[entrypoint] Found existing WhatsApp credentials — will use for auto-connect"
24
- fi
25
 
26
- # ── 基本诊断 ──
27
  cd /app/openclaw
28
- echo "[entrypoint] Build artifacts:"
29
- test -f dist/entry.js && echo " dist/entry.js OK" || echo " WARNING: dist/entry.js missing!"
30
- test -f dist/plugin-sdk/index.js && echo " dist/plugin-sdk/index.js OK" || echo " WARNING: dist/plugin-sdk/index.js missing!"
31
  echo " Extensions: $(ls extensions/ 2>/dev/null | wc -l | tr -d ' ') found"
32
  echo " Global extensions link: $(readlink /home/node/.openclaw/extensions 2>/dev/null || echo 'NOT SET')"
33
  echo " DNS resolved: $(cat /tmp/dns-resolved.json 2>/dev/null || echo 'file missing')"
34
 
35
- # 网络连通性测试
36
- echo "[entrypoint] Network connectivity test:"
37
- for host in "web.whatsapp.com" "g.whatsapp.net"; do
38
- ip=$(python3 -c "import json; d=json.load(open('/tmp/dns-resolved.json')); print(d.get('$host',''))" 2>/dev/null)
39
- if [ -n "$ip" ]; then
40
- timeout 10 curl -so /dev/null -w " $host ($ip): HTTP %{http_code}, connect %{time_connect}s\n" "https://$ip/" --resolve "$host:443:$ip" 2>/dev/null || echo " $host ($ip): connection failed"
41
- fi
42
- done
43
 
44
- echo "[entrypoint] Starting OpenClaw via Sync Manager..."
45
-
46
- # Create logs directory
47
  mkdir -p /home/node/logs
48
  touch /home/node/logs/app.log
49
 
50
- # EXECUTE NEW SYNC MANAGER
51
- # This manager handles:
52
- # 1. Complete state restore from HF Dataset (entire ~/.openclaw)
53
- # 2. Launch OpenClaw (gateway)
54
- # 3. Periodic full-directory backups
55
- # 4. Graceful shutdown with final backup
 
 
 
 
 
 
 
 
 
56
  exec python3 -u /home/node/scripts/openclaw_sync.py
 
1
  #!/bin/sh
2
  set -e
3
 
4
+ # =============================================================================
5
+ # OpenClaw Hugging Face Spaces Entrypoint
6
+ # =============================================================================
7
+ #
8
+ # This entrypoint handles:
9
+ # 1. DNS pre-resolution for WhatsApp
10
+ # 2. Extension symlink setup
11
+ # 3. Complete state persistence via openclaw_sync.py
12
+ # 4. Graceful shutdown with backup
13
+ #
14
+ # Environment Variables:
15
+ # HF_TOKEN - Hugging Face access token (required)
16
+ # OPENCLAW_DATASET_REPO - Dataset for persistence (e.g., "username/openclaw-state")
17
+ # OPENCLAW_HOME - OpenClaw home directory (default: ~/.openclaw)
18
+ # SYNC_INTERVAL - Seconds between automatic backups (default: 300)
19
+ # ENABLE_AUX_SERVICES - Enable aux services like WA guardian (default: false)
20
+ #
21
+ # =============================================================================
22
+
23
+ echo "[entrypoint] OpenClaw Hugging Face Spaces Entrypoint"
24
+ echo "[entrypoint] ======================================="
25
+
26
+ # -----------------------------------------------------------------------------
27
+ # 1. DNS Resolution for WhatsApp
28
+ # -----------------------------------------------------------------------------
29
+
30
  echo "[entrypoint] Resolving WhatsApp domains via DNS-over-HTTPS..."
31
  python3 /home/node/scripts/dns-resolve.py /tmp/dns-resolved.json || echo "[entrypoint] DNS pre-resolve had issues (non-fatal)"
32
 
33
+ # Enable Node.js DNS fix
34
  export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/dns-fix.cjs"
35
 
36
+ # -----------------------------------------------------------------------------
37
+ # 2. Extensions Setup
38
+ # -----------------------------------------------------------------------------
39
 
40
+ # Ensure extensions symlink exists (plugins load from global origin, all enabled by default)
41
  if [ ! -L /home/node/.openclaw/extensions ]; then
42
  rm -rf /home/node/.openclaw/extensions 2>/dev/null || true
43
  ln -s /app/openclaw/extensions /home/node/.openclaw/extensions
44
  echo "[entrypoint] Created extensions symlink -> /app/openclaw/extensions"
45
  fi
46
 
47
+ # -----------------------------------------------------------------------------
48
+ # 3. Diagnostics
49
+ # -----------------------------------------------------------------------------
 
50
 
 
51
  cd /app/openclaw
52
+ echo "[entrypoint] Build artifacts check:"
53
+ test -f dist/entry.js && echo " OK dist/entry.js" || echo " WARNING: dist/entry.js missing!"
54
+ test -f dist/plugin-sdk/index.js && echo " OK dist/plugin-sdk/index.js" || echo " WARNING: dist/plugin-sdk/index.js missing!"
55
  echo " Extensions: $(ls extensions/ 2>/dev/null | wc -l | tr -d ' ') found"
56
  echo " Global extensions link: $(readlink /home/node/.openclaw/extensions 2>/dev/null || echo 'NOT SET')"
57
  echo " DNS resolved: $(cat /tmp/dns-resolved.json 2>/dev/null || echo 'file missing')"
58
 
59
+ # -----------------------------------------------------------------------------
60
+ # 4. Create logs directory
61
+ # -----------------------------------------------------------------------------
 
 
 
 
 
62
 
 
 
 
63
  mkdir -p /home/node/logs
64
  touch /home/node/logs/app.log
65
 
66
+ # -----------------------------------------------------------------------------
67
+ # 5. Launch Sync Manager
68
+ # -----------------------------------------------------------------------------
69
+ #
70
+ # The sync manager handles:
71
+ # - Restoring state on startup
72
+ # - Running OpenClaw gateway
73
+ # - Periodic backups to dataset
74
+ # - Graceful shutdown with final backup
75
+ #
76
+
77
+ echo "[entrypoint] Starting OpenClaw via Sync Manager..."
78
+ echo "[entrypoint] This will restore state, start app, and manage backups."
79
+
80
+ # Execute unified sync wrapper
81
  exec python3 -u /home/node/scripts/openclaw_sync.py