8900 commited on
Commit ·
6c2acc7
1
Parent(s): 2dc6956
Update entrypoint.sh
Browse files- entrypoint.sh +48 -39
entrypoint.sh
CHANGED
|
@@ -1,67 +1,76 @@
|
|
| 1 |
#!/bin/sh
|
| 2 |
|
| 3 |
# resolve OPENCLAW_HOME
|
|
|
|
| 4 |
if mkdir -p /data/.openclaw 2>/dev/null; then
|
| 5 |
-
|
| 6 |
else
|
| 7 |
-
|
| 8 |
-
|
| 9 |
fi
|
| 10 |
|
| 11 |
echo "[entrypoint] OPENCLAW_HOME=$OPENCLAW_HOME"
|
| 12 |
|
| 13 |
-
# 显式导出网关令牌(如果存在),确保网关能读取
|
| 14 |
-
if [ -n "$OPENCLAW_GATEWAY_TOKEN" ]; then
|
| 15 |
-
export OPENCLAW_GATEWAY_TOKEN
|
| 16 |
-
echo "[entrypoint] Gateway token is set (use this in Control UI): $OPENCLAW_GATEWAY_TOKEN"
|
| 17 |
-
elif [ -n "$OPENCLAW_GATEWAY_PASSWORD" ]; then
|
| 18 |
-
export OPENCLAW_GATEWAY_PASSWORD
|
| 19 |
-
echo "[entrypoint] Gateway password is set (use this in Control UI)"
|
| 20 |
-
else
|
| 21 |
-
echo "[entrypoint] WARNING: Neither OPENCLAW_GATEWAY_TOKEN nor OPENCLAW_GATEWAY_PASSWORD is set. Gateway will be unprotected!"
|
| 22 |
-
fi
|
| 23 |
-
|
| 24 |
# dynamically export all provider keys so openclaw gateway can read them
|
| 25 |
-
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
done
|
| 41 |
|
| 42 |
-
# always export
|
|
|
|
| 43 |
export HF_TOKEN="${HF_TOKEN:-}"
|
| 44 |
|
| 45 |
# restore from HF Dataset (30s timeout, non-fatal)
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
fi
|
| 50 |
|
| 51 |
# write openclaw config
|
|
|
|
| 52 |
node /app/spaces/huggingface/setup-hf-config.mjs || true
|
| 53 |
|
| 54 |
# run security check (non-fatal)
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
fi
|
| 58 |
|
| 59 |
echo "[entrypoint] starting gateway..."
|
| 60 |
|
| 61 |
# start background sync loop
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
fi
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
|
|
| 1 |
#!/bin/sh
|
| 2 |
|
| 3 |
# resolve OPENCLAW_HOME
|
| 4 |
+
|
| 5 |
if mkdir -p /data/.openclaw 2>/dev/null; then
|
| 6 |
+
export OPENCLAW_HOME=/data
|
| 7 |
else
|
| 8 |
+
export OPENCLAW_HOME=/home/user
|
| 9 |
+
mkdir -p /home/user/.openclaw
|
| 10 |
fi
|
| 11 |
|
| 12 |
echo "[entrypoint] OPENCLAW_HOME=$OPENCLAW_HOME"
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# dynamically export all provider keys so openclaw gateway can read them
|
| 15 |
+
|
| 16 |
+
# OpenClaw's official mechanism: reads provider keys directly from process env vars
|
| 17 |
+
|
| 18 |
+
# matches: anything ending in _API_KEY _SECRET_KEY _ACCESS_TOKEN _BOT_TOKEN _AUTH_TOKEN _APP_KEY
|
| 19 |
+
|
| 20 |
+
# excludes: OPENCLAW SPACE SYSTEM NODE vars prefixes
|
| 21 |
+
|
| 22 |
+
for VAR in $(env | cut -d= -f1);
|
| 23 |
+
do
|
| 24 |
+
case "$VAR" in
|
| 25 |
+
OPENCLAW_*|SPACE_*|SYSTEM_*|NODE_*|HF_SPACE*) continue ;;
|
| 26 |
+
esac
|
| 27 |
+
case "$VAR" in
|
| 28 |
+
*_API_KEY|*_SECRET_KEY|*_ACCESS_TOKEN|*_BOT_TOKEN|*_AUTH_TOKEN|*_APP_KEY)
|
| 29 |
+
# Optimized dynamic export logic for both standard sh and bash.
|
| 30 |
+
# Ensure both Key exists in env and its Value is not empty before exporting
|
| 31 |
+
#eval VAL=\$$VAR # Convoluted expression that can be simplified
|
| 32 |
+
if env | grep -q "^$VAR="; then
|
| 33 |
+
export "$VAR"
|
| 34 |
+
echo "[entrypoint] exported: $VAR"
|
| 35 |
+
fi
|
| 36 |
+
;;
|
| 37 |
+
esac
|
| 38 |
done
|
| 39 |
|
| 40 |
+
# also always export HF TOKEN for dataset sync
|
| 41 |
+
|
| 42 |
export HF_TOKEN="${HF_TOKEN:-}"
|
| 43 |
|
| 44 |
# restore from HF Dataset (30s timeout, non-fatal)
|
| 45 |
+
|
| 46 |
+
if [ -n "$HF_TOKEN" ] && [ -n "$HF_DATASET_ID" ];
|
| 47 |
+
then
|
| 48 |
+
echo "[entrypoint] Restoring from dataset ${HF_DATASET_ID}..."
|
| 49 |
+
timeout 30 sh /app/hf-sync.sh restore ||
|
| 50 |
+
echo "[entrypoint] Restore skipped (non-fatal)"
|
| 51 |
fi
|
| 52 |
|
| 53 |
# write openclaw config
|
| 54 |
+
|
| 55 |
node /app/spaces/huggingface/setup-hf-config.mjs || true
|
| 56 |
|
| 57 |
# run security check (non-fatal)
|
| 58 |
+
|
| 59 |
+
if [ -f /app/security-check.sh ];
|
| 60 |
+
then
|
| 61 |
+
sh /app/security-check.sh || true
|
| 62 |
fi
|
| 63 |
|
| 64 |
echo "[entrypoint] starting gateway..."
|
| 65 |
|
| 66 |
# start background sync loop
|
| 67 |
+
|
| 68 |
+
if [ -n "$HF_TOKEN" ] && [ -n "$HF_DATASET_ID" ];
|
| 69 |
+
then
|
| 70 |
+
sh /app/hf-sync.sh loop &
|
| 71 |
+
echo "[entrypoint] sync loop started (interval=${HF_SYNC_INTERVAL:-3600}s)"
|
| 72 |
fi
|
| 73 |
|
| 74 |
+
# FIX: must use ASCII hyphens -- not en-dashes – in execution line
|
| 75 |
+
|
| 76 |
+
exec node /app/openclaw.mjs gateway --allow-unconfigured --bind lan --port 7860
|