Telemax/install.sh
Folist 876db31ffd Guard every apt-get call in install.sh against the same broken-trigger issue
The initramfs-tools/dhcpcd trigger from the previous fix doesn't just fail
once — it re-fires and fails on every subsequent apt-get call until the
underlying missing .so is actually fixed, confirmed live: it took down the
git/jq install step too, right after upgrade had already been guarded.
Route every apt-get through one wrapper instead of patching call sites
one at a time as they turn up, and verify Docker actually landed rather
than trusting get.docker.com's own exit code (it shells out to apt-get
internally and can hit the same thing).
2026-08-14 08:42:31 +03:00

90 lines
3.7 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# One-command bootstrap for a bare Ubuntu/Debian server: system update, git,
# Docker, clone the repo, hand off to setup.sh for the interactive key setup.
#
# Usage (as root, on a fresh server):
# curl -fsSL https://raw.githubusercontent.com/Trollobot/Telemax/main/install.sh | bash
#
# Safe to re-run: skips steps that are already done (git/Docker already
# installed, repo already cloned — pulls latest instead).
set -euo pipefail
REPO_URL="https://github.com/Trollobot/Telemax.git"
INSTALL_DIR="/opt/telemax"
bold() { printf '\033[1m%s\033[0m\n' "$1"; }
if [ "$(id -u)" -ne 0 ]; then
echo "Запустите от root (на большинстве VPS вы и так root по SSH; иначе — sudo -i, затем повторите команду)."
exit 1
fi
export DEBIAN_FRONTEND=noninteractive
# Best-effort apt wrapper. Some VPS images ship with an unrelated package
# already broken (seen live — initramfs-tools' dhcpcd hook failing on a
# missing .so with nothing to do with Telemax) whose dpkg trigger re-fires
# and fails on EVERY subsequent apt-get call, not just the one that first
# surfaced it — upgrade, then installing jq, then (if left unguarded) the
# Docker install too. The package we actually asked for still installs fine
# each time; only that unrelated trigger's own exit code is non-zero.
# Aborting the whole bootstrap over someone else's package is worse than
# warning once and moving on, so every apt-get call in this script goes
# through this instead of a bare one.
apt_get() {
if ! apt-get "$@"; then
echo "⚠️ apt-get $* завершился с предупреждением (см. вывод выше) — похоже, дело в стороннем пакете, не связанном с Telemax. Продолжаю; если хотите разобраться отдельно, обычно помогает: dpkg --configure -a"
dpkg --configure -a >/dev/null 2>&1 || true
fi
}
bold "=== Telemax — установка на чистый сервер ==="
echo
echo "[1/5] Обновляю систему (может занять несколько минут)..."
apt-get update -y
apt_get upgrade -y
echo
echo "[2/5] Проверяю git и jq..."
# jq: used by setup.sh to auto-detect the Telegram group id (no need to hunt
# for it manually — see setup.sh).
for pkg in git jq; do
if ! command -v "$pkg" >/dev/null 2>&1; then
apt_get install -y "$pkg"
fi
done
echo
echo "[3/5] Проверяю Docker..."
if ! command -v docker >/dev/null 2>&1; then
# get.docker.com's own script calls apt-get install internally and can hit
# the exact same recurring trigger issue — don't trust its exit code alone,
# check whether docker actually landed afterward.
curl -fsSL https://get.docker.com | sh || true
if ! command -v docker >/dev/null 2>&1; then
echo "❌ Docker всё ещё не установлен после попытки. Разберитесь с ошибкой apt выше (обычно: dpkg --configure -a), затем запустите install.sh заново."
exit 1
fi
else
echo "Docker уже установлен."
fi
systemctl enable --now docker >/dev/null 2>&1 || true
echo
echo "[4/5] Скачиваю проект в $INSTALL_DIR..."
if [ -d "$INSTALL_DIR/.git" ]; then
echo "Уже склонировано — обновляю до последней версии..."
git -C "$INSTALL_DIR" pull --ff-only
else
git clone "$REPO_URL" "$INSTALL_DIR"
fi
cd "$INSTALL_DIR"
echo
bold "Окружение готово, переходим к настройке."
echo
# curl | bash consumes stdin for the script itself — reconnect to the real
# terminal so setup.sh's prompts (bot token, group id) actually work.
exec ./setup.sh < /dev/tty