tune scripts

This commit is contained in:
Oleg Proskurin 2026-06-08 01:53:57 +07:00
parent f4b75ebb7d
commit ddc41779d0
1 changed files with 13 additions and 2 deletions

View File

@ -17,12 +17,23 @@ PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
[ -f "$PROJECT_ROOT/.env" ] || { echo "missing $PROJECT_ROOT/.env (copy .env.example and fill it in)" >&2; exit 1; } [ -f "$PROJECT_ROOT/.env" ] || { echo "missing $PROJECT_ROOT/.env (copy .env.example and fill it in)" >&2; exit 1; }
set -a; . "$PROJECT_ROOT/.env"; set +a set -a; . "$PROJECT_ROOT/.env"; set +a
# Pick the session string for the requested account, then aggressively drop all
# suffixed TELEGRAM_SESSION_STRING_* vars from the environment so telegram-mcp's
# auto-discovery (runtime.py: _discover_accounts) does NOT load the other
# account as a secondary client on this server. Each MCP server must expose
# exactly one identity = "default".
case "$ACCOUNT" in case "$ACCOUNT" in
usulsu) export TELEGRAM_SESSION_STRING="${TELEGRAM_SESSION_STRING:-}" ;; usulsu) SESSION="${TELEGRAM_SESSION_STRING:-}" ;;
helper) export TELEGRAM_SESSION_STRING="${TELEGRAM_SESSION_STRING_HELPER:-}" ;; helper) SESSION="${TELEGRAM_SESSION_STRING_HELPER:-}" ;;
*) echo "account must be 'usulsu' or 'helper'" >&2; exit 1 ;; *) echo "account must be 'usulsu' or 'helper'" >&2; exit 1 ;;
esac esac
while IFS='=' read -r name _; do
case "$name" in TELEGRAM_SESSION_STRING_*|TELEGRAM_SESSION_NAME_*) unset "$name" ;; esac
done < <(env)
export TELEGRAM_SESSION_STRING="$SESSION"
if [ -z "${TELEGRAM_API_ID:-}" ] || [ -z "${TELEGRAM_API_HASH:-}" ]; then if [ -z "${TELEGRAM_API_ID:-}" ] || [ -z "${TELEGRAM_API_HASH:-}" ]; then
echo "TELEGRAM_API_ID / TELEGRAM_API_HASH missing in $PROJECT_ROOT/.env" >&2 echo "TELEGRAM_API_ID / TELEGRAM_API_HASH missing in $PROJECT_ROOT/.env" >&2
exit 1 exit 1