2023-08-05 18:57:50 +03:00
|
|
|
|
#!/bin/bash
|
2024-03-10 11:55:31 +03:00
|
|
|
|
##
|
2024-11-27 22:38:23 +03:00
|
|
|
|
# TorrentPier – Bull-powered BitTorrent tracker engine
|
2024-04-12 02:22:19 +03:00
|
|
|
|
# EngineGP (https://enginegp.ru or https://enginegp.com)
|
2024-03-10 11:55:31 +03:00
|
|
|
|
#
|
2024-11-27 22:38:23 +03:00
|
|
|
|
# @copyright Copyright (c) 2024-present TorrentPier (https://torrentpier.com)
|
|
|
|
|
# @copyright Copyright (c) 2024-present Solovev Sergei <inbox@seansolovev.ru>
|
|
|
|
|
#
|
|
|
|
|
# @link https://github.com/torrentpier/autoinstall for the canonical source repository
|
2024-04-12 02:22:19 +03:00
|
|
|
|
# @link https://github.com/EngineGPDev/Autoinstall for the canonical source repository
|
|
|
|
|
#
|
2024-11-27 22:38:23 +03:00
|
|
|
|
# @license https://github.com/torrentpier/autoinstall/blob/main/LICENSE MIT License
|
2024-04-12 02:22:19 +03:00
|
|
|
|
# @license https://github.com/EngineGPDev/Autoinstall/blob/main/LICENSE MIT License
|
2024-03-10 11:55:31 +03:00
|
|
|
|
##
|
2024-03-09 21:51:32 +03:00
|
|
|
|
|
2023-10-22 22:37:21 +03:00
|
|
|
|
clear
|
|
|
|
|
|
2024-11-27 22:38:23 +03:00
|
|
|
|
# Arrays and variables used
|
|
|
|
|
suppOs=("debian" "ubuntu")
|
|
|
|
|
aptOs=("debian" "ubuntu")
|
|
|
|
|
currOs=$(grep ^ID= /etc/os-release | awk -F= '{print $2}')
|
2024-11-27 16:45:05 +03:00
|
|
|
|
logsInst="/var/log/enginegp_install.log"
|
2023-10-22 22:37:21 +03:00
|
|
|
|
|
2024-11-27 22:38:23 +03:00
|
|
|
|
# User verification
|
|
|
|
|
if [ "$(whoami)" != "root" ]; then
|
|
|
|
|
echo "It needs to be run under the root user!" 2>&1 | tee -a "$logsInst"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2024-08-18 00:37:21 +03:00
|
|
|
|
|
|
|
|
|
# Проверка, есть ли currOs в массиве suppOs
|
|
|
|
|
foundOs=false
|
|
|
|
|
for os in "${suppOs[@]}"; do
|
|
|
|
|
if [[ "$os" == "$currOs" ]]; then
|
|
|
|
|
foundOs=true
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
2023-08-06 01:55:44 +03:00
|
|
|
|
|
|
|
|
|
# Проверка аргументов командной строки
|
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
|
# Переменные для хранения
|
2024-08-18 00:37:21 +03:00
|
|
|
|
verPhp=""
|
|
|
|
|
sysIp=""
|
|
|
|
|
gitEgp=""
|
2023-08-06 01:55:44 +03:00
|
|
|
|
|
|
|
|
|
# Перебор всех аргументов
|
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
|
key="$1"
|
|
|
|
|
|
|
|
|
|
case $key in
|
|
|
|
|
--php)
|
|
|
|
|
# Если передан аргумент --php, сохранить указанную версию PHP
|
2024-08-18 00:37:21 +03:00
|
|
|
|
verPhp="$2"
|
2023-08-06 01:55:44 +03:00
|
|
|
|
shift # Пропустить значение версии
|
|
|
|
|
shift # Пропустить аргумент --php
|
|
|
|
|
;;
|
|
|
|
|
--ip)
|
|
|
|
|
# Если передан аргумент --ip, сохранить указанный IP-адрес
|
2024-08-18 00:37:21 +03:00
|
|
|
|
sysIp="$2"
|
2023-08-06 01:55:44 +03:00
|
|
|
|
shift # Пропустить значение IP-адреса
|
|
|
|
|
shift # Пропустить аргумент --ip
|
|
|
|
|
;;
|
2024-04-10 22:16:36 +03:00
|
|
|
|
--branch)
|
|
|
|
|
# Если передан аргумент --ip, сохранить указанный IP-адрес
|
2024-08-18 00:37:21 +03:00
|
|
|
|
gitEgp="$2"
|
2024-04-10 22:16:36 +03:00
|
|
|
|
shift # Пропустить значение ветки
|
|
|
|
|
shift # Пропустить аргумент --branch
|
|
|
|
|
;;
|
2023-08-06 01:55:44 +03:00
|
|
|
|
*)
|
|
|
|
|
# Неизвестный аргумент, вывести справку и выйти
|
|
|
|
|
clear
|
2024-09-07 19:29:26 +03:00
|
|
|
|
echo "Использование: ./install.sh --php 8.2 --ip 192.168.1.1 --branch main"
|
|
|
|
|
echo " --php версия: установить указанную версию PHP. Формат должен быть: 8.2"
|
2023-10-12 22:47:04 +03:00
|
|
|
|
echo " --ip IP-адрес: использовать указанный IP-адрес. Формат должен быть: 192.168.1.1"
|
2024-04-10 22:16:36 +03:00
|
|
|
|
echo " --branch ветка: использовать указаную ветку GIT. Формат должен быть: main"
|
2023-08-06 01:55:44 +03:00
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
2024-10-05 03:13:02 +03:00
|
|
|
|
fi
|
2023-08-06 01:55:44 +03:00
|
|
|
|
|
2024-10-05 03:13:02 +03:00
|
|
|
|
# Если версия PHP не выбрана, использовать PHP 7.4 по умолчанию
|
|
|
|
|
if [ -z "$verPhp" ]; then
|
|
|
|
|
verPhp="8.2"
|
|
|
|
|
fi
|
2023-08-06 01:55:44 +03:00
|
|
|
|
|
2024-10-05 03:13:02 +03:00
|
|
|
|
# Если IP-адрес не указан, получить внешний IP-адрес с помощью сервиса ipinfo.io
|
|
|
|
|
if [ -z "$sysIp" ]; then
|
|
|
|
|
sysIp=$(ip a | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '127.0.0.1' | head -n 1)
|
|
|
|
|
fi
|
2024-04-10 22:16:36 +03:00
|
|
|
|
|
2024-11-27 22:47:00 +03:00
|
|
|
|
# Если ветка не указана, использовать main (Временно beta)
|
2024-10-05 03:13:02 +03:00
|
|
|
|
if [ -z "$gitEgp" ]; then
|
2024-11-27 22:47:00 +03:00
|
|
|
|
gitEgp="beta"
|
2023-08-06 01:55:44 +03:00
|
|
|
|
fi
|
2023-08-05 18:57:50 +03:00
|
|
|
|
|
|
|
|
|
# Проверяем, является ли полученный IP-адрес действительным IPv4 адресом
|
2024-08-18 00:37:21 +03:00
|
|
|
|
if [[ ! $sysIp =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
2023-08-06 01:55:44 +03:00
|
|
|
|
clear
|
2023-08-05 18:57:50 +03:00
|
|
|
|
echo "Не удалось получить внешний IP-адрес"
|
2023-08-06 01:55:44 +03:00
|
|
|
|
echo "Используй: ./install.sh [--ip IP-адрес]"
|
|
|
|
|
exit
|
2023-08-05 18:57:50 +03:00
|
|
|
|
fi
|
|
|
|
|
|
2024-11-27 22:38:23 +03:00
|
|
|
|
# Checking for system support
|
|
|
|
|
foundOs=false
|
|
|
|
|
for os in "${suppOs[@]}"; do
|
|
|
|
|
if [[ "$os" == "$currOs" ]]; then
|
|
|
|
|
foundOs=true
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
2023-10-19 22:04:04 +03:00
|
|
|
|
|
2024-11-27 22:38:23 +03:00
|
|
|
|
# Downloading and running the installation file
|
|
|
|
|
if $foundOs; then
|
|
|
|
|
for os in "${aptOs[@]}"; do
|
|
|
|
|
if [[ "$os" == "$currOs" ]]; then
|
|
|
|
|
# Required packages
|
|
|
|
|
pkgsList=("jq" "curl" "zip" "unzip")
|
|
|
|
|
|
|
|
|
|
# Updating tables and packages
|
|
|
|
|
echo "===================================" 2>&1 | tee -a "$logsInst" > /dev/null
|
|
|
|
|
echo "Updating tables and packages" | tee -a "$logsInst"
|
|
|
|
|
echo "===================================" 2>&1 | tee -a "$logsInst" > /dev/null
|
|
|
|
|
apt-get -y update 2>&1 | tee -a "$logsInst" > /dev/null
|
|
|
|
|
apt-get -y dist-upgrade 2>&1 | tee -a "$logsInst" > /dev/null
|
|
|
|
|
|
|
|
|
|
# Check and installation sudo
|
|
|
|
|
if ! dpkg-query -W -f='${Status}' "sudo" 2>/dev/null | grep -q "install ok installed"; then
|
|
|
|
|
echo "===================================" 2>&1 | tee -a "$logsInst" > /dev/null
|
|
|
|
|
echo "sudo not installed. Installation in progress..." | tee -a "$logsInst"
|
|
|
|
|
echo "===================================" 2>&1 | tee -a "$logsInst" > /dev/null
|
|
|
|
|
apt-get install -y sudo 2>&1 | tee -a "$logsInst" > /dev/null
|
2023-10-12 22:47:04 +03:00
|
|
|
|
fi
|
2023-11-20 03:26:14 +03:00
|
|
|
|
|
2024-11-27 22:38:23 +03:00
|
|
|
|
# Package installation cycle
|
|
|
|
|
for package in "${pkgsList[@]}"; do
|
|
|
|
|
# Checking for packages and installing packages
|
|
|
|
|
if ! dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -q "install ok installed"; then
|
2024-08-18 00:37:21 +03:00
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-27 22:38:23 +03:00
|
|
|
|
echo "$package not installed. Installation in progress..." | tee -a "$logsInst"
|
2024-08-18 00:37:21 +03:00
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-27 22:38:23 +03:00
|
|
|
|
sudo apt-get install -y "$package" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2023-11-20 03:26:14 +03:00
|
|
|
|
fi
|
2024-11-27 22:38:23 +03:00
|
|
|
|
done
|
2024-09-15 23:52:38 +03:00
|
|
|
|
|
2024-11-27 22:38:23 +03:00
|
|
|
|
# Preparing a temporary catalog
|
2024-08-18 00:37:21 +03:00
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-27 22:38:23 +03:00
|
|
|
|
echo "Preparing a temporary catalog" | tee -a "$logsInst"
|
2024-08-18 00:37:21 +03:00
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-27 22:38:23 +03:00
|
|
|
|
sudo mkdir -p /tmp/enginegp 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
sudo rm -rf /tmp/enginegp/* 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
|
|
|
|
|
# Downloading the installation script
|
2024-08-18 00:37:21 +03:00
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-27 22:38:23 +03:00
|
|
|
|
echo "Downloading the installation script" | tee -a "$logsInst"
|
2024-08-18 00:37:21 +03:00
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-27 22:38:23 +03:00
|
|
|
|
curl -s https://api.github.com/repos/EngineGPDev/Autoinstall/releases | jq -r 'map(select(.prerelease == true)) | .[0].zipball_url' | xargs -n 1 curl -L -o /tmp/enginegp/autoinstall.zip 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
sudo unzip -o /tmp/enginegp/autoinstall.zip -d /tmp/enginegp 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
sudo mv /tmp/enginegp/*Autoinstall-* /tmp/enginegp/autoinstall 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
|
|
|
|
|
# Starting the automatic installation
|
2024-08-18 00:37:21 +03:00
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-27 22:38:23 +03:00
|
|
|
|
echo "Starting the automatic installation" | tee -a "$logsInst"
|
2024-08-18 00:37:21 +03:00
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-27 22:38:23 +03:00
|
|
|
|
sudo chmod +x /tmp/enginegp/autoinstall/deb.install.sh 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
sudo /tmp/enginegp/autoinstall/deb.install.sh --php "$verPhp" --ip "$sysIp" --branch "$gitEgp"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
else
|
|
|
|
|
echo "Your system is not supported." 2>&1 | tee -a "$logsInst"
|
|
|
|
|
fi
|