Spaces:
Sleeping
Sleeping
| set -e | |
| mkdir -p /data/config /data/workspace /data/state | |
| PORT_VALUE="${CLAWDBOT_GATEWAY_PORT:-${PORT:-7860}}" | |
| CONFIG_PATH="${CLAWDBOT_CONFIG_PATH:-/data/config/clawdbot.json}" | |
| TELEGRAM_ENABLED="false" | |
| if [ "${ENABLE_TELEGRAM:-0}" = "1" ] && [ -n "${TELEGRAM_BOT_TOKEN:-}" ]; then | |
| if node -e "fetch('https://api.telegram.org').then(()=>process.exit(0)).catch(()=>process.exit(1))"; then | |
| TELEGRAM_ENABLED="true" | |
| else | |
| echo "Telegram API is not reachable from this runtime; starting with Telegram disabled." 1>&2 | |
| fi | |
| fi | |
| if [ ! -f "$CONFIG_PATH" ]; then | |
| cat >"$CONFIG_PATH" <<EOF | |
| { | |
| "channels": { | |
| "telegram": { | |
| "enabled": $TELEGRAM_ENABLED, | |
| "botToken": "${TELEGRAM_BOT_TOKEN:-}", | |
| "dmPolicy": "pairing", | |
| "commands": { | |
| "native": false, | |
| "nativeSkills": false | |
| } | |
| } | |
| }, | |
| "gateway": { | |
| "mode": "local", | |
| "bind": "lan", | |
| "port": $PORT_VALUE, | |
| "auth": { | |
| "mode": "token", | |
| "token": "${CLAWDBOT_GATEWAY_TOKEN:-}" | |
| }, | |
| "controlUi": { | |
| "enabled": true, | |
| "allowInsecureAuth": true | |
| } | |
| }, | |
| "agents": { | |
| "defaults": { | |
| "workspace": "/data/workspace" | |
| } | |
| } | |
| } | |
| EOF | |
| fi | |
| clawdbot doctor --yes || true | |
| exec clawdbot gateway --bind lan --port "$PORT_VALUE" --allow-unconfigured --verbose | |