/
kreyndelHam
/
Konstructorium
Обзор
Документация
Войти
/
kreyndelHam
/
Konstructorium
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
Безопасность
dev
scripts/telegram/verify_dev.sh
81 строка
2 KB
MihahamYT
Telegram Bot Working
25 май 2026, 20:20
25 май 2026, 20:20
1089971
Код
Авторство
О чём код?
#!/usr/bin/env bash # Verify Docker API ports and optionally Telegram Bot API reachability (VPN dev). set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" CI_MODE=0 ENV_FILE="${ENV_FILE:-$ROOT/telegram_bot_service/.env}" while [[ $# -gt 0 ]]; do case "$1" in --ci) CI_MODE=1 shift ;; *) echo "Unknown argument: $1 (supported: --ci)" exit 2 ;; esac done check_url() { local label="$1" local url="$2" if curl -fsS --max-time 10 "$url" >/dev/null 2>&1; then echo "[OK] $label ($url)" return 0 fi echo "[FAIL] $label ($url)" return 1 } failed=0 echo "=== Konstructorium telegram VPN dev checks ===" check_url "auth_service health" "http://127.0.0.1:8001/api/health/" || failed=1 check_url "user_service health" "http://127.0.0.1:8002/api/health/" || failed=1 check_url "product_service models" "http://127.0.0.1:8003/api/models/" || failed=1 check_url "order_service health" "http://127.0.0.1:8004/api/health/" || failed=1 if [[ "$CI_MODE" -eq 1 ]]; then if [[ "$failed" -ne 0 ]]; then echo "CI mode: one or more local API checks failed." exit 1 fi echo "CI mode: local API checks passed (Telegram skipped)." exit 0 fi if [[ -f "$ENV_FILE" ]]; then # shellcheck disable=SC1090 set -a source <(grep -E '^[A-Z_]+=' "$ENV_FILE" | sed 's/\r$//') set +a fi if [[ -z "${TELEGRAM_BOT_TOKEN:-}" ]]; then echo "[SKIP] TELEGRAM_BOT_TOKEN not set; Telegram getMe skipped." echo "Set token in telegram_bot_service/.env and enable VPN (or TELEGRAM_PROXY_URL)." if [[ "$failed" -ne 0 ]]; then exit 1 fi exit 0 fi telegram_url="https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getMe" if curl -fsS --max-time 20 "$telegram_url" >/dev/null 2>&1; then echo "[OK] Telegram API getMe (VPN/proxy route working)" else echo "[FAIL] Telegram API getMe unreachable." echo " Enable VPN on the host or set TELEGRAM_PROXY_URL in telegram_bot_service/.env" failed=1 fi if [[ "$failed" -ne 0 ]]; then exit 1 fi echo "All checks passed."