echo8900 commited on
Commit
7684a29
·
verified ·
1 Parent(s): 392bd69

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +37 -20
entrypoint.sh CHANGED
@@ -1,5 +1,8 @@
1
  #!/bin/sh
2
- # OpenClaw HF Spaces Entrypoint with Telegram safe polling
 
 
 
3
 
4
  if mkdir -p /data/.openclaw 2>/dev/null; then
5
  export OPENCLAW_HOME=/data
@@ -9,30 +12,44 @@ else
9
  fi
10
  echo "[entrypoint] OPENCLAW_HOME=$OPENCLAW_HOME"
11
 
12
- # Remove old Telegram polling lock to prevent 409 after HF restart
13
- LOCK_FILE="$OPENCLAW_HOME/.openclaw/.tg-polling-lock"
14
- [ -f "$LOCK_FILE" ] && rm -f "$LOCK_FILE" && echo "[entrypoint] Removed old Telegram lock"
15
-
16
- # Export secrets
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  export HF_TOKEN="${HF_TOKEN:-}"
18
 
19
- # Run config setup
20
- echo "[entrypoint] Running setup"
21
  node /app/spaces/huggingface/setup-hf-config.mjs || true
22
  echo "[entrypoint] Setup done."
23
 
24
- # Security audit
25
- [ -f /app/security-check.sh ] && sh /app/security-check.sh || true
26
-
27
- # Start sync manager
28
- [ -f /app/hf-sync-manager.mjs ] && node /app/hf-sync-manager.mjs & echo "[entrypoint] Sync manager started (PID $!)"
29
 
30
- # Create Telegram lock before starting gateway
31
- touch "$LOCK_FILE"
32
- echo "[entrypoint] Telegram lock created"
 
 
33
 
34
- echo "[entrypoint] Starting gateway"
35
  exec node /app/openclaw.mjs gateway \
36
- --allow-unconfigured \
37
- --bind lan \
38
- --port 7860
 
1
  #!/bin/sh
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
 
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