8900 commited on
Commit
d161dbf
Β·
verified Β·
1 Parent(s): 2ac101c

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +37 -37
entrypoint.sh CHANGED
@@ -10,68 +10,68 @@
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
 
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