Spaces:
Sleeping
Sleeping
Hugging Face Deploy commited on
Commit ·
bb7ec5e
1
Parent(s): 29b97cc
Make Telegram optional and avoid startup crash
Browse files- entrypoint.sh +19 -3
entrypoint.sh
CHANGED
|
@@ -7,9 +7,26 @@ PORT_VALUE="${CLAWDBOT_GATEWAY_PORT:-${PORT:-7860}}"
|
|
| 7 |
|
| 8 |
CONFIG_PATH="${CLAWDBOT_CONFIG_PATH:-/data/config/clawdbot.json}"
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
"gateway": {
|
| 14 |
"mode": "local",
|
| 15 |
"bind": "lan",
|
|
@@ -30,6 +47,5 @@ if [ ! -f "$CONFIG_PATH" ]; then
|
|
| 30 |
}
|
| 31 |
}
|
| 32 |
EOF
|
| 33 |
-
fi
|
| 34 |
|
| 35 |
exec clawdbot gateway --bind lan --port "$PORT_VALUE" --allow-unconfigured --verbose
|
|
|
|
| 7 |
|
| 8 |
CONFIG_PATH="${CLAWDBOT_CONFIG_PATH:-/data/config/clawdbot.json}"
|
| 9 |
|
| 10 |
+
TELEGRAM_ENABLED="false"
|
| 11 |
+
if [ "${ENABLE_TELEGRAM:-0}" = "1" ] && [ -n "${TELEGRAM_BOT_TOKEN:-}" ]; then
|
| 12 |
+
if node -e "fetch('https://api.telegram.org').then(()=>process.exit(0)).catch(()=>process.exit(1))"; then
|
| 13 |
+
TELEGRAM_ENABLED="true"
|
| 14 |
+
else
|
| 15 |
+
echo "Telegram API is not reachable from this runtime; starting with Telegram disabled." 1>&2
|
| 16 |
+
fi
|
| 17 |
+
fi
|
| 18 |
+
|
| 19 |
+
cat >"$CONFIG_PATH" <<EOF
|
| 20 |
{
|
| 21 |
+
"commands": {
|
| 22 |
+
"native": "off"
|
| 23 |
+
},
|
| 24 |
+
"channels": {
|
| 25 |
+
"telegram": {
|
| 26 |
+
"enabled": $TELEGRAM_ENABLED,
|
| 27 |
+
"token": "${TELEGRAM_BOT_TOKEN:-}"
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
"gateway": {
|
| 31 |
"mode": "local",
|
| 32 |
"bind": "lan",
|
|
|
|
| 47 |
}
|
| 48 |
}
|
| 49 |
EOF
|
|
|
|
| 50 |
|
| 51 |
exec clawdbot gateway --bind lan --port "$PORT_VALUE" --allow-unconfigured --verbose
|