mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-06 11:35:29 +00:00
Script di installazione per principali os
Script di installazione per principali sistemi unix(Linux/MacOS) e windows
This commit is contained in:
parent
dd094d5b98
commit
2c8444ab12
122
unix_install.sh
Normal file
122
unix_install.sh
Normal file
@ -0,0 +1,122 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to check if a command exists
|
||||
command_exists() {
|
||||
command -v "$1" &> /dev/null
|
||||
}
|
||||
|
||||
# Install OpenSSL on Debian/Ubuntu-based systems
|
||||
install_on_debian() {
|
||||
echo "Detected Debian-based system. Installing $1..."
|
||||
sudo apt update
|
||||
sudo apt install -y $1
|
||||
}
|
||||
|
||||
# Install OpenSSL on Red Hat/CentOS/Fedora-based systems
|
||||
install_on_redhat() {
|
||||
echo "Detected Red Hat-based system. Installing $1..."
|
||||
sudo yum install -y $1
|
||||
}
|
||||
|
||||
# Install OpenSSL on Arch-based systems
|
||||
install_on_arch() {
|
||||
echo "Detected Arch-based system. Installing $1..."
|
||||
sudo pacman -Sy --noconfirm $1
|
||||
}
|
||||
|
||||
# Install OpenSSL on macOS
|
||||
install_on_macos() {
|
||||
echo "Detected macOS. Installing $1..."
|
||||
if command_exists brew; then
|
||||
brew install $1
|
||||
else
|
||||
echo "Homebrew is not installed. Installing Homebrew first..."
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
brew install $1
|
||||
fi
|
||||
}
|
||||
|
||||
# Get the Python version
|
||||
PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')
|
||||
|
||||
# Compare the Python version with 3.8
|
||||
REQUIRED_VERSION="3.8"
|
||||
|
||||
if [[ $(echo -e "$PYTHON_VERSION\n$REQUIRED_VERSION" | sort -V | head -n1) == "$REQUIRED_VERSION" ]]; then
|
||||
echo "Python version $PYTHON_VERSION is >= $REQUIRED_VERSION. Continuing..."
|
||||
else
|
||||
echo "ERROR: Python version $PYTHON_VERSION is < $REQUIRED_VERSION. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d ".venv/" ]; then
|
||||
echo ".venv exists."
|
||||
else
|
||||
echo "Making .venv and installing requirements.txt."
|
||||
python3 -m venv .venv
|
||||
.venv/bin/pip install -r requirements.txt
|
||||
fi
|
||||
|
||||
if command -v ffmpeg > /dev/null 2>&1; then
|
||||
echo "ffmpeg exists."
|
||||
else
|
||||
# Detect the platform and install ffmpeg accordingly
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# Detect the package manager
|
||||
if command_exists apt; then
|
||||
install_on_debian "ffmpeg"
|
||||
elif command_exists yum; then
|
||||
install_on_redhat "ffmpeg"
|
||||
elif command_exists pacman; then
|
||||
install_on_arch "ffmpeg"
|
||||
else
|
||||
echo "Unsupported Linux distribution."
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
install_on_macos "ffmpeg"
|
||||
else
|
||||
echo "Unsupported operating system."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if command -v openssl > /dev/null 2>&1 || .venv/bin/pip list | grep -q "pycryptodome"; then
|
||||
echo "openssl or pycryptodome exists."
|
||||
else
|
||||
echo "Please choose an option:"
|
||||
echo "1) openssl"
|
||||
echo "2) pycryptodome"
|
||||
read -p "Enter your choice (1): " choice
|
||||
case $choice in
|
||||
2)
|
||||
echo "Installing pycryptodome."
|
||||
.venv/bin/pip install pycryptodome
|
||||
;;
|
||||
*)
|
||||
echo "Installing openssl."
|
||||
# Detect the platform and install OpenSSL accordingly
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# Detect the package manager
|
||||
if command_exists apt; then
|
||||
install_on_debian "openssl"
|
||||
elif command_exists yum; then
|
||||
install_on_redhat "openssl"
|
||||
elif command_exists pacman; then
|
||||
install_on_arch "openssl"
|
||||
else
|
||||
echo "Unsupported Linux distribution."
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
install_on_macos "openssl"
|
||||
else
|
||||
echo "Unsupported operating system."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
sed -i.bak "1s|.*|#!.venv/bin/python3|" run.py
|
||||
echo "Everything is installed!"
|
118
win_install.bat
Normal file
118
win_install.bat
Normal file
@ -0,0 +1,118 @@
|
||||
@echo off
|
||||
REM Get the Python version
|
||||
for /f "delims=" %%v in ('python -c "import sys; print('.'.join(map(str, sys.version_info[:3])))"') do set PYTHON_VERSION=%%v
|
||||
|
||||
REM Set the required version
|
||||
set REQUIRED_VERSION=3.8
|
||||
|
||||
REM Compare the Python version with the required version
|
||||
REM Split versions by dot and compare each segment
|
||||
setlocal enabledelayedexpansion
|
||||
for /f "tokens=1-3 delims=." %%a in ("%PYTHON_VERSION%") do (
|
||||
set PYTHON_MAJOR=%%a
|
||||
set PYTHON_MINOR=%%b
|
||||
set PYTHON_PATCH=%%c
|
||||
)
|
||||
|
||||
for /f "tokens=1-3 delims=." %%a in ("%REQUIRED_VERSION%") do (
|
||||
set REQUIRED_MAJOR=%%a
|
||||
set REQUIRED_MINOR=%%b
|
||||
set REQUIRED_PATCH=%%c
|
||||
)
|
||||
|
||||
REM Compare major version
|
||||
if !PYTHON_MAJOR! LSS !REQUIRED_MAJOR! (
|
||||
echo ERROR: Python version !PYTHON_VERSION! is < !REQUIRED_VERSION!. Exiting...
|
||||
exit /b 1
|
||||
) else if !PYTHON_MAJOR! EQU !REQUIRED_MAJOR! (
|
||||
REM Compare minor version
|
||||
if !PYTHON_MINOR! LSS !REQUIRED_MINOR! (
|
||||
echo ERROR: Python version !PYTHON_VERSION! is < !REQUIRED_VERSION!. Exiting...
|
||||
exit /b 1
|
||||
) else if !PYTHON_MINOR! EQU !REQUIRED_MINOR! (
|
||||
REM Compare patch version
|
||||
if !PYTHON_PATCH! LSS !REQUIRED_PATCH! (
|
||||
echo ERROR: Python version !PYTHON_VERSION! is < !REQUIRED_VERSION!. Exiting...
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
echo Python version !PYTHON_VERSION! is >= !REQUIRED_VERSION!. Continuing...
|
||||
|
||||
if exist ".venv\" (
|
||||
echo .venv exists.
|
||||
) else (
|
||||
echo Making .venv and installing requirements.txt.
|
||||
python -m venv .venv
|
||||
.venv\Scripts\pip install -r requirements.txt
|
||||
)
|
||||
|
||||
where /Q ffmpeg >nul 2>nul
|
||||
if %errorlevel% neq 1 (
|
||||
echo ffmpeg exists.
|
||||
) else (
|
||||
echo ffmpeg not found. Checking for Chocolatey...
|
||||
|
||||
REM Check if Chocolatey is installed
|
||||
where /Q choco >nul 2>nul
|
||||
if %errorlevel% neq 1 (
|
||||
echo Installing ffmpeg using Chocolatey...
|
||||
choco install ffmpeg -y
|
||||
) else (
|
||||
echo Chocolatey is not installed.
|
||||
echo Please install Chocolatey first from https://chocolatey.org/install
|
||||
echo After installing Chocolatey, you can run this script again to install ffmpeg.
|
||||
echo Alternatively, you can install ffmpeg manually from https://www.ffmpeg.org/
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
REM Check if OpenSSL exists
|
||||
where /Q openssl >nul 2>nul
|
||||
if %errorlevel% neq 1 (
|
||||
echo openssl exists.
|
||||
goto end
|
||||
)
|
||||
|
||||
REM Check if pycryptodome is installed
|
||||
.venv\Scripts\pip list | findstr /i "pycryptodome" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo pycryptodome exists.
|
||||
goto end
|
||||
)
|
||||
|
||||
REM Prompt for installation option
|
||||
echo Please choose an option:
|
||||
echo 1) openssl
|
||||
echo 2) pycryptodome
|
||||
set /p choice="Enter your choice (1): "
|
||||
|
||||
REM Handle the choice
|
||||
if "%choice%"=="2" (
|
||||
echo Installing pycryptodome.
|
||||
.venv\Scripts\pip install pycryptodome
|
||||
) else (
|
||||
echo Installing openssl.
|
||||
echo Checking for Chocolatey...
|
||||
|
||||
REM Check if Chocolatey is installed
|
||||
where /Q choco >nul 2>nul
|
||||
if %errorlevel% neq 1 (
|
||||
echo Installing openssl using Chocolatey...
|
||||
choco install openssl -y
|
||||
) else (
|
||||
echo Chocolatey is not installed.
|
||||
echo Please install Chocolatey first from https://chocolatey.org/install
|
||||
echo After installing Chocolatey, you can run this script again to install openssl.
|
||||
echo Alternatively, you can install OpenSSH manually from https://www.openssl.com/.
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
:end
|
||||
|
||||
setlocal enabledelayedexpansion & set "tempfile=%temp%\tempfile.txt" & (echo #^^!.venv\Scripts\python & type run.py | more +1) > "!tempfile!" & move /Y "!tempfile!" run.py >nul 2>nul
|
||||
|
||||
echo Everything is installed^^!
|
Loading…
x
Reference in New Issue
Block a user