115 lines
3.6 KiB
Bash
Executable File
115 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# One-command installer for rTorrent + pyTorrent on RHEL-compatible systems.
|
|
# Notes:
|
|
# - rTorrent is built as a minimal v0.16.11 install by default.
|
|
# - pyTorrent is configured through its HTTP API after the service starts.
|
|
|
|
if [[ "${EUID}" -ne 0 ]]; then
|
|
echo "Run as root: sudo $0" >&2
|
|
exit 1
|
|
fi
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
|
|
RTORRENT_USER="${RTORRENT_USER:-rtorrent}"
|
|
RTORRENT_HOME="${RTORRENT_HOME:-/home/${RTORRENT_USER}}"
|
|
RTORRENT_BASE_DIR="${RTORRENT_BASE_DIR:-/opt/rtorrent_build}"
|
|
RTORRENT_SCGI_PORT="${RTORRENT_SCGI_PORT:-5000}"
|
|
RTORRENT_TORRENT_PORT="${RTORRENT_TORRENT_PORT:-51300}"
|
|
RTORRENT_REF="${RTORRENT_REF:-v0.16.11}"
|
|
LIBTORRENT_REF="${LIBTORRENT_REF:-v0.16.11}"
|
|
PYTORRENT_APP_DIR="${PYTORRENT_APP_DIR:-/opt/pytorrent}"
|
|
PYTORRENT_PORT="${PYTORRENT_PORT:-8090}"
|
|
PYTORRENT_BASE_URL="${PYTORRENT_BASE_URL:-http://127.0.0.1:${PYTORRENT_PORT}}"
|
|
PYTORRENT_PROFILE_NAME="${PYTORRENT_PROFILE_NAME:-Local rTorrent}"
|
|
PYTORRENT_API_TOKEN="${PYTORRENT_API_TOKEN:-}"
|
|
PYTORRENT_SERVICE_NAME="${PYTORRENT_SERVICE_NAME:-pytorrent}"
|
|
PYTORRENT_RTORRENT_SCGI_URL="${PYTORRENT_RTORRENT_SCGI_URL:-scgi://127.0.0.1:${RTORRENT_SCGI_PORT}}"
|
|
|
|
export PYTORRENT_APP_DIR PYTORRENT_PORT PYTORRENT_SERVICE_NAME PYTORRENT_API_TOKEN
|
|
|
|
install_rhel_stack_prerequisites() {
|
|
local manager=""
|
|
if command -v dnf >/dev/null 2>&1; then
|
|
manager="dnf"
|
|
elif command -v yum >/dev/null 2>&1; then
|
|
manager="yum"
|
|
else
|
|
echo "dnf or yum is required on RHEL-compatible systems." >&2
|
|
exit 1
|
|
fi
|
|
|
|
"${manager}" install -y ca-certificates tar curl gzip sudo python3 dnf-plugins-core epel-release || \
|
|
"${manager}" install -y ca-certificates tar curl gzip sudo python3
|
|
|
|
if command -v crb >/dev/null 2>&1; then
|
|
crb enable || true
|
|
fi
|
|
"${manager}" config-manager --set-enabled crb || true
|
|
"${manager}" config-manager --set-enabled powertools || true
|
|
"${manager}" makecache || true
|
|
|
|
"${manager}" groupinstall -y "Development Tools" || true
|
|
"${manager}" install -y \
|
|
git \
|
|
gcc \
|
|
gcc-c++ \
|
|
make \
|
|
autoconf \
|
|
automake \
|
|
libtool \
|
|
pkgconf-pkg-config \
|
|
ncurses-devel \
|
|
openssl-devel \
|
|
expat-devel \
|
|
zlib-devel \
|
|
libcurl-devel \
|
|
redhat-rpm-config \
|
|
patch \
|
|
diffutils \
|
|
findutils \
|
|
file \
|
|
which \
|
|
libstdc++-devel
|
|
}
|
|
|
|
install_rhel_stack_prerequisites
|
|
|
|
RTORRENT_INSTALL_ARGS=(
|
|
--yes
|
|
--minimal
|
|
--force-config
|
|
)
|
|
if [[ "${PYTORRENT_DEBUG_INSTALL:-0}" == "1" ]]; then
|
|
RTORRENT_INSTALL_ARGS+=(--debug)
|
|
fi
|
|
|
|
python3 "${SCRIPT_DIR}/install_rtorrent_rhel.py" \
|
|
"${RTORRENT_INSTALL_ARGS[@]}" \
|
|
--base-dir "${RTORRENT_BASE_DIR}" \
|
|
--user "${RTORRENT_USER}" \
|
|
--group "${RTORRENT_USER}" \
|
|
--home "${RTORRENT_HOME}" \
|
|
--scgi-port "${RTORRENT_SCGI_PORT}" \
|
|
--torrent-port "${RTORRENT_TORRENT_PORT}" \
|
|
--rtorrent-ref "${RTORRENT_REF}" \
|
|
--libtorrent-ref "${LIBTORRENT_REF}"
|
|
|
|
cd "${PROJECT_DIR}"
|
|
bash "${SCRIPT_DIR}/install_pytorrent_rhel.sh"
|
|
|
|
CONFIGURE_ARGS=(
|
|
--base-url "${PYTORRENT_BASE_URL}"
|
|
--profile-name "${PYTORRENT_PROFILE_NAME}"
|
|
--scgi-url "${PYTORRENT_RTORRENT_SCGI_URL}"
|
|
)
|
|
if [[ -n "${PYTORRENT_API_TOKEN}" ]]; then
|
|
CONFIGURE_ARGS+=(--api-token "${PYTORRENT_API_TOKEN}")
|
|
fi
|
|
"${PYTORRENT_APP_DIR}/venv/bin/python" "${PYTORRENT_APP_DIR}/scripts/stack_installers/configure_pytorrent_api.py" "${CONFIGURE_ARGS[@]}"
|
|
|
|
echo "Done. pyTorrent: ${PYTORRENT_BASE_URL} | rTorrent SCGI: ${PYTORRENT_RTORRENT_SCGI_URL}"
|