install scrpts

This commit is contained in:
Mateusz Gruszczyński
2026-05-31 08:44:22 +02:00
parent 6f2c266e7c
commit ce0edc2e39
10 changed files with 526 additions and 114 deletions
+27 -10
View File
@@ -30,6 +30,7 @@ RT_PROXY_USER="${RTORRENT_SCGI_PROXY_USER:-rtproxy}"
RT_PROXY_LISTEN="${RTORRENT_SCGI_PROXY_LISTEN:-127.0.0.1:5050}"
RT_PROXY_TOKEN="${RTORRENT_SCGI_PROXY_TOKEN:-}"
RT_PROXY_ALLOW_NET="${RTORRENT_SCGI_PROXY_ALLOW_NET:-127.0.0.1}"
RT_PROXY_TARGET_NETWORK_EXPLICIT="${RTORRENT_SCGI_PROXY_TARGET_NETWORK+x}"
RT_PROXY_TARGET_NETWORK="${RTORRENT_SCGI_PROXY_TARGET_NETWORK:-tcp}"
RT_PROXY_TARGET_ADDRESS="${RTORRENT_SCGI_PROXY_TARGET_ADDRESS:-127.0.0.1:5000}"
RT_PROXY_BINARY_URL="${RTORRENT_SCGI_PROXY_BINARY_URL:-https://git.linuxiarz.pl/gru/rtorrent-scgi-proxy/raw/branch/master/dist/rtorrent-scgi-proxy-linux-amd64}"
@@ -157,7 +158,7 @@ parse_args() {
--proxy-listen) RT_PROXY_LISTEN="$2"; shift 2 ;;
--proxy-token) RT_PROXY_TOKEN="$2"; shift 2 ;;
--proxy-allow-net) RT_PROXY_ALLOW_NET="$2"; shift 2 ;;
--proxy-target-network) RT_PROXY_TARGET_NETWORK="$2"; shift 2 ;;
--proxy-target-network) RT_PROXY_TARGET_NETWORK="$2"; RT_PROXY_TARGET_NETWORK_EXPLICIT=1; shift 2 ;;
--proxy-target-address) RT_PROXY_TARGET_ADDRESS="$2"; shift 2 ;;
--skip-profile) SKIP_PROFILE=1; shift ;;
-h|--help) usage; exit 0 ;;
@@ -174,6 +175,7 @@ detect_os_family() {
case "${ID:-} ${ID_LIKE:-}" in
*debian*|*ubuntu*) echo "debian" ;;
*rhel*|*fedora*|*centos*|*rocky*|*almalinux*) echo "rhel" ;;
*arch*) echo "arch" ;;
*) fail "Unsupported OS: ID=${ID:-unknown}, ID_LIKE=${ID_LIKE:-unknown}." ;;
esac
}
@@ -193,6 +195,10 @@ install_prerequisites() {
[[ -n "${manager}" ]] || fail "dnf or yum is required."
"${manager}" install -y ca-certificates curl git rsync sudo python3 python3-devel python3-pip gcc pkgconf-pkg-config
;;
arch)
command -v pacman >/dev/null 2>&1 || fail "pacman is required on Arch Linux."
pacman -Sy --noconfirm --needed ca-certificates curl git rsync sudo python python-pip gcc pkgconf
;;
esac
}
@@ -213,7 +219,22 @@ ask_configuration() {
INSTALL_SCGI_PROXY="$(normalize_yes_no "${INSTALL_SCGI_PROXY}")"
fi
if [[ "${INSTALL_SCGI_PROXY}" == "yes" ]]; then
prompt RT_PROXY_LISTEN "SCGI proxy listen address" "127.0.0.1:5050"
if [[ -n "${RTORRENT_SOCKET}" ]]; then
RT_PROXY_TARGET_NETWORK="unix"
RT_PROXY_TARGET_ADDRESS="${RTORRENT_SOCKET}"
elif [[ -z "${RT_PROXY_TARGET_NETWORK_EXPLICIT}" ]]; then
RT_PROXY_TARGET_NETWORK="unix"
fi
prompt RT_PROXY_TARGET_NETWORK "rTorrent SCGI backend: tcp or unix" "${RT_PROXY_TARGET_NETWORK}"
if [[ "${RT_PROXY_TARGET_NETWORK}" == "unix" ]]; then
prompt RT_PROXY_TARGET_ADDRESS "rTorrent Unix socket path" "${RTORRENT_SOCKET:-/run/rtorrent/rtorrent.sock}"
elif [[ "${RT_PROXY_TARGET_NETWORK}" == "tcp" ]]; then
prompt RT_PROXY_TARGET_ADDRESS "rTorrent SCGI TCP address" "${RT_PROXY_TARGET_ADDRESS}"
else
fail "Invalid SCGI proxy backend network: ${RT_PROXY_TARGET_NETWORK}"
fi
prompt RT_PROXY_ALLOW_NET "SCGI proxy allowed client network/IP/CIDR" "127.0.0.1"
prompt RT_PROXY_LISTEN "SCGI proxy TCP listen address for pyTorrent" "127.0.0.1:5050"
if [[ -z "${RT_PROXY_TOKEN}" ]]; then
RT_PROXY_TOKEN="$(python3 - <<'PY'
import secrets
@@ -221,16 +242,10 @@ print(secrets.token_urlsafe(32))
PY
)"
fi
prompt RT_PROXY_ALLOW_NET "SCGI proxy allowed client network/IP/CIDR" "127.0.0.1"
if [[ -n "${RTORRENT_SOCKET}" ]]; then
RT_PROXY_TARGET_NETWORK="unix"
RT_PROXY_TARGET_ADDRESS="${RTORRENT_SOCKET}"
fi
prompt RT_PROXY_TARGET_NETWORK "SCGI proxy backend network: tcp or unix" "${RT_PROXY_TARGET_NETWORK}"
prompt RT_PROXY_TARGET_ADDRESS "SCGI proxy backend address" "${RT_PROXY_TARGET_ADDRESS}"
SCGI_URL="scgi://${RT_PROXY_LISTEN}/proxy/${RT_PROXY_TOKEN}"
else
prompt SCGI_URL "rTorrent SCGI URL for pyTorrent profile" "${SCGI_URL}"
fi
prompt SCGI_URL "rTorrent SCGI URL for pyTorrent profile" "${SCGI_URL}"
if [[ "${AUTH_MODE}" == "ask" ]]; then
prompt AUTH_MODE "Enable pyTorrent authentication? yes/no" "no"
@@ -271,6 +286,7 @@ ensure_app_user() {
if ! id -u "${APP_USER}" >/dev/null 2>&1; then
local shell_path="/usr/sbin/nologin"
[[ -x "${shell_path}" ]] || shell_path="/sbin/nologin"
[[ -x "${shell_path}" ]] || shell_path="/usr/bin/nologin"
useradd --system --create-home --home-dir "/var/lib/${APP_USER}" --shell "${shell_path}" "${APP_USER}"
fi
}
@@ -521,6 +537,7 @@ install_scgi_proxy() {
if ! id -u "${RT_PROXY_USER}" >/dev/null 2>&1; then
local shell_path="/usr/sbin/nologin"
[[ -x "${shell_path}" ]] || shell_path="/sbin/nologin"
[[ -x "${shell_path}" ]] || shell_path="/usr/bin/nologin"
useradd --system --no-create-home --shell "${shell_path}" "${RT_PROXY_USER}"
fi
curl -fL "${RT_PROXY_BINARY_URL}" -o /usr/local/bin/rtorrent-scgi-proxy