8900 commited on
Commit
bfb0ac8
Β·
verified Β·
1 Parent(s): fcce6a0

Update entrypoint.sh

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