Aggiunto script di installazione automatico (#171)

* Aggiunto shebang iniziale

Aggiunto shebang iniziale che verrà sostituito dall install script con il percorso python adeguato permettendo di eseguire run.py senza prefissare python o python3

* Script di installazione per principali os

Script di installazione per principali sistemi unix(Linux/MacOS) e windows

* Update unix_install.sh

* Update README.md con Automatic Installation e anchor link

* Update README.md

* Update README.md

* Update win_install.bat

* Update README.md

* Update README.md

* Update unix_install.sh

* Update unix_install.sh

* Update win_install.bat

* Update win_install.bat

* Update README.md

* Avvio amministratore

* Update unix_install.sh

* Update unix_install.sh, conversione da bash a sh, supporto bsd
This commit is contained in:
BluTiger 2024-10-01 17:32:33 +02:00 committed by GitHub
parent 0a93ba9590
commit c33d58e6f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 439 additions and 11 deletions

View File

@ -11,18 +11,73 @@ You can chat, help improve this repo, or just hang around for some fun in the **
# Table of Contents # Table of Contents
* [INSTALLATION](#installation) * [INSTALLATION](#installation)
* [Automatic Installation](#automatic-installation)
* [Usage](#usage-automatic)
* [Supported OSs for Automatic Installation](#automatic-installation-os)
* [Manual Installation](#manual-installation)
* [Requirement](#requirement) * [Requirement](#requirement)
* [Usage](#usage) * [Usage](#usage-manual)
* [Win 7](https://github.com/Ghost6446/StreamingCommunity_api/wiki/Installation#win-7) * [Win 7](https://github.com/Ghost6446/StreamingCommunity_api/wiki/Installation#win-7)
* [Termux](https://github.com/Ghost6446/StreamingCommunity_api/wiki/Termux) * [Termux](https://github.com/Ghost6446/StreamingCommunity_api/wiki/Termux)
* [Update](#update) * [Update](#update)
* [CONFIGURATION](#Configuration) * [CONFIGURATION](#configuration)
* [DOCKER](#docker) * [DOCKER](#docker)
* [TUTORIAL](#tutorial) * [TUTORIAL](#tutorial)
* [TO DO](#to-do) * [TO DO](#to-do)
# INSTALLATION
## Requirement 📋 ## Automatic Installation
<a id="automatic-installation-os"></a>
### Supported OSs for Automatic Installation 💿
- Supported ✔️
- Not tested ⏳
- Not supported ❌
| OS | Automatic Installation Support |
|:--------------------|:--------------------:|
| Windows 10/11 | ✔️ |
| Windows 7 | ❌ |
| Debian Linux | ✔️ |
| Arch Linux | ✔️ |
| CentOS Stream 9 | ✔️ |
| FreeBSD | ⏳ |
| MacOS | ✔️ |
| Termux | ❌ |
### Installation ⚙️
Run the following command inside the main directory:
#### On Windows:
```powershell
.\win_install.bat
```
#### On Linux/MacOS/BSD:
```bash
sudo chmod +x unix_install.sh && ./unix_install.sh
```
<a id="usage-automatic"></a>
### Usage 📚
Run the script with the following command:
#### On Windows:
```powershell
.\run.py
```
or
```powershell
.venv\Scripts\python .\run.py
```
#### On Linux/MacOS/BSD:
```bash
./run.py
```
## Manual Installation
<a id="requirement"></a>
### Requirement 📋
Make sure you have the following prerequisites installed on your system: Make sure you have the following prerequisites installed on your system:
@ -30,7 +85,7 @@ Make sure you have the following prerequisites installed on your system:
* [ffmpeg](https://www.gyan.dev/ffmpeg/builds/) * [ffmpeg](https://www.gyan.dev/ffmpeg/builds/)
* [openssl](https://www.openssl.org) or [pycryptodome](https://pypi.org/project/pycryptodome/) * [openssl](https://www.openssl.org) or [pycryptodome](https://pypi.org/project/pycryptodome/)
## Installation ⚙️ ### Installation ⚙️
Install the required Python libraries using the following command: Install the required Python libraries using the following command:
@ -38,7 +93,8 @@ Install the required Python libraries using the following command:
pip install -r requirements.txt pip install -r requirements.txt
``` ```
## Usage 📚 <a id="usage-manual"></a>
### Usage 📚
Run the script with the following command: Run the script with the following command:
@ -71,7 +127,7 @@ python update_version.py
python3 update_version.py python3 update_version.py
``` ```
<a id="configuration"></a>
## Configuration ⚙️ ## Configuration ⚙️
You can change some behaviors by tweaking the configuration file. You can change some behaviors by tweaking the configuration file.
@ -164,6 +220,7 @@ You can choose different vars:
> NOTE: You don't need to add .mp4 at the end > NOTE: You don't need to add .mp4 at the end
<a id="docker"></a>
## Docker 🐳 ## Docker 🐳
You can run the script in a docker container, to build the image just run You can run the script in a docker container, to build the image just run
@ -197,13 +254,14 @@ make LOCAL_DIR=/path/to/download run-container
The `run-container` command mounts also the `config.json` file, so any change to the configuration file is reflected immediately without having to rebuild the image. The `run-container` command mounts also the `config.json` file, so any change to the configuration file is reflected immediately without having to rebuild the image.
<a id="tutorial"></a>
## Tutorial 📖 ## Tutorial 📖
For a detailed walkthrough, refer to the [video tutorial](https://www.youtube.com/watch?v=Ok7hQCgxqLg&ab_channel=Nothing) For a detailed walkthrough, refer to the [video tutorial](https://www.youtube.com/watch?v=Ok7hQCgxqLg&ab_channel=Nothing)
Add [api_1](https://www.youtube.com/watch?v=3ylBSMyQlhM) Add [api_1](https://www.youtube.com/watch?v=3ylBSMyQlhM)
Add [api_2](https://www.youtube.com/watch?v=ReEYUIbdbG4) Add [api_2](https://www.youtube.com/watch?v=ReEYUIbdbG4)
<a id="to-do"></a>
## To do 📝 ## To do 📝
- GUI - GUI
- Website api - Website api

1
run.py
View File

@ -1,3 +1,4 @@
#!
# 10.12.23 # 10.12.23
import os import os

200
unix_install.sh Normal file
View File

@ -0,0 +1,200 @@
#!/bin/sh
# Function to check if a command exists
command_exists() {
command -v "$1" > /dev/null 2>&1
}
# Install on Debian/Ubuntu-based systems
install_on_debian() {
echo "Installing $1..."
sudo apt update
sudo apt install -y "$1"
}
# Install on Red Hat/CentOS/Fedora-based systems
install_on_redhat() {
echo "Installing $1..."
sudo yum install -y "$1"
}
# Install on Arch-based systems
install_on_arch() {
echo "Installing $1..."
sudo pacman -Sy --noconfirm "$1"
}
# Install on BSD-based systems
install_on_bsd() {
echo "Installing $1..."
env ASSUME_ALWAYS_YES=yes sudo pkg install -y "$1"
}
# Install on macOS
install_on_macos() {
echo "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
}
set -e
# Check and install Python3
# if command_exists python3 > /dev/null 2>&1; then
# echo "Checking Python..."
# else
# # Detect the platform and install Python3 accordingly
# if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# # Detect the package manager
# if command_exists apt; then
# install_on_debian "python3"
# elif command_exists yum; then
# install_on_redhat "python3"
# elif command_exists pacman; then
# install_on_arch "python-pip"
# else
# echo "Unsupported Linux distribution."
# exit 1
# fi
# elif [[ "$OSTYPE" == "bsd"* ]]; then
# echo "Detected BSD-based system."
# install_on_bsd "python39"
# elif [[ "$OSTYPE" == "darwin"* ]]; then
# install_on_macos "python"
# else
# echo "Unsupported operating system."
# exit 1
# fi
# 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. Installing requirements.txt..."
.venv/bin/pip install -r requirements.txt
else
echo "Making .venv and installing requirements.txt..."
if [ "$(uname)" = "Linux" ]; then
# Detect the package manager for venv installation check.
if command_exists apt; then
echo "Detected Debian-based system. Checking python3-venv."
if dpkg -l | grep -q "python3-venv"; then
echo "python3-venv found."
else
echo "python3-venv not found, installing..."
install_on_debian "python3-venv"
fi
fi
fi
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
fi
if command_exists ffmpeg; then
echo "ffmpeg exists."
else
echo "ffmpeg does not exist."
# Detect the platform and install ffmpeg accordingly.
case "$(uname)" in
Linux)
if command_exists apt; then
echo "Detected Debian-based system."
install_on_debian "ffmpeg"
elif command_exists yum; then
echo "Detected Red Hat-based system."
echo "Installing needed repos for ffmpeg..."
sudo yum config-manager --set-enabled crb > /dev/null 2>&1 || true
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %rhel).noarch.rpm https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-$(rpm -E %rhel).noarch.rpm > /dev/null 2>&1 || true
sudo yum install -y --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm > /dev/null 2>&1 || true
install_on_redhat "ffmpeg"
elif command_exists pacman; then
echo "Detected Arch-based system."
install_on_arch "ffmpeg"
else
echo "Unsupported Linux distribution."
exit 1
fi
;;
FreeBSD|NetBSD|OpenBSD)
echo "Detected BSD-based system."
install_on_bsd "ffmpeg"
;;
Darwin)
echo "Detected macOS."
install_on_macos "ffmpeg"
;;
*)
echo "Unsupported operating system."
exit 1
;;
esac
fi
if command_exists openssl || .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
;;
*)
# Detect the platform and install OpenSSL accordingly.
case "$(uname)" in
Linux)
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
;;
FreeBSD|NetBSD|OpenBSD)
install_on_bsd openssl
;;
Darwin)
install_on_macos openssl
;;
*)
echo "Unsupported operating system."
exit 1
;;
esac
;;
esac
fi
sed -i.bak '1s|.*|#!.venv/bin/python3|' run.py
sudo chmod +x run.py
echo 'Everything is installed!'
echo 'Run StreamingCommunity with "./run.py"'

169
win_install.bat Normal file
View File

@ -0,0 +1,169 @@
@echo off
:: BatchGotAdmin
::-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"="
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
::--------------------------------------
REM Check if running in PowerShell
@REM Check and install python
@REM where /q python >nul 2>nul
@REM if %errorlevel% neq 1 (
@REM echo Checking Python...
@REM ) else (
@REM call (exit /b 0)
@REM echo python not found. Checking for Chocolatey...
@REM REM Check if Chocolatey is installed
@REM where /q choco >nul 2>nul
@REM if %errorlevel% neq 1 (
@REM echo Installing python using Chocolatey...
@REM choco install python -y
@REM ) else (
@REM echo Chocolatey is not installed.
@REM echo Please install Chocolatey first from https://chocolatey.org/install
@REM echo After installing Chocolatey, you can run this script again to install ffmpeg.
@REM echo Alternatively, you can install python manually from https://www.python.org/
@REM exit /b 1
@REM )
@REM )
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. Installing requirements.txt.
.venv\Scripts\python -m pip install -r requirements.txt
) else (
echo Making .venv and installing requirements.txt...
python -m venv .venv
.venv\Scripts\python -m pip install -r requirements.txt
)
where /q ffmpeg >nul 2>nul
if %errorlevel% neq 1 (
echo ffmpeg exists.
) else (
call (exit /b 0)
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
)
call (exit /b 0)
REM Check if pycryptodome is installed
.venv\Scripts\pip list | findstr /i "pycryptodome" >nul
if %errorlevel% equ 0 (
echo pycryptodome exists.
goto end
)
call (exit /b 0)
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^^!
echo Run StreamingCommunity with '.\run.py'
pause