diff --git a/gotelegram-bot/bot.py b/gotelegram-bot/bot.py index 999e49a..76581e2 100644 --- a/gotelegram-bot/bot.py +++ b/gotelegram-bot/bot.py @@ -100,7 +100,7 @@ logger = logging.getLogger(__name__) # CONFIGURATION # ============================================================================ -GOTELEGRAM_VERSION = "2.4.3" +GOTELEGRAM_VERSION = "2.4.4" GOTELEGRAM_CONFIG = "/opt/gotelegram/config.json" TELEMT_CONFIG = "/etc/telemt/config.toml" TELEMT_SERVICE = "telemt" diff --git a/install.sh b/install.sh old mode 100755 new mode 100644 index 4e0e8be..f9d880b --- a/install.sh +++ b/install.sh @@ -751,11 +751,21 @@ menu_bot() { bot_install() { log_step "$(t bot_install_step)" - # Python - if ! command -v python3 &>/dev/null; then + # Python + venv + pip (always ensure — python3 can be present without venv/pip) + local need_py=0 + command -v python3 &>/dev/null || need_py=1 + # python3-venv not having its own command; probe by trying 'python3 -m venv --help' + if ! python3 -m venv --help &>/dev/null; then need_py=1; fi + # pip check + if ! python3 -m pip --version &>/dev/null; then need_py=1; fi + + if [ "$need_py" = "1" ]; then log_info "$(t bot_install_python)" if command -v apt-get &>/dev/null; then - apt-get update -qq && apt-get install -y -qq python3 python3-pip python3-venv + apt-get update -qq + # python3-full pulls venv, pip, distutils — safer than piece-by-piece + apt-get install -y -qq python3 python3-venv python3-pip python3-full 2>/dev/null || \ + apt-get install -y -qq python3 python3-venv python3-pip elif command -v dnf &>/dev/null; then dnf install -y -q python3 python3-pip elif command -v yum &>/dev/null; then @@ -786,13 +796,45 @@ bot_install() { [ -f "$SCRIPT_DIR/templates_catalog.json" ] && \ cp "$SCRIPT_DIR/templates_catalog.json" "$GOTELEGRAM_DIR/" - # Venv - if [ ! -d "$BOT_DIR/venv" ]; then + # Venv — create, and verify pip exists (python3-venv can silently create broken venv) + if [ ! -d "$BOT_DIR/venv" ] || [ ! -x "$BOT_DIR/venv/bin/pip" ]; then log_info "$(t bot_create_venv)" - python3 -m venv "$BOT_DIR/venv" + rm -rf "$BOT_DIR/venv" + if ! python3 -m venv "$BOT_DIR/venv" 2>/tmp/venv_err; then + log_error "venv creation failed: $(cat /tmp/venv_err 2>/dev/null)" + # Try to fix by reinstalling python3-venv + if command -v apt-get &>/dev/null; then + apt-get install --reinstall -y -qq python3-venv python3-pip python3-full 2>/dev/null || true + python3 -m venv "$BOT_DIR/venv" || { log_error "venv still broken, aborting"; return 1; } + else + return 1 + fi + fi fi + + if [ ! -x "$BOT_DIR/venv/bin/pip" ]; then + log_info "bootstrapping pip via ensurepip..." + "$BOT_DIR/venv/bin/python" -m ensurepip --upgrade 2>/dev/null || true + fi + + if [ ! -x "$BOT_DIR/venv/bin/pip" ]; then + log_error "pip missing in venv — install python3-venv manually: apt install python3-venv python3-pip" + return 1 + fi + log_info "$(t bot_install_deps)" - "$BOT_DIR/venv/bin/pip" install -r "$BOT_DIR/requirements.txt" -q + if ! "$BOT_DIR/venv/bin/pip" install -r "$BOT_DIR/requirements.txt" -q 2>/tmp/pip_err; then + log_error "pip install failed:" + tail -n 5 /tmp/pip_err >&2 + return 1 + fi + + # Sanity check: verify critical imports succeed + if ! "$BOT_DIR/venv/bin/python" -c "import telegram, toml, dotenv" 2>/tmp/imp_err; then + log_error "dependency import check failed:" + cat /tmp/imp_err >&2 + return 1 + fi # Configuration if [ ! -f "$BOT_DIR/.env" ]; then @@ -862,14 +904,13 @@ SVCEOF has_ids=$(grep "^ALLOWED_IDS=" "$BOT_DIR/.env" 2>/dev/null | cut -d= -f2) if [ -z "$has_ids" ]; then echo "" - echo -e " ${YELLOW}╔══════════════════════════════════════════════════════╗${NC}" - printf " ${YELLOW}║${NC} ${BOLD}%-52s${NC} ${YELLOW}║${NC}\n" "$(t bot_wait_admin_title)" - echo -e " ${YELLOW}║${NC} ${YELLOW}║${NC}" - printf " ${YELLOW}║${NC} %s ${CYAN}/start${NC}%*s${YELLOW}║${NC}\n" "$(t bot_wait_admin_msg1)" 0 "" - printf " ${YELLOW}║${NC} %-52s ${YELLOW}║${NC}\n" "$(t bot_wait_admin_msg2)" - echo -e " ${YELLOW}║${NC} ${YELLOW}║${NC}" - printf " ${YELLOW}║${NC} ${DIM}%-52s${NC} ${YELLOW}║${NC}\n" "$(t bot_wait_admin_skip)" - echo -e " ${YELLOW}╚══════════════════════════════════════════════════════╝${NC}" + # Simple bullet-style block (no box — printf %-Ns breaks on UTF-8 multibyte chars) + echo -e " ${YELLOW}▸${NC} ${BOLD}$(t bot_wait_admin_title)${NC}" + echo "" + echo -e " $(t bot_wait_admin_msg1) ${CYAN}/start${NC}" + echo -e " $(t bot_wait_admin_msg2)" + echo "" + echo -e " ${DIM}$(t bot_wait_admin_skip)${NC}" echo "" local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏') diff --git a/lib/common.sh b/lib/common.sh index 536e1a8..9abf57c 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -3,7 +3,7 @@ # Colors, logging, spinner, system helpers, v1 compat, i18n-aware # ── Version ─────────────────────────────────────────────────────────────────── -GOTELEGRAM_VERSION="2.4.3" +GOTELEGRAM_VERSION="2.4.4" GOTELEGRAM_NAME="GoTelegram" # ── Пути ──────────────────────────────────────────────────────────────────────