v2.4.7: fix telemt download (skip GitHub API rate limit, direct CDN URL + musl fallback)

This commit is contained in:
anten-ka
2026-04-11 20:15:18 +03:00
parent b10ea54ce9
commit bb2502e1fc
3 changed files with 55 additions and 25 deletions

View File

@@ -100,7 +100,7 @@ logger = logging.getLogger(__name__)
# CONFIGURATION
# ============================================================================
GOTELEGRAM_VERSION = "2.4.6"
GOTELEGRAM_VERSION = "2.4.7"
GOTELEGRAM_CONFIG = "/opt/gotelegram/config.json"
TELEMT_CONFIG = "/etc/telemt/config.toml"
TELEMT_SERVICE = "telemt"

2
lib/common.sh Executable file → Normal file
View File

@@ -3,7 +3,7 @@
# Colors, logging, spinner, system helpers, v1 compat, i18n-aware
# ── Version ───────────────────────────────────────────────────────────────────
GOTELEGRAM_VERSION="2.4.6"
GOTELEGRAM_VERSION="2.4.7"
GOTELEGRAM_NAME="GoTelegram"
# ── Пути ──────────────────────────────────────────────────────────────────────

76
lib/telemt.sh Executable file → Normal file
View File

@@ -19,27 +19,40 @@ get_latest_telemt_version() {
}
get_telemt_download_url() {
local arch
# Detect arch and map to telemt asset naming convention
local arch arch_name
arch=$(get_arch)
local resp
resp=$(curl -s --max-time 10 "$TELEMT_RELEASE_API" 2>/dev/null)
if [ -z "$resp" ]; then return 1; fi
# URL format: telemt-x86_64-linux-gnu.tar.gz (arch BEFORE linux)
local arch_pattern
case "$arch" in
amd64) arch_pattern="(amd64|x86_64)" ;;
arm64) arch_pattern="(arm64|aarch64)" ;;
armv7) arch_pattern="(armv7|arm)" ;;
*) arch_pattern="${arch}" ;;
amd64) arch_name="x86_64" ;;
arm64) arch_name="aarch64" ;;
armv7) arch_name="armv7" ;;
*) arch_name="$arch" ;;
esac
echo "$resp" | jq -r ".assets[].browser_download_url" 2>/dev/null \
| grep -iE "$arch_pattern" \
| grep -i "linux" \
| grep -v "sha256" \
| grep "gnu" \
| head -1
# IMPORTANT: We do NOT query the GitHub releases API here.
# Reason: VPS providers (Hetzner/Hostkey/Aeza/DO/Selectel) share IPv4 with
# many other tenants → unauthenticated GitHub API rate limit (60/hour) is
# exhausted constantly → API returns 403 → jq sees no assets → install
# fails with "не найден бинарник".
#
# The endpoint /releases/latest/download/<file> is a stable redirect served
# from GitHub's CDN — it does NOT count against the API rate limit and
# always points at the latest non-prerelease asset by exact filename.
# Asset name format: telemt-<arch>-linux-gnu.tar.gz
echo "https://github.com/${TELEMT_GITHUB}/releases/latest/download/telemt-${arch_name}-linux-gnu.tar.gz"
}
# Fallback URL using musl libc (some minimal distros / older glibc)
get_telemt_download_url_musl() {
local arch arch_name
arch=$(get_arch)
case "$arch" in
amd64) arch_name="x86_64" ;;
arm64) arch_name="aarch64" ;;
armv7) arch_name="armv7" ;;
*) arch_name="$arch" ;;
esac
echo "https://github.com/${TELEMT_GITHUB}/releases/latest/download/telemt-${arch_name}-linux-musl.tar.gz"
}
# ── Установленная версия ─────────────────────────────────────────────────────
@@ -69,18 +82,35 @@ download_telemt() {
log_info "Скачивание: $url"
if ! curl -L -s --max-time 120 -o "$tmp_file" "$url"; then
log_error "Ошибка скачивания telemt"
rm -f "$tmp_file"
return 1
log_warning "Не удалось скачать gnu-сборку, пробую musl..."
url=$(get_telemt_download_url_musl)
log_info "Скачивание: $url"
if ! curl -L -s --max-time 120 -o "$tmp_file" "$url"; then
log_error "Ошибка скачивания telemt (gnu и musl)"
rm -f "$tmp_file"
return 1
fi
fi
# Проверяем что файл не пустой и не HTML
local file_size
file_size=$(stat -c%s "$tmp_file" 2>/dev/null || echo 0)
if [ "$file_size" -lt 1000 ]; then
log_error "Скачанный файл слишком маленький ($file_size байт) — возможна ошибка сети"
rm -f "$tmp_file"
return 1
# Try musl as fallback if gnu came back empty/error-html
log_warning "Файл подозрительно мал ($file_size байт), пробую musl-сборку..."
url=$(get_telemt_download_url_musl)
log_info "Скачивание: $url"
if ! curl -L -s --max-time 120 -o "$tmp_file" "$url"; then
log_error "Ошибка скачивания telemt (musl fallback)"
rm -f "$tmp_file"
return 1
fi
file_size=$(stat -c%s "$tmp_file" 2>/dev/null || echo 0)
if [ "$file_size" -lt 1000 ]; then
log_error "Скачанный файл слишком маленький ($file_size байт) — возможна ошибка сети"
rm -f "$tmp_file"
return 1
fi
fi
# Определяем тип файла и распаковываем