initial commit
This commit is contained in:
commit
13eace9ce9
219 files changed
+6918
No files matched your search
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=rTorrent
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=rtorrent
|
||||
Group=rtorrent
|
||||
WorkingDirectory=/var/lib/rtorrent
|
||||
ExecStart=/usr/bin/rtorrent -n -o import=/etc/rtorrent/.rtorrent.rc
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
LimitNOFILE=65536
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
- name: restart rtorrent
|
||||
ansible.builtin.systemd_service:
|
||||
name: rtorrent
|
||||
state: restarted
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
|
||||
- name: restart apache
|
||||
ansible.builtin.systemd:
|
||||
name: apache2
|
||||
enabled: true
|
||||
state: reloaded
|
||||
|
||||
- name: restart php-fpm
|
||||
ansible.builtin.systemd:
|
||||
name: php{{ php_version.stdout }}-fpm
|
||||
enabled: true
|
||||
state: reloaded
|
||||
@@ -0,0 +1,359 @@
|
||||
---
|
||||
- name: install dependencies
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- git
|
||||
- apache2
|
||||
- php-fpm
|
||||
- php-curl
|
||||
- php-xml
|
||||
- php-mbstring
|
||||
- php-zip
|
||||
- python3
|
||||
- python3-cloudscraper
|
||||
- sox
|
||||
- mediainfo
|
||||
- ffmpeg
|
||||
- zip
|
||||
- unzip
|
||||
- unrar-free
|
||||
- curl
|
||||
- sudo
|
||||
state: present
|
||||
update_cache: yes
|
||||
notify:
|
||||
- restart apache
|
||||
- restart php-fpm
|
||||
|
||||
- name: get current php-fpm version
|
||||
ansible.builtin.shell: php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;'
|
||||
register: php_version
|
||||
changed_when: false
|
||||
|
||||
- name: get latest dumptorrent release info
|
||||
ansible.builtin.uri:
|
||||
url: https://api.github.com/repos/tomcdj71/dumptorrent/releases/latest
|
||||
return_content: yes
|
||||
register: dumptorrent_release
|
||||
run_once: true
|
||||
check_mode: false
|
||||
|
||||
- name: set current dumptorrent version
|
||||
ansible.builtin.set_fact:
|
||||
dumptorrent_version: "{{ dumptorrent_release.json.tag_name | regex_replace('^v', '') }}"
|
||||
dumptorrent_asset_url: "{{ dumptorrent_release.json.assets | selectattr('name', 'search', 'ubuntu-latest_amd64.deb') | map(attribute='browser_download_url') | first }}"
|
||||
|
||||
- name: check dumptorrent installed version
|
||||
ansible.builtin.shell: dumptorrent -V | grep -oP '\d+\.\d+\.\d+'
|
||||
register: dumptorrent_current_version
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: display dumptorrent version info
|
||||
ansible.builtin.debug:
|
||||
msg: "latest version: {{ dumptorrent_version }}, installed version: {{ dumptorrent_current_version.stdout | default('not installed', true) }}"
|
||||
|
||||
- name: download and install dumptorrent
|
||||
ansible.builtin.apt:
|
||||
deb: "{{ dumptorrent_asset_url }}"
|
||||
when: dumptorrent_version not in (dumptorrent_current_version.stdout | default(''))
|
||||
|
||||
- name: create media group
|
||||
ansible.builtin.group:
|
||||
name: media
|
||||
gid: 1000
|
||||
state: present
|
||||
|
||||
- name: create rtorrent group
|
||||
ansible.builtin.group:
|
||||
name: rtorrent
|
||||
system: true
|
||||
state: present
|
||||
|
||||
- name: create rtorrent user
|
||||
ansible.builtin.user:
|
||||
name: rtorrent
|
||||
group: rtorrent
|
||||
groups: media
|
||||
append: yes
|
||||
system: true
|
||||
shell: /usr/sbin/nologin
|
||||
home: /var/lib/rtorrent
|
||||
create_home: true
|
||||
state: present
|
||||
|
||||
- name: add www-data to rtorrent group
|
||||
ansible.builtin.user:
|
||||
name: www-data
|
||||
groups: rtorrent
|
||||
append: yes
|
||||
notify: restart apache
|
||||
|
||||
- name: ensure rtorrent data directory exists
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/rtorrent
|
||||
owner: rtorrent
|
||||
group: rtorrent
|
||||
state: directory
|
||||
mode: "0750"
|
||||
|
||||
- name: ensure rtorrent run directory exists
|
||||
ansible.builtin.file:
|
||||
path: /var/run/rtorrent
|
||||
owner: rtorrent
|
||||
group: rtorrent
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: ensure rtorrent log directory exists
|
||||
ansible.builtin.file:
|
||||
path: /var/log/rtorrent
|
||||
owner: rtorrent
|
||||
group: rtorrent
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: install rtorrent
|
||||
ansible.builtin.apt:
|
||||
name: rtorrent
|
||||
state: latest
|
||||
update_cache: true
|
||||
notify: restart rtorrent
|
||||
|
||||
- name: fetch wan ip
|
||||
ansible.builtin.shell: ssh -o StrictHostKeyChecking=no root@{{ hostvars['router'].ip }} "ip -4 addr show eth1 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'"
|
||||
delegate_to: localhost
|
||||
register: router_wan_ip
|
||||
changed_when: false
|
||||
vars:
|
||||
ansible_connection: local
|
||||
|
||||
- name: ensure rtorrent config directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/rtorrent
|
||||
owner: root
|
||||
group: root
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: deploy rtorrent config
|
||||
ansible.builtin.template:
|
||||
src: "{{ inventory_hostname }}/.rtorrent.rc.j2"
|
||||
dest: "/etc/rtorrent/.rtorrent.rc"
|
||||
owner: rtorrent
|
||||
group: rtorrent
|
||||
mode: "0640"
|
||||
vars:
|
||||
wan_ip: "{{ router_wan_ip.stdout }}"
|
||||
notify: restart rtorrent
|
||||
|
||||
- name: ensure rtorrent session directory is a mountpoint
|
||||
ansible.builtin.command: mountpoint -q /var/lib/rtorrent/session
|
||||
register: session_mountpoint
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: ensure rtorrent session source directory exists
|
||||
ansible.builtin.file:
|
||||
path: /mnt/rtorrent/session
|
||||
state: directory
|
||||
owner: rtorrent
|
||||
group: rtorrent
|
||||
mode: "0755"
|
||||
|
||||
- name: bind mount rtorrent session directory
|
||||
ansible.posix.mount:
|
||||
path: /var/lib/rtorrent/session
|
||||
src: /mnt/rtorrent/session
|
||||
fstype: none
|
||||
opts: bind
|
||||
state: mounted
|
||||
notify: restart rtorrent
|
||||
|
||||
- name: set rtorrent session directory ownership
|
||||
ansible.builtin.file:
|
||||
path: /mnt/rtorrent/session
|
||||
owner: rtorrent
|
||||
group: rtorrent
|
||||
recurse: true
|
||||
|
||||
- name: ensure ansible remote tmp dir exists
|
||||
ansible.builtin.file:
|
||||
path: /tmp/.ansible-www-data
|
||||
state: directory
|
||||
owner: www-data
|
||||
group: www-data
|
||||
mode: "0700"
|
||||
|
||||
- name: check current rutorrent git remote
|
||||
ansible.builtin.command: git -C /var/www/html remote get-url origin
|
||||
become: yes
|
||||
become_user: www-data
|
||||
register: current_remote
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
vars:
|
||||
ansible_remote_tmp: /tmp/.ansible-www-data
|
||||
|
||||
- name: get latest rutorrent release info
|
||||
ansible.builtin.uri:
|
||||
url: "https://api.github.com/repos/Novik/ruTorrent/releases/latest"
|
||||
return_content: yes
|
||||
register: rutorrent_release
|
||||
run_once: true
|
||||
check_mode: false
|
||||
|
||||
- name: set current rutorrent version
|
||||
ansible.builtin.set_fact:
|
||||
rutorrent_version: "{{ rutorrent_release.json.tag_name | regex_replace('^v', '') }}"
|
||||
|
||||
- name: check rutorrent installed version
|
||||
ansible.builtin.command: grep -oP 'version:\s*"\K[^"]+' /var/www/html/js/webui.js
|
||||
register: rutorrent_current_version
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: ensure html share directory is a mountpoint
|
||||
ansible.builtin.command: mountpoint -q /var/www/html/share
|
||||
register: share_mountpoint
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: unmount rutorrent share directory before update
|
||||
ansible.posix.mount:
|
||||
path: /var/www/html/share
|
||||
state: unmounted
|
||||
when:
|
||||
- share_mountpoint.rc == 0
|
||||
- rutorrent_version not in (rutorrent_current_version.stdout | default(''))
|
||||
|
||||
- name: remove irrelevant html directory
|
||||
ansible.builtin.file:
|
||||
path: /var/www/html
|
||||
state: absent
|
||||
when:
|
||||
- current_remote.rc is defined
|
||||
- current_remote.rc != 0
|
||||
- rutorrent_version not in (rutorrent_current_version.stdout | default(''))
|
||||
|
||||
- name: display rutorrent version info
|
||||
ansible.builtin.debug:
|
||||
msg: "latest version: {{ rutorrent_version }}, installed version: {{ rutorrent_current_version.stdout | default('not installed', true) }}"
|
||||
|
||||
- name: clone rutorrent
|
||||
ansible.builtin.git:
|
||||
repo: "https://github.com/Novik/ruTorrent.git"
|
||||
dest: "/var/www/html"
|
||||
version: "v{{ rutorrent_version }}"
|
||||
force: yes
|
||||
when: rutorrent_version not in (rutorrent_current_version.stdout | default(''))
|
||||
|
||||
- name: set rutorrent directory ownership
|
||||
ansible.builtin.file:
|
||||
path: /var/www/html
|
||||
owner: www-data
|
||||
group: www-data
|
||||
recurse: yes
|
||||
when: rutorrent_version not in (rutorrent_current_version.stdout | default(''))
|
||||
|
||||
- name: remove default share directory
|
||||
ansible.builtin.file:
|
||||
path: /var/www/html/share
|
||||
state: absent
|
||||
when: rutorrent_version not in (rutorrent_current_version.stdout | default(''))
|
||||
|
||||
- name: ensure rutorrent share source directory exists
|
||||
ansible.builtin.file:
|
||||
path: /mnt/rutorrent/share
|
||||
state: directory
|
||||
owner: www-data
|
||||
group: www-data
|
||||
mode: "0755"
|
||||
|
||||
- name: bind mount rutorrent share directory
|
||||
ansible.posix.mount:
|
||||
path: /var/www/html/share
|
||||
src: /mnt/rtorrent/share
|
||||
fstype: none
|
||||
opts: bind
|
||||
state: mounted
|
||||
notify: restart apache
|
||||
|
||||
- name: set rutorrent share subdirectories ownership
|
||||
ansible.builtin.file:
|
||||
path: "/mnt/rtorrent/share/{{ item }}"
|
||||
owner: www-data
|
||||
group: www-data
|
||||
recurse: true
|
||||
loop:
|
||||
- settings
|
||||
- torrents
|
||||
- users
|
||||
|
||||
- name: set rutorrent share tmp ownership
|
||||
ansible.builtin.file:
|
||||
path: /mnt/rtorrent/share/tmp
|
||||
owner: rtorrent
|
||||
group: rtorrent
|
||||
recurse: true
|
||||
|
||||
- name: deploy rutorrent config
|
||||
ansible.builtin.template:
|
||||
src: "{{ inventory_hostname }}/config.php.j2"
|
||||
dest: "/var/www/html/conf/config.php"
|
||||
owner: www-data
|
||||
group: www-data
|
||||
mode: "0644"
|
||||
notify: restart apache
|
||||
|
||||
- name: deploy rutorrent plugin config
|
||||
ansible.builtin.template:
|
||||
src: "{{ inventory_hostname }}/plugin.ini.j2"
|
||||
dest: "/var/www/html/conf/plugin.ini"
|
||||
owner: www-data
|
||||
group: www-data
|
||||
mode: "0644"
|
||||
notify: restart apache
|
||||
|
||||
- name: enable required apache modules
|
||||
community.general.apache2_module:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop:
|
||||
- proxy
|
||||
- proxy_fcgi
|
||||
- proxy_scgi
|
||||
- rewrite
|
||||
- setenvif
|
||||
- headers
|
||||
notify: restart apache
|
||||
|
||||
- name: deploy rutorrent apache vhost
|
||||
ansible.builtin.template:
|
||||
src: "{{ inventory_hostname }}/rutorrent.conf.j2"
|
||||
dest: "/etc/apache2/sites-available/rutorrent.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
notify: restart apache
|
||||
|
||||
- name: enable rutorrent site
|
||||
ansible.builtin.command: a2ensite rutorrent
|
||||
args:
|
||||
creates: /etc/apache2/sites-enabled/rutorrent.conf
|
||||
notify: restart apache
|
||||
|
||||
- name: disable default apache site
|
||||
ansible.builtin.command: a2dissite 000-default
|
||||
args:
|
||||
removes: /etc/apache2/sites-enabled/000-default.conf
|
||||
notify: restart apache
|
||||
|
||||
- name: deploy rtorrent service
|
||||
ansible.builtin.copy:
|
||||
src: rtorrent.service
|
||||
dest: /etc/systemd/system/rtorrent.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
notify: restart rtorrent
|
||||
@@ -0,0 +1,43 @@
|
||||
method.insert = cfg.basedir, private|const|string, (cat, "/var/lib/rtorrent/")
|
||||
method.insert = cfg.download, private|const|string, (cat, "/mnt/media1/downloads/")
|
||||
method.insert = cfg.session, private|const|string, (cat, (cfg.basedir), "session/")
|
||||
method.insert = cfg.logs, private|const|string, (cat, "/var/log/rtorrent/")
|
||||
method.insert = cfg.logfile, private|const|string, (cat, (cfg.logs), "rtorrent.log")
|
||||
execute.throw = sh, -c, (cat,\
|
||||
"mkdir -p \"", (cfg.session), "\" ",\
|
||||
"\"", (cfg.logs), "\" ")
|
||||
throttle.global_down.max_rate.set_kb = 8192
|
||||
throttle.global_up.max_rate.set_kb = 8192
|
||||
network.http.max_open.set = 50
|
||||
network.max_open_files.set = 600
|
||||
network.max_open_sockets.set = 300
|
||||
network.local_address.set = {{ wan_ip }}
|
||||
network.port_range.set = 6890-6899
|
||||
network.port_random.set = yes
|
||||
dht.mode.set = auto
|
||||
protocol.pex.set = yes
|
||||
protocol.encryption.set = allow_incoming,try_outgoing,enable_retry
|
||||
system.daemon.set = true
|
||||
#network.rpc.use_xmlrpc.set = true
|
||||
#network.xmlrpc.dialect.set = 1.1
|
||||
network.scgi.open_local = /run/rtorrent/rpc.sock
|
||||
execute.nothrow = chmod, 770, /run/rtorrent/rpc.sock
|
||||
encoding.add = UTF-8
|
||||
system.umask.set = 0002
|
||||
session.path.set = (cat, (cfg.session))
|
||||
directory.default.set = (cat, (cfg.download))
|
||||
system.cwd.set = (directory.default)
|
||||
schedule2 = w_apps, 10, 10, "load.start=/mnt/media1/.torrents/apps/*.torrent,d.directory.set=/mnt/media1/apps/,d.custom1.set=apps"
|
||||
schedule2 = w_games, 11, 10, "load.start=/mnt/media1/.torrents/games/*.torrent,d.directory.set=/mnt/media1/games/,d.custom1.set=games"
|
||||
schedule2 = w_movies, 12, 10, "load.start=/mnt/media1/.torrents/movies/*.torrent,d.directory.set=/mnt/media1/movies/,d.custom1.set=movies"
|
||||
schedule2 = w_music, 13, 10, "load.start=/mnt/media1/.torrents/music/*.torrent,d.directory.set=/mnt/media1/music/,d.custom1.set=music"
|
||||
schedule2 = w_shows, 14, 10, "load.start=/mnt/media1/.torrents/shows/*.torrent,d.directory.set=/mnt/media1/shows/,d.custom1.set=shows"
|
||||
schedule2 = w_ps1, 15, 10, "load.start=/mnt/media1/.torrents/ps1/*.torrent,d.directory.set=/mnt/media1/ps1/,d.custom1.set=ps1"
|
||||
schedule2 = w_ps2, 16, 10, "load.start=/mnt/media1/.torrents/ps2/*.torrent,d.directory.set=/mnt/media1/ps2/,d.custom1.set=ps2"
|
||||
schedule2 = w_ps3, 17, 10, "load.start=/mnt/media1/.torrents/ps3/*.torrent,d.directory.set=/mnt/media2/ps3/,d.custom1.set=ps3"
|
||||
schedule2 = w_psp, 18, 10, "load.start=/mnt/media1/.torrents/psp/*.torrent,d.directory.set=/mnt/media1/psp/,d.custom1.set=psp"
|
||||
schedule2 = w_ds, 19, 10, "load.start=/mnt/media1/.torrents/ds/*.torrent,d.directory.set=/mnt/media1/ds/,d.custom1.set=ds"
|
||||
log.open_file = "log", (cfg.logfile)
|
||||
log.add_output = "critical", "log"
|
||||
log.add_output = "error", "log"
|
||||
log.add_output = "warn", "log"
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
$httpUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36';
|
||||
$httpTimeOut = 30;
|
||||
$httpUseGzip = true;
|
||||
$httpIP = null;
|
||||
$httpProxy = array
|
||||
(
|
||||
'use' => false,
|
||||
'proto' => 'http',
|
||||
'host' => 'PROXY_HOST_HERE',
|
||||
'port' => 3128
|
||||
);
|
||||
$rpcTimeOut = 5;
|
||||
$rpcLogCalls = false;
|
||||
$rpcLogFaults = true;
|
||||
$phpUseGzip = false;
|
||||
$phpGzipLevel = 2;
|
||||
$schedule_rand = 10;
|
||||
$do_diagnostic = true;
|
||||
$al_diagnostic = true;
|
||||
$log_file = $_ENV['RU_LOG_FILE'] ?? '/tmp/errors.log';
|
||||
$saveUploadedTorrents = true;
|
||||
$overwriteUploadedTorrents = false;
|
||||
$topDirectory = $_ENV['RU_TOP_DIR'] ?? '/';
|
||||
$forbidUserSettings = false;
|
||||
$scgi_port = 0;
|
||||
$scgi_host = "unix:///run/rtorrent/rpc.sock";
|
||||
$XMLRPCMountPoint = "/RPC2";
|
||||
$throttleMaxSpeed = 327625*1024;
|
||||
$pathToExternals = array(
|
||||
"php" => '/bin/php',
|
||||
"curl" => '/bin/curl',
|
||||
"gzip" => '/bin/gzip',
|
||||
"id" => '/bin/id',
|
||||
"stat" => '/bin/stat',
|
||||
"python" => '/usr/bin/python3'
|
||||
);
|
||||
$localHostedMode = false;
|
||||
$cachedPluginLoading = false;
|
||||
$pluginMinification = true;
|
||||
$localhosts = array(
|
||||
"::1",
|
||||
"127.0.0.1",
|
||||
"localhost",
|
||||
);
|
||||
getenv("RU_LOCALHOSTS") && $localhosts[] = $_ENV['RU_LOCALHOSTS'];
|
||||
$profilePath = $_ENV['RU_PROFILE_PATH'] ?? '../../share';
|
||||
$profileMask = $_ENV['RU_PROFILE_MASK'] ?? 0777;
|
||||
$tempDirectory = '/var/www/html/share/tmp';
|
||||
$canUseXSendFile = false;
|
||||
$locale = "UTF8";
|
||||
$enableCSRFCheck = false;
|
||||
$enabledOrigins = array();
|
||||
$configLocalPath = dirname(__FILE__)."/config.local.php";
|
||||
if(is_file($configLocalPath) && is_readable($configLocalPath))
|
||||
require($configLocalPath);
|
||||
@@ -0,0 +1,13 @@
|
||||
[default]
|
||||
enabled = user-defined
|
||||
canChangeToolbar = yes
|
||||
canChangeMenu = yes
|
||||
canChangeOptions = yes
|
||||
canChangeTabs = yes
|
||||
canChangeColumns = yes
|
||||
canChangeStatusBar = yes
|
||||
canChangeCategory = yes
|
||||
canBeShutdowned = yes
|
||||
|
||||
[geoip]
|
||||
enabled = no
|
||||
@@ -0,0 +1,21 @@
|
||||
<VirtualHost *:80>
|
||||
ServerName {{ rutorrent_server_name | default(inventory_hostname) }}
|
||||
DocumentRoot /var/www/html
|
||||
|
||||
ErrorLog /var/log/apache2/rutorrent_error.log
|
||||
CustomLog /var/log/apache2/rutorrent_access.log combined
|
||||
|
||||
<Directory /var/www/html>
|
||||
Options -Indexes +FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
DirectoryIndex index.html
|
||||
</Directory>
|
||||
|
||||
<FilesMatch \.php$>
|
||||
SetHandler "proxy:unix:/run/php/php{{ php_version.stdout }}-fpm.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
|
||||
ProxyPass /RPC2 scgi://unix:/run/rtorrent/rpc.sock|
|
||||
ProxyPassReverse /RPC2 scgi://unix:/run/rtorrent/rpc.sock|
|
||||
</VirtualHost>
|
||||
Reference in new issue
Block a user