mirror of
https://github.com/anten-ka/gotelegram_pro.git
synced 2026-05-19 14:26:02 +00:00
66 lines
2.7 KiB
Bash
66 lines
2.7 KiB
Bash
#!/bin/bash
|
||
# Bootstrap: клонирует приватный репозиторий (по SSH или по токену) и запускает установку.
|
||
# Использование:
|
||
# По SSH-ключу: GIT_REPO_SSH=git@github.com:USER/REPO.git bash bootstrap_install.sh
|
||
# По токену: GITHUB_TOKEN=ghp_xxx GIT_REPO_HTTPS=https://github.com/USER/REPO.git bash bootstrap_install.sh
|
||
# Или задайте репо по умолчанию ниже и запустите: sudo bash bootstrap_install.sh
|
||
|
||
set -e
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
NC='\033[0m'
|
||
|
||
# Репозиторий по умолчанию (подставьте свой)
|
||
REPO_SSH="${GIT_REPO_SSH:-git@github.com:anten-ka/gotelegram_pro.git}"
|
||
REPO_HTTPS="${GIT_REPO_HTTPS:-https://github.com/anten-ka/gotelegram_pro.git}"
|
||
BRANCH="${GIT_BRANCH:-main}"
|
||
CLONE_DIR="/tmp/gotelegram_pro_install_$$"
|
||
|
||
cleanup() { rm -rf "$CLONE_DIR"; }
|
||
trap cleanup EXIT
|
||
|
||
echo -e "${GREEN}[*] Установка GoTelegram Bot из приватного репозитория${NC}"
|
||
|
||
if ! command -v git &>/dev/null; then
|
||
echo -e "${YELLOW}[*] Установка git...${NC}"
|
||
if command -v apt-get &>/dev/null; then
|
||
apt-get update && apt-get install -y git
|
||
elif command -v dnf &>/dev/null; then
|
||
dnf install -y git
|
||
elif command -v yum &>/dev/null; then
|
||
yum install -y git
|
||
else
|
||
echo -e "${RED}Установите git вручную.${NC}"
|
||
exit 1
|
||
fi
|
||
fi
|
||
|
||
if [ -n "$GITHUB_TOKEN" ]; then
|
||
echo -e "${GREEN}[*] Клонирование по токену (HTTPS)...${NC}"
|
||
# Подставляем токен в URL для доступа к приватному репо
|
||
if [[ "$REPO_HTTPS" == https://github.com/* ]]; then
|
||
CLONE_URL="https://${GITHUB_TOKEN}@github.com/${REPO_HTTPS#https://github.com/}"
|
||
else
|
||
CLONE_URL="$REPO_HTTPS"
|
||
fi
|
||
git clone --depth 1 --branch "$BRANCH" "$CLONE_URL" "$CLONE_DIR"
|
||
elif [ -n "$GIT_REPO_SSH" ]; then
|
||
echo -e "${GREEN}[*] Клонирование по SSH...${NC}"
|
||
git clone --depth 1 --branch "$BRANCH" "$GIT_REPO_SSH" "$CLONE_DIR"
|
||
else
|
||
echo -e "${GREEN}[*] Клонирование по SSH (ключ по умолчанию)...${NC}"
|
||
git clone --depth 1 --branch "$BRANCH" "$REPO_SSH" "$CLONE_DIR"
|
||
fi
|
||
|
||
if [ ! -f "$CLONE_DIR/install_gotelegram_bot.sh" ]; then
|
||
echo -e "${RED}В репозитории не найден install_gotelegram_bot.sh${NC}"
|
||
exit 1
|
||
fi
|
||
|
||
chmod +x "$CLONE_DIR/install_gotelegram_bot.sh"
|
||
# Передаём токен в установочный скрипт, если использовали HTTPS (для совместимости)
|
||
export GITHUB_TOKEN
|
||
echo -e "${GREEN}[*] Запуск установки...${NC}"
|
||
exec sudo "$CLONE_DIR/install_gotelegram_bot.sh"
|