add bootstrap.sh installer

This commit is contained in:
anten-ka
2026-04-09 11:15:43 +03:00
parent c70cb36a2b
commit d70e046035

115
bootstrap.sh Executable file
View File

@@ -0,0 +1,115 @@
#!/bin/bash
# GoTelegram Pro — Bootstrap installer for private repo
# Downloads all files and launches install.sh
set -euo pipefail
REPO="anten-ka/gotelegram_pro"
BRANCH="test"
PAT="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"
INSTALL_DIR="/opt/gotelegram"
API="https://api.github.com/repos/${REPO}/contents"
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
NC='\033[0m'
BOLD='\033[1m'
echo ""
echo -e " ${YELLOW}╔══════════════════════════════════════════════════════╗${NC}"
echo -e " ${YELLOW}${NC} ${BOLD}GoTelegram Pro — Установка${NC} ${YELLOW}${NC}"
echo -e " ${YELLOW}${NC} ${YELLOW}${NC}"
echo -e " ${YELLOW}${NC} MTProxy менеджер с Telegram-ботом ${YELLOW}${NC}"
echo -e " ${YELLOW}${NC} Stealth-режим, 1800+ шаблонов сайтов ${YELLOW}${NC}"
echo -e " ${YELLOW}╚══════════════════════════════════════════════════════╝${NC}"
echo ""
# Check root
if [ "$(id -u)" -ne 0 ]; then
echo -e " ${RED}${NC} Запустите от root: ${CYAN}sudo bash bootstrap.sh${NC}"
exit 1
fi
# Check dependencies
for cmd in curl jq; do
if ! command -v "$cmd" &>/dev/null; then
echo -e " ${CYAN}${NC} Установка $cmd..."
apt-get update -qq && apt-get install -y -qq "$cmd" >/dev/null 2>&1
fi
done
download_file() {
local remote_path="$1"
local local_path="$2"
local dir
dir=$(dirname "$local_path")
mkdir -p "$dir"
local http_code
http_code=$(curl -sL -w "%{http_code}" -o "$local_path" \
-H "Authorization: token ${PAT}" \
-H "Accept: application/vnd.github.raw" \
"${API}/${remote_path}?ref=${BRANCH}")
if [ "$http_code" != "200" ]; then
echo -e " ${RED}${NC} Ошибка загрузки ${remote_path} (HTTP ${http_code})"
return 1
fi
return 0
}
# File list
FILES=(
"install.sh"
"install_gotelegram_bot.sh"
"templates_catalog.json"
"lib/common.sh"
"lib/telemt.sh"
"lib/telemt_config.sh"
"lib/backup.sh"
"lib/website.sh"
"lib/templates_catalog.sh"
"lib/stats.sh"
"gotelegram-bot/bot.py"
"gotelegram-bot/config.example.env"
"gotelegram-bot/requirements.txt"
"gotelegram-bot/README.md"
)
echo -e " ${CYAN}${NC} Загрузка файлов в ${INSTALL_DIR}..."
mkdir -p "${INSTALL_DIR}/lib" "${INSTALL_DIR}/gotelegram-bot"
failed=0
for f in "${FILES[@]}"; do
if download_file "$f" "${INSTALL_DIR}/${f}"; then
echo -e " ${GREEN}${NC} ${f}"
else
failed=$((failed + 1))
fi
done
if [ "$failed" -gt 0 ]; then
echo ""
echo -e " ${RED}${NC} Не удалось загрузить ${failed} файл(ов)"
echo -e " ${YELLOW}Проверьте токен доступа и подключение к сети${NC}"
exit 1
fi
# Fix permissions and line endings
echo -e " ${CYAN}${NC} Настройка прав..."
chmod +x "${INSTALL_DIR}/install.sh" "${INSTALL_DIR}/install_gotelegram_bot.sh"
chmod +x "${INSTALL_DIR}"/lib/*.sh
sed -i 's/\r$//' "${INSTALL_DIR}/install.sh" "${INSTALL_DIR}/install_gotelegram_bot.sh" "${INSTALL_DIR}"/lib/*.sh 2>/dev/null
# Create symlink
ln -sf "${INSTALL_DIR}/install.sh" /usr/local/bin/gotelegram
echo -e " ${GREEN}${NC} Команда ${CYAN}gotelegram${NC} доступна"
echo ""
echo -e " ${GREEN}${NC} Установка завершена! Запуск..."
echo ""
# Launch
exec bash "${INSTALL_DIR}/install.sh"