Spaces:
Running
Running
Create setup.sh
Browse files
setup.sh
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# OpenClaw Gateway entrypoint for Hugging Face Spaces.
|
| 3 |
+
# - Sets OPENCLAW_HOME to /data when writable (persistent storage), else /home/user.
|
| 4 |
+
# - When HF_TOKEN is set and no config exists, runs onboarding with Hugging Face Inference as default.
|
| 5 |
+
# - Starts the gateway on port 7860.
|
| 6 |
+
|
| 7 |
+
set -e
|
| 8 |
+
|
| 9 |
+
# 1. Persistence: use /data if writable, else /home/user
|
| 10 |
+
if mkdir -p /data/.openclaw 2>/dev/null; then
|
| 11 |
+
export OPENCLAW_HOME=/data
|
| 12 |
+
else
|
| 13 |
+
export OPENCLAW_HOME=/home/user
|
| 14 |
+
mkdir -p /home/user/.openclaw
|
| 15 |
+
fi
|
| 16 |
+
|
| 17 |
+
CONFIG_FILE="${OPENCLAW_HOME}/.openclaw/openclaw.json"
|
| 18 |
+
|
| 19 |
+
# 2. When HF_TOKEN is set and config doesn't exist, run onboarding with Hugging Face as default
|
| 20 |
+
if [ -n "${HF_TOKEN}" ] && [ ! -f "$CONFIG_FILE" ]; then
|
| 21 |
+
export HF_TOKEN
|
| 22 |
+
if [ -n "${OPENCLAW_GATEWAY_TOKEN}" ]; then
|
| 23 |
+
node /app/openclaw.mjs onboard --non-interactive --mode local \
|
| 24 |
+
--auth-choice huggingface-api-key --huggingface-api-key "$HF_TOKEN" \
|
| 25 |
+
--no-install-daemon --skip-health \
|
| 26 |
+
--gateway-port 7860 --gateway-bind lan \
|
| 27 |
+
--gateway-token "$OPENCLAW_GATEWAY_TOKEN"
|
| 28 |
+
else
|
| 29 |
+
node /app/openclaw.mjs onboard --non-interactive --mode local \
|
| 30 |
+
--auth-choice huggingface-api-key --huggingface-api-key "$HF_TOKEN" \
|
| 31 |
+
--no-install-daemon --skip-health \
|
| 32 |
+
--gateway-port 7860 --gateway-bind lan
|
| 33 |
+
fi
|
| 34 |
+
fi
|
| 35 |
+
|
| 36 |
+
# 3. Start the gateway
|
| 37 |
+
exec node /app/openclaw.mjs gateway --allow-unconfigured --bind lan --port 7860 "$@"
|