warp-proxy / entrypoint.sh
TomatitoToho's picture
Upload entrypoint.sh with huggingface_hub
03511b8 verified
Raw
History Blame Contribute Delete
1.29 kB
#!/bin/bash
# entrypoint.sh for WARP Proxy Space
# Starts WARP daemon as root, then runs the app
echo "[ENTRYPOINT] WARP Proxy Space starting..."
# Start WARP daemon
if command -v warp-svc &> /dev/null; then
echo "[WARP] Starting warp-svc..."
warp-svc &
sleep 3
# Register and connect
echo "[WARP] Registering..."
warp-cli --accept-tos registration new 2>/dev/null || true
echo "[WARP] Setting proxy mode..."
warp-cli --accept-tos mode proxy 2>/dev/null || true
echo "[WARP] Connecting..."
warp-cli --accept-tos connect 2>/dev/null || true
# Wait for connection
for i in $(seq 1 20); do
STATUS=$(warp-cli --accept-tos status 2>/dev/null | head -1 || echo "")
if echo "$STATUS" | grep -qi "connected"; then
echo "[WARP] CONNECTED! SOCKS5 proxy active on 127.0.0.1:40000"
break
fi
echo "[WARP] Waiting... ($i/20)"
sleep 2
done
else
echo "[WARP] warp-svc not found! WARP will not be available."
fi
# Start the app
echo "[ENTRYPOINT] Starting proxy app..."
cd /app
# Run as user if we're root (HF Spaces compatibility)
if [ "$(id -u)" = "0" ]; then
exec su user -s /bin/bash -c "cd /app && exec python app.py"
else
exec python app.py
fi