2024-11-24 03:57:19 +03:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
##
|
|
|
|
|
# TorrentPier – Bull-powered BitTorrent tracker engine
|
|
|
|
|
#
|
|
|
|
|
# @copyright Copyright (c) 2024-present TorrentPier (https://torrentpier.com)
|
|
|
|
|
# @copyright Copyright (c) 2024-present Solovev Sergei <inbox@seansolovev.ru>
|
2024-11-24 13:48:37 +03:00
|
|
|
|
#
|
2024-11-24 03:57:19 +03:00
|
|
|
|
# @link https://github.com/torrentpier/autoinstall for the canonical source repository
|
|
|
|
|
#
|
|
|
|
|
# @license https://github.com/torrentpier/autoinstall/blob/main/LICENSE MIT License
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
clear
|
|
|
|
|
|
|
|
|
|
# Arrays and variables used
|
|
|
|
|
suppOs=("debian" "ubuntu")
|
|
|
|
|
aptOs=("debian" "ubuntu")
|
2024-11-24 14:27:19 +03:00
|
|
|
|
currOs=$(grep ^ID= /etc/os-release | awk -F= '{print $2}')
|
2024-11-24 03:57:19 +03:00
|
|
|
|
logsInst="/var/log/torrentpier_install.log"
|
|
|
|
|
|
|
|
|
|
# User verification
|
|
|
|
|
if [ "$(whoami)" != "root" ]; then
|
|
|
|
|
echo "It needs to be run under the root user!" 2>&1 | tee -a "$logsInst"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Checking for system support
|
|
|
|
|
foundOs=false
|
|
|
|
|
for os in "${suppOs[@]}"; do
|
|
|
|
|
if [[ "$os" == "$currOs" ]]; then
|
|
|
|
|
foundOs=true
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# 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
|
2024-11-26 15:59:43 +03:00
|
|
|
|
echo "===================================" 2>&1 | tee -a "$logsInst" > /dev/null
|
2024-11-24 03:57:19 +03:00
|
|
|
|
echo "Updating tables and packages" | tee -a "$logsInst"
|
2024-11-26 15:59:43 +03:00
|
|
|
|
echo "===================================" 2>&1 | tee -a "$logsInst" > /dev/null
|
2024-11-24 03:57:19 +03:00
|
|
|
|
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
|
2024-11-26 15:59:43 +03:00
|
|
|
|
echo "===================================" 2>&1 | tee -a "$logsInst" > /dev/null
|
2024-11-24 03:57:19 +03:00
|
|
|
|
echo "sudo not installed. Installation in progress..." | tee -a "$logsInst"
|
2024-11-26 15:59:43 +03:00
|
|
|
|
echo "===================================" 2>&1 | tee -a "$logsInst" > /dev/null
|
|
|
|
|
apt-get install -y sudo 2>&1 | tee -a "$logsInst" > /dev/null
|
2024-11-24 03:57:19 +03:00
|
|
|
|
fi
|
|
|
|
|
|
2024-11-24 13:48:37 +03:00
|
|
|
|
# Package installation cycle
|
2024-11-24 03:57:19 +03:00
|
|
|
|
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
|
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
echo "$package not installed. Installation in progress..." | tee -a "$logsInst"
|
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
sudo apt-get install -y "$package" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Preparing a temporary catalog
|
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
echo "Preparing a temporary catalog" | tee -a "$logsInst"
|
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
sudo mkdir -p /tmp/torrentpier 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
sudo rm -rf /tmp/torrentpier/* 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
|
|
|
|
|
# Downloading the installation script
|
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
echo "Downloading the installation script" | tee -a "$logsInst"
|
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-24 14:31:33 +03:00
|
|
|
|
curl -s https://api.github.com/repos/torrentpier/autoinstall/releases | jq -r 'map(select(.prerelease == true)) | .[0].zipball_url' | xargs -n 1 curl -L -o /tmp/torrentpier/autoinstall.zip 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-24 03:57:19 +03:00
|
|
|
|
sudo unzip -o /tmp/torrentpier/autoinstall.zip -d /tmp/torrentpier 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
sudo mv /tmp/torrentpier/*autoinstall-* /tmp/torrentpier/autoinstall 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
|
|
|
|
|
# Starting the automatic installation
|
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
echo "Starting the automatic installation" | tee -a "$logsInst"
|
|
|
|
|
echo "===================================" 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
2024-11-24 14:36:34 +03:00
|
|
|
|
sudo chmod +x /tmp/torrentpier/autoinstall/deb.install.sh 2>&1 | sudo tee -a "$logsInst" > /dev/null
|
|
|
|
|
sudo /tmp/torrentpier/autoinstall/deb.install.sh
|
2024-11-24 03:57:19 +03:00
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
else
|
|
|
|
|
echo "Your system is not supported." 2>&1 | tee -a "$logsInst"
|
2024-11-24 13:48:37 +03:00
|
|
|
|
fi
|