8900 commited on
Update entrypoint.sh
Browse files- entrypoint.sh +38 -4
entrypoint.sh
CHANGED
|
@@ -1,11 +1,31 @@
|
|
| 1 |
#!/bin/sh
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
export OPENCLAW_HOME
|
| 7 |
echo "[entrypoint] OPENCLAW_HOME=$OPENCLAW_HOME"
|
| 8 |
|
|
|
|
|
|
|
| 9 |
for VAR in $(env | cut -d= -f1); do
|
| 10 |
case "$VAR" in
|
| 11 |
OPENCLAW_*|SPACE_*|SYSTEM_*|HF_*|NODE_*|npm_*) continue ;;
|
|
@@ -23,14 +43,23 @@ done
|
|
| 23 |
|
| 24 |
export HF_TOKEN="${HF_TOKEN:-}"
|
| 25 |
|
|
|
|
|
|
|
| 26 |
echo "[entrypoint] Running setup..."
|
| 27 |
node /app/spaces/huggingface/setup-hf-config.mjs || true
|
| 28 |
echo "[entrypoint] Setup done."
|
| 29 |
|
|
|
|
|
|
|
| 30 |
if [ -f /app/security-check.sh ]; then
|
| 31 |
sh /app/security-check.sh || true
|
| 32 |
fi
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
(
|
| 35 |
DEVICES_DIR="$OPENCLAW_HOME/.openclaw/devices"
|
| 36 |
mkdir -p "$DEVICES_DIR"
|
|
@@ -69,12 +98,17 @@ try {
|
|
| 69 |
fs.writeFileSync(pendingPath, '[]');
|
| 70 |
console.log('[auto-pair] Approved ' + toApprove.length + ' device(s)');
|
| 71 |
}
|
| 72 |
-
} catch(e) { }
|
| 73 |
JSEOF
|
| 74 |
fi
|
| 75 |
done
|
| 76 |
) &
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
echo "[entrypoint] Starting gateway loop..."
|
| 79 |
while true; do
|
| 80 |
echo "[entrypoint] Gateway starting..."
|
|
@@ -85,4 +119,4 @@ while true; do
|
|
| 85 |
EXIT_CODE=$?
|
| 86 |
echo "[entrypoint] Gateway exited (code $EXIT_CODE) - restarting in 2s..."
|
| 87 |
sleep 2
|
| 88 |
-
done
|
|
|
|
| 1 |
#!/bin/sh
|
| 2 |
|
| 3 |
+
# OpenClaw HF Spaces - Production Entrypoint
|
| 4 |
+
# Storage: HF Storage Bucket mounted at /data (100 GB, persists across restarts)
|
| 5 |
+
|
| 6 |
+
# -- resolve writable home ----------------------------------------
|
| 7 |
+
|
| 8 |
+
OPENCLAW_HOME=/home/user
|
| 9 |
+
mkdir -p /home/user/.openclaw
|
| 10 |
+
|
| 11 |
+
if [ -d /data ]; then
|
| 12 |
+
if touch /data/.bucket-write-test 2>/dev/null; then
|
| 13 |
+
rm -f /data/.bucket-write-test
|
| 14 |
+
OPENCLAW_HOME=/data
|
| 15 |
+
mkdir -p /data/.openclaw
|
| 16 |
+
echo "[entrypoint] Storage bucket at /data is writable - using persistent storage"
|
| 17 |
+
else
|
| 18 |
+
echo "[entrypoint] WARNING: /data exists but is not writable - falling back to ephemeral /home/user"
|
| 19 |
+
fi
|
| 20 |
+
else
|
| 21 |
+
echo "[entrypoint] WARNING: /data not found - bucket may not be mounted, using ephemeral /home/user"
|
| 22 |
+
fi
|
| 23 |
|
| 24 |
export OPENCLAW_HOME
|
| 25 |
echo "[entrypoint] OPENCLAW_HOME=$OPENCLAW_HOME"
|
| 26 |
|
| 27 |
+
# -- dynamic provider key export ----------------------------------
|
| 28 |
+
|
| 29 |
for VAR in $(env | cut -d= -f1); do
|
| 30 |
case "$VAR" in
|
| 31 |
OPENCLAW_*|SPACE_*|SYSTEM_*|HF_*|NODE_*|npm_*) continue ;;
|
|
|
|
| 43 |
|
| 44 |
export HF_TOKEN="${HF_TOKEN:-}"
|
| 45 |
|
| 46 |
+
# -- run setup (patch mode: preserves user settings) --------------
|
| 47 |
+
|
| 48 |
echo "[entrypoint] Running setup..."
|
| 49 |
node /app/spaces/huggingface/setup-hf-config.mjs || true
|
| 50 |
echo "[entrypoint] Setup done."
|
| 51 |
|
| 52 |
+
# -- security audit -----------------------------------------------
|
| 53 |
+
|
| 54 |
if [ -f /app/security-check.sh ]; then
|
| 55 |
sh /app/security-check.sh || true
|
| 56 |
fi
|
| 57 |
|
| 58 |
+
# -- auto-approve pending device pairings -------------------------
|
| 59 |
+
|
| 60 |
+
# Sub-agents connecting as nodes require device pairing.
|
| 61 |
+
# This loop detects pending pairing requests and approves them automatically.
|
| 62 |
+
|
| 63 |
(
|
| 64 |
DEVICES_DIR="$OPENCLAW_HOME/.openclaw/devices"
|
| 65 |
mkdir -p "$DEVICES_DIR"
|
|
|
|
| 98 |
fs.writeFileSync(pendingPath, '[]');
|
| 99 |
console.log('[auto-pair] Approved ' + toApprove.length + ' device(s)');
|
| 100 |
}
|
| 101 |
+
} catch(e) { /* ignore */ }
|
| 102 |
JSEOF
|
| 103 |
fi
|
| 104 |
done
|
| 105 |
) &
|
| 106 |
|
| 107 |
+
# -- gateway loop -------------------------------------------------
|
| 108 |
+
|
| 109 |
+
# Gateway exits on config save (OpenClaw full process restart).
|
| 110 |
+
# Loop keeps container alive and restarts gateway in 2s.
|
| 111 |
+
|
| 112 |
echo "[entrypoint] Starting gateway loop..."
|
| 113 |
while true; do
|
| 114 |
echo "[entrypoint] Gateway starting..."
|
|
|
|
| 119 |
EXIT_CODE=$?
|
| 120 |
echo "[entrypoint] Gateway exited (code $EXIT_CODE) - restarting in 2s..."
|
| 121 |
sleep 2
|
| 122 |
+
done
|