mirror of
https://github.com/anten-ka/gotelegram_pro.git
synced 2026-05-19 15:36:03 +00:00
install.sh: при токене только git clone (raw не работает для приватного репо), установка git
Made-with: Cursor
This commit is contained in:
48
install.sh
48
install.sh
@@ -22,19 +22,25 @@ REPO_RAW="${GOTETELEGRAM_REPO_RAW:-https://raw.githubusercontent.com/anten-ka/go
|
|||||||
|
|
||||||
echo -e "${GREEN}[*] GoTelegram Bot — установка...${NC}"
|
echo -e "${GREEN}[*] GoTelegram Bot — установка...${NC}"
|
||||||
|
|
||||||
# Зависимости
|
# Зависимости (python3, curl, git для приватного репо)
|
||||||
if ! command -v python3 &>/dev/null; then
|
if ! command -v python3 &>/dev/null; then
|
||||||
if command -v apt-get &>/dev/null; then
|
if command -v apt-get &>/dev/null; then
|
||||||
apt-get update && apt-get install -y python3 python3-pip python3-venv curl
|
apt-get update && apt-get install -y python3 python3-pip python3-venv curl git
|
||||||
elif command -v dnf &>/dev/null; then
|
elif command -v dnf &>/dev/null; then
|
||||||
dnf install -y python3 python3-pip python3-virtualenv curl 2>/dev/null || dnf install -y python3 python3-pip curl
|
dnf install -y python3 python3-pip python3-virtualenv curl git 2>/dev/null || dnf install -y python3 python3-pip curl git
|
||||||
elif command -v yum &>/dev/null; then
|
elif command -v yum &>/dev/null; then
|
||||||
yum install -y python3 python3-pip curl
|
yum install -y python3 python3-pip curl git
|
||||||
else
|
else
|
||||||
echo -e "${RED}Установите python3 и curl.${NC}"
|
echo -e "${RED}Установите python3 и curl.${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$GITHUB_TOKEN" ] && ! command -v git &>/dev/null; then
|
||||||
|
echo -e "${GREEN}[*] Установка git для клонирования приватного репо...${NC}"
|
||||||
|
if command -v apt-get &>/dev/null; then apt-get update && apt-get install -y git; fi
|
||||||
|
if command -v dnf &>/dev/null; then dnf install -y git; fi
|
||||||
|
if command -v yum &>/dev/null; then yum install -y git; fi
|
||||||
|
fi
|
||||||
if ! command -v docker &>/dev/null; then
|
if ! command -v docker &>/dev/null; then
|
||||||
echo -e "${YELLOW}[!] Docker не найден. Нужен для /install в боте.${NC}"
|
echo -e "${YELLOW}[!] Docker не найден. Нужен для /install в боте.${NC}"
|
||||||
fi
|
fi
|
||||||
@@ -42,34 +48,30 @@ fi
|
|||||||
mkdir -p "$BOT_DIR"
|
mkdir -p "$BOT_DIR"
|
||||||
cd "$BOT_DIR"
|
cd "$BOT_DIR"
|
||||||
|
|
||||||
# Скачивание файлов бота по raw URL (с токеном для приватного репо)
|
# Получение файлов бота: при токене — только git clone (raw для приватного не работает)
|
||||||
fetch_file() {
|
|
||||||
local f="$1"
|
|
||||||
if [ -n "$GITHUB_TOKEN" ]; then
|
|
||||||
curl -sL -f -H "Authorization: token $GITHUB_TOKEN" "$REPO_RAW/gotelegram-bot/$f" -o "$BOT_DIR/$f" 2>/dev/null && return 0
|
|
||||||
fi
|
|
||||||
curl -sL -f "$REPO_RAW/gotelegram-bot/$f" -o "$BOT_DIR/$f" 2>/dev/null && return 0
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -f "$BOT_DIR/bot.py" ]; then
|
if [ ! -f "$BOT_DIR/bot.py" ]; then
|
||||||
echo -e "${GREEN}[*] Загрузка файлов из репозитория...${NC}"
|
echo -e "${GREEN}[*] Загрузка файлов из репозитория...${NC}"
|
||||||
OK=1
|
if [ -n "$GITHUB_TOKEN" ] && command -v git &>/dev/null; then
|
||||||
for f in bot.py requirements.txt config.example.env; do
|
|
||||||
fetch_file "$f" || { OK=0; break; }
|
|
||||||
done
|
|
||||||
if [ "$OK" -eq 0 ] && [ -n "$GITHUB_TOKEN" ] && command -v git &>/dev/null; then
|
|
||||||
echo -e "${GREEN}[*] Клонирование по токену...${NC}"
|
|
||||||
TMP="/tmp/gotelegram_pro_$$"
|
TMP="/tmp/gotelegram_pro_$$"
|
||||||
git clone --depth 1 --branch main "https://${GITHUB_TOKEN}@github.com/anten-ka/gotelegram_pro.git" "$TMP" 2>/dev/null && {
|
if git clone --depth 1 --branch main "https://${GITHUB_TOKEN}@github.com/anten-ka/gotelegram_pro.git" "$TMP" 2>/tmp/gotelegram_clone_err_$$; then
|
||||||
cp -r "$TMP/gotelegram-bot"/* "$BOT_DIR/"
|
cp -r "$TMP/gotelegram-bot"/* "$BOT_DIR/"
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
}
|
else
|
||||||
|
echo -e "${RED}Ошибка клонирования:${NC}"
|
||||||
|
cat /tmp/gotelegram_clone_err_$$ 2>/dev/null
|
||||||
|
rm -rf "$TMP" /tmp/gotelegram_clone_err_$$ 2>/dev/null
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
rm -f /tmp/gotelegram_clone_err_$$
|
||||||
|
else
|
||||||
|
# Публичный репо — пробуем curl
|
||||||
|
for f in bot.py requirements.txt config.example.env; do
|
||||||
|
curl -sL -f "$REPO_RAW/gotelegram-bot/$f" -o "$BOT_DIR/$f" 2>/dev/null || true
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$BOT_DIR/bot.py" ]; then
|
if [ ! -f "$BOT_DIR/bot.py" ]; then
|
||||||
echo -e "${RED}Не удалось загрузить файлы. Для приватного репо запустите с токеном:${NC}"
|
echo -e "${RED}Не удалось загрузить файлы. Для приватного репо запустите с токеном:${NC}"
|
||||||
echo -e " ${YELLOW}gotelegram ВАШ_GITHUB_ТОКЕН${NC}"
|
echo -e " ${YELLOW}gotelegram ВАШ_GITHUB_ТОКЕН${NC}"
|
||||||
echo -e " или: ${YELLOW}GITHUB_TOKEN=ВАШ_ТОКЕН gotelegram${NC}"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user