echo8900 commited on
Commit
ad67ccc
·
verified ·
1 Parent(s): aef4141

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +69 -10
entrypoint.sh CHANGED
@@ -1,18 +1,77 @@
1
  #!/bin/sh
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  echo "[entrypoint] OPENCLAW_HOME=$OPENCLAW_HOME"
4
 
5
- # 只导出 keys
 
6
  for VAR in $(env | cut -d= -f1); do
7
- case "$VAR" in
8
- *_API_KEY|*_SECRET_KEY|*_ACCESS_TOKEN|*_BOT_TOKEN)
9
- VAL=$(printenv "$VAR" 2>/dev/null || true)
10
- if [ -n "$VAL" ]; then export "$VAR"; echo "[entrypoint] exported: $VAR"; fi
11
- ;;
12
- esac
 
 
 
 
 
 
13
  done
14
 
15
- echo "[entrypoint] Setup skipped for clean test"
16
- echo "[entrypoint] Starting gateway directly..."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- exec node /app/openclaw.mjs gateway --allow-unconfigured --bind lan --port 7860
 
 
 
 
1
  #!/bin/sh
2
 
3
+ # OpenClaw HF Spaces - Production Entrypoint
4
+
5
+ #
6
+
7
+ # SETUP_MARKER lives in /tmp.
8
+
9
+ # /tmp is wiped on container restart but survives gateway restart.
10
+
11
+ # So setup only runs once per container lifetime.
12
+
13
+ SETUP_MARKER="/tmp/.openclaw-setup-done"
14
+
15
+ # -- resolve writable home --------------------------------
16
+
17
+ if mkdir -p /data/.openclaw 2>/dev/null; then
18
+ export OPENCLAW_HOME=/data
19
+ else
20
+ export OPENCLAW_HOME=/home/user
21
+ mkdir -p /home/user/.openclaw
22
+ fi
23
  echo "[entrypoint] OPENCLAW_HOME=$OPENCLAW_HOME"
24
 
25
+ # -- dynamic provider key export --------------------------
26
+
27
  for VAR in $(env | cut -d= -f1); do
28
+ case "$VAR" in
29
+ OPENCLAW_*|SPACE_*|SYSTEM_*|HF_*|NODE_*|npm_*) continue ;;
30
+ esac
31
+ case "$VAR" in
32
+ *_API_KEY|*_SECRET_KEY|*_ACCESS_TOKEN|*_BOT_TOKEN|*_AUTH_TOKEN|*_APP_KEY)
33
+ VAL=$(printenv "$VAR" 2>/dev/null || true)
34
+ if [ -n "$VAL" ]; then
35
+ export "$VAR"
36
+ echo "[entrypoint] exported: $VAR"
37
+ fi
38
+ ;;
39
+ esac
40
  done
41
 
42
+ export HF_TOKEN="${HF_TOKEN:-}"
43
+
44
+ # -- run setup only on first boot -------------------------
45
+
46
+ # Gateway restart reuses /tmp, so marker survives -> setup skipped.
47
+
48
+ # Container restart wipes /tmp, marker gone -> setup runs once.
49
+
50
+ if [ ! -f "$SETUP_MARKER" ]; then
51
+ echo "[entrypoint] First boot - running setup…"
52
+ node /app/spaces/huggingface/setup-hf-config.mjs || true
53
+ touch "$SETUP_MARKER"
54
+ echo "[entrypoint] Setup done (marker created)"
55
+ else
56
+ echo "[entrypoint] Gateway restart - setup skipped (settings preserved)"
57
+ fi
58
+
59
+ # -- security audit (non-fatal) --------------------------
60
+
61
+ if [ -f /app/security-check.sh ]; then
62
+ sh /app/security-check.sh || true
63
+ fi
64
+
65
+ # -- start sync manager in background ---------------------
66
+
67
+ if [ -f /app/hf-sync-manager.mjs ]; then
68
+ (node /app/hf-sync-manager.mjs &)
69
+ echo "[entrypoint] Sync manager started"
70
+ fi
71
+
72
+ echo "[entrypoint] Starting gateway…"
73
 
74
+ exec node /app/openclaw.mjs gateway \
75
+ --allow-unconfigured \
76
+ --bind lan \
77
+ --port 7860