diff --git a/README.md b/README.md index 04b1a06..6391d63 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,45 @@ Modern single-page web UI for managing rTorrent through SCGI/XML-RPC. pyTorrent > pyTorrent is a controller for your own rTorrent instance. It does not include a BitTorrent engine and does not bypass tracker, copyright or network rules. +## Install pyTorrent only - recommended first path + +Use this when rTorrent already exists and only the pyTorrent web UI should be installed. The installer creates the pyTorrent service, virtualenv, `.env`, database and a default rTorrent profile. It does **not** install or reconfigure rTorrent. + +Supported systems for `scripts/install_pytorrent_only.sh`: + +- Debian / Ubuntu +- RHEL-compatible distributions: RHEL, Rocky Linux, AlmaLinux, CentOS Stream and Fedora-like systems with `dnf` or `yum` +- Arch Linux + +One-line install from the repository: + +```bash +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_pytorrent.sh | sudo bash +``` + +Local install after cloning: + +```bash +git clone https://github.com/zdzichu6969/pyTorrent.git +cd pyTorrent +sudo bash scripts/install_pytorrent_only.sh +``` + +Non-interactive example for an existing rTorrent SCGI endpoint: + +```bash +sudo bash scripts/install_pytorrent_only.sh \ + --yes \ + --port 8090 \ + --scgi-url scgi://127.0.0.1:5000 \ + --auth enable \ + --auth-provider local \ + --auth-user pytorrent \ + --auth-password 'change-this-password' +``` + +Optional full stack install is described below. Use it only when the server should install and configure rTorrent together with pyTorrent. + ## Highlights - Live torrent table with WebSocket updates and patch-based refreshes. @@ -36,9 +75,9 @@ Modern single-page web UI for managing rTorrent through SCGI/XML-RPC. pyTorrent The project uses Flask, Flask-SocketIO, python-dotenv, psutil, geoip2, gunicorn and related runtime dependencies listed in `requirements.txt`. -## Quick start +## Manual development quick start -Clone the repository and run the local installer: +Clone the repository and run the local development installer: ```bash git clone https://github.com/zdzichu6969/pyTorrent.git @@ -76,9 +115,9 @@ network.scgi.open_port = 127.0.0.1:5000 For production, keep SCGI bound to localhost or a private trusted network only. -## Stack installer +## Optional stack installer -The repository includes a stack installer for a clean server. It can install and configure rTorrent + pyTorrent together. +The repository also includes a stack installer for a clean server. It can install and configure rTorrent + pyTorrent together. Supported systems: @@ -103,10 +142,10 @@ The default stack install creates: | pyTorrent HTTP port | `8090` | | pyTorrent service | `pytorrent` | -### One-line install with rtorrent +### Optional one-line full stack install with rTorrent ```bash -curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/main/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | PYTORRENT_PORT=8091 \ RTORRENT_SCGI_PORT=5001 \ PYTORRENT_PROFILE_NAME="Local rTorrent" \ diff --git a/scripts/INSTALL.md b/scripts/INSTALL.md index 56118c7..c143a66 100644 --- a/scripts/INSTALL.md +++ b/scripts/INSTALL.md @@ -12,7 +12,7 @@ The installer is split into two layers: Run as root or through `sudo`: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh | sudo bash +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh | sudo bash ``` The bootstrap script downloads the current pyTorrent repository, detects the operating system family, and runs the matching installer: @@ -46,14 +46,14 @@ Environment variables must be passed to the `sudo bash` process. Example: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo PYTORRENT_PORT=8091 RTORRENT_SCGI_PORT=5001 bash ``` Another example with a custom profile name: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo PYTORRENT_PROFILE_NAME="Local rTorrent" PYTORRENT_PORT=8090 bash ``` @@ -63,7 +63,7 @@ These variables are used by `scripts/install_stack.sh`. | Variable | Default | Description | | --- | --- | --- | -| `PYTORRENT_REPO_URL` | `https://git.linuxiarz.pl/gru/pyTorrent` | Git repository base URL. | +| `PYTORRENT_REPO_URL` | `https://github.com/zdzichu6969/pyTorrent` | GitHub repository base URL. | | `PYTORRENT_REPO_BRANCH` | `master` | Branch used to download the repository archive. | | `PYTORRENT_ARCHIVE_URL` | derived from repo URL and branch | Custom repository archive URL. | | `PYTORRENT_BOOTSTRAP_DIR` | `/tmp/pytorrent-stack-installer` | Temporary directory used by the bootstrap script. | @@ -72,7 +72,7 @@ These variables are used by `scripts/install_stack.sh`. Example using a different branch: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo PYTORRENT_REPO_BRANCH=develop bash ``` @@ -96,14 +96,14 @@ These variables are used by both stack installers. Example: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo RTORRENT_USER=rtorrent RTORRENT_SCGI_PORT=5001 RTORRENT_TORRENT_PORT=51400 bash ``` Classic xmlrpc-c backend instead of default tinyxml2. On Arch this forces source build: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo RTORRENT_WITH_XMLRPC_C=1 bash ``` @@ -122,7 +122,7 @@ curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/inst Example with API token: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo PYTORRENT_API_TOKEN="pt_xxx" bash ``` @@ -234,7 +234,7 @@ sudo bash scripts/install_pytorrent_only.sh Bootstrap run from repository: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_pytorrent.sh | sudo bash +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_pytorrent.sh | sudo bash ``` Non-interactive example for an existing TCP SCGI backend: diff --git a/scripts/install_pytorrent.sh b/scripts/install_pytorrent.sh index 7e79cfa..0cdc17b 100755 --- a/scripts/install_pytorrent.sh +++ b/scripts/install_pytorrent.sh @@ -3,11 +3,11 @@ set -euo pipefail # Bootstrap installer for pyTorrent only. # Intended usage: -# curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_pytorrent.sh | sudo bash +# curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_pytorrent.sh | sudo bash if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then cat <<'USAGE' -Usage: curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_pytorrent.sh | sudo bash -s -- [options] +Usage: curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_pytorrent.sh | sudo bash -s -- [options] This bootstrap downloads pyTorrent and forwards all options to scripts/install_pytorrent_only.sh. Run scripts/install_pytorrent_only.sh --help inside the repository for the full option list. @@ -20,11 +20,23 @@ if [[ "${EUID}" -ne 0 ]]; then exit 1 fi -REPO_URL="${PYTORRENT_REPO_URL:-https://git.linuxiarz.pl/gru/pyTorrent}" +REPO_URL="${PYTORRENT_REPO_URL:-https://github.com/zdzichu6969/pyTorrent}" REPO_BRANCH="${PYTORRENT_REPO_BRANCH:-master}" WORK_DIR="${PYTORRENT_BOOTSTRAP_DIR:-/tmp/pytorrent-only-installer}" KEEP_WORK_DIR="${PYTORRENT_KEEP_BOOTSTRAP_DIR:-0}" -ARCHIVE_URL="${PYTORRENT_ARCHIVE_URL:-${REPO_URL%/}/archive/${REPO_BRANCH}.tar.gz}" + +default_archive_url() { + case "${REPO_URL%/}" in + https://github.com/*) + printf '%s/archive/refs/heads/%s.tar.gz\n' "${REPO_URL%/}" "${REPO_BRANCH}" + ;; + *) + printf '%s/archive/%s.tar.gz\n' "${REPO_URL%/}" "${REPO_BRANCH}" + ;; + esac +} + +ARCHIVE_URL="${PYTORRENT_ARCHIVE_URL:-$(default_archive_url)}" PROJECT_DIR="${WORK_DIR}/src" ARCHIVE_PATH="${WORK_DIR}/pytorrent.tar.gz" diff --git a/scripts/install_stack.sh b/scripts/install_stack.sh index a17787d..107cd65 100755 --- a/scripts/install_stack.sh +++ b/scripts/install_stack.sh @@ -3,7 +3,7 @@ set -euo pipefail # Bootstrap installer for pyTorrent + rTorrent. # Intended usage from a clean server: -# curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh | sudo bash +# curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh | sudo bash # # The script downloads the current pyTorrent repository, detects the OS family, # and runs the matching installer from scripts/stack_installers/. @@ -13,13 +13,37 @@ if [[ "${EUID}" -ne 0 ]]; then exit 1 fi -REPO_URL="${PYTORRENT_REPO_URL:-https://git.linuxiarz.pl/gru/pyTorrent}" +REPO_URL="${PYTORRENT_REPO_URL:-https://github.com/zdzichu6969/pyTorrent}" REPO_BRANCH="${PYTORRENT_REPO_BRANCH:-master}" WORK_DIR="${PYTORRENT_BOOTSTRAP_DIR:-/tmp/pytorrent-stack-installer}" KEEP_WORK_DIR="${PYTORRENT_KEEP_BOOTSTRAP_DIR:-0}" -RAW_BASE="${REPO_URL%/}/raw/branch/${REPO_BRANCH}" -ARCHIVE_URL="${PYTORRENT_ARCHIVE_URL:-${REPO_URL%/}/archive/${REPO_BRANCH}.tar.gz}" +default_archive_url() { + case "${REPO_URL%/}" in + https://github.com/*) + printf '%s/archive/refs/heads/%s.tar.gz\n' "${REPO_URL%/}" "${REPO_BRANCH}" + ;; + *) + printf '%s/archive/%s.tar.gz\n' "${REPO_URL%/}" "${REPO_BRANCH}" + ;; + esac +} + +default_raw_base() { + case "${REPO_URL%/}" in + https://github.com/*) + local path + path="${REPO_URL#https://github.com/}" + printf 'https://raw.githubusercontent.com/%s/%s\n' "${path%/}" "${REPO_BRANCH}" + ;; + *) + printf '%s/raw/branch/%s\n' "${REPO_URL%/}" "${REPO_BRANCH}" + ;; + esac +} + +RAW_BASE="${PYTORRENT_RAW_BASE:-$(default_raw_base)}" +ARCHIVE_URL="${PYTORRENT_ARCHIVE_URL:-$(default_archive_url)}" PROJECT_DIR="${WORK_DIR}/src" ARCHIVE_PATH="${WORK_DIR}/pytorrent.tar.gz" @@ -142,7 +166,7 @@ if ! download_file "${ARCHIVE_URL}" "${ARCHIVE_PATH}"; then install_rtorrent.py \ install_rtorrent_rhel.py \ configure_pytorrent_api.py \ - INSTALL_STACK.md + INSTALL.md do download_file "${RAW_BASE}/scripts/stack_installers/${file}" "${PROJECT_DIR}/scripts/stack_installers/${file}" done diff --git a/scripts/stack_installers/INSTALL.md b/scripts/stack_installers/INSTALL.md index 5226da6..639de7d 100644 --- a/scripts/stack_installers/INSTALL.md +++ b/scripts/stack_installers/INSTALL.md @@ -12,7 +12,7 @@ The installer is split into two layers: Run as root or through `sudo`: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh | sudo bash +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh | sudo bash ``` The bootstrap script downloads the current pyTorrent repository, detects the operating system family, and runs the matching installer: @@ -46,14 +46,14 @@ Environment variables must be passed to the `sudo bash` process. Example: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo PYTORRENT_PORT=8091 RTORRENT_SCGI_PORT=5001 bash ``` Another example with a custom profile name: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo PYTORRENT_PROFILE_NAME="Local rTorrent" PYTORRENT_PORT=8090 bash ``` @@ -63,7 +63,7 @@ These variables are used by `scripts/install_stack.sh`. | Variable | Default | Description | | --- | --- | --- | -| `PYTORRENT_REPO_URL` | `https://git.linuxiarz.pl/gru/pyTorrent` | Git repository base URL. | +| `PYTORRENT_REPO_URL` | `https://github.com/zdzichu6969/pyTorrent` | GitHub repository base URL. | | `PYTORRENT_REPO_BRANCH` | `master` | Branch used to download the repository archive. | | `PYTORRENT_ARCHIVE_URL` | derived from repo URL and branch | Custom repository archive URL. | | `PYTORRENT_BOOTSTRAP_DIR` | `/tmp/pytorrent-stack-installer` | Temporary directory used by the bootstrap script. | @@ -72,7 +72,7 @@ These variables are used by `scripts/install_stack.sh`. Example using a different branch: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo PYTORRENT_REPO_BRANCH=develop bash ``` @@ -96,14 +96,14 @@ These variables are used by both stack installers. Example: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo RTORRENT_USER=rtorrent RTORRENT_SCGI_PORT=5001 RTORRENT_TORRENT_PORT=51400 bash ``` Classic xmlrpc-c backend instead of default tinyxml2. On Arch this forces source build: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo RTORRENT_WITH_XMLRPC_C=1 bash ``` @@ -122,7 +122,7 @@ curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/inst Example with API token: ```bash -curl -fsSL https://git.linuxiarz.pl/gru/pyTorrent/raw/branch/master/scripts/install_stack.sh \ +curl -fsSL https://raw.githubusercontent.com/zdzichu6969/pyTorrent/master/scripts/install_stack.sh \ | sudo PYTORRENT_API_TOKEN="pt_xxx" bash ```