8900 commited on
Commit
6af251e
Β·
verified Β·
1 Parent(s): 66b9e6c

Update entrypoint.sh

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