frumar: add torrent config

master
Yorick van Pelt 2023-08-04 10:39:22 +02:00
parent 13344f0ecc
commit 10cc75e067
Signed by: yorick
GPG Key ID: D8D3CC6D951384DE
4 changed files with 106 additions and 1 deletions

View File

@ -4,6 +4,7 @@
../../roles/server.nix
../../roles/homeserver.nix
./paperless.nix
./torrent.nix
];
system.stateVersion = "15.09";

View File

@ -54,7 +54,7 @@
fsType = "zfs";
};
fileSystems."/home/yorick/rtorrent" = {
fileSystems."/torrent" = {
device = "ssdpool/torrent";
fsType = "zfs";
};

View File

@ -0,0 +1,91 @@
#############################################################################
# A minimal rTorrent configuration that provides the basic features
# you want to have in addition to the built-in defaults.
#
# See https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template
# for an up-to-date version.
#############################################################################
# Instance layout (base paths)
method.insert = cfg.basedir, private|const|string, "/torrent/"
method.insert = cfg.download, private|const|string, (cat,(cfg.basedir),"work/")
method.insert = cfg.logs, private|const|string, (cat,(cfg.basedir),"log/")
method.insert = cfg.logfile, private|const|string, (cat,(cfg.logs),"rtorrent-",(system.time),".log")
method.insert = cfg.session, private|const|string, (cat,(cfg.basedir),"session/")
# method.insert = cfg.watch, private|const|string, (cat,(cfg.basedir),"watch/")
# Create instance directories
execute.throw = sh, -c, (cat,\
"mkdir -p \"",(cfg.download),"\" ",\
"\"",(cfg.logs),"\" ",\
"\"",(cfg.session),"\" ")
# Listening port for incoming peer traffic (fixed; you can also randomize it)
network.port_range.set = 58572-58572
network.port_random.set = no
# Tracker-less torrent and UDP tracker support
# (conservative settings for 'private' trackers, change for 'public')
dht.mode.set = auto
protocol.pex.set = yes
trackers.use_udp.set = yes
# Peer settings
throttle.max_uploads.set = 100
throttle.max_uploads.global.set = 250
throttle.min_peers.normal.set = 20
throttle.max_peers.normal.set = 60
throttle.min_peers.seed.set = 30
throttle.max_peers.seed.set = 80
trackers.numwant.set = 80
protocol.encryption.set = allow_incoming,try_outgoing,enable_retry
# Limits for file handle resources, this is optimized for
# an `ulimit` of 1024 (a common default). You MUST leave
# a ceiling of handles reserved for rTorrent's internal needs!
network.http.max_open.set = 50
network.max_open_files.set = 600
network.max_open_sockets.set = 300
# Memory resource usage (increase if you have a large number of items loaded,
# and/or the available resources to spend)
pieces.memory.max.set = 3600M
network.xmlrpc.size_limit.set = 4M
# Basic operational settings (no need to change these)
session.path.set = (cat, (cfg.session))
directory.default.set = (cat, (cfg.download))
log.execute = (cat, (cfg.logs), "execute.log")
##log.xmlrpc = (cat, (cfg.logs), "xmlrpc.log")
execute.nothrow = sh, -c, (cat, "echo >",\
(session.path), "rtorrent.pid", " ", (system.pid))
# Other operational settings (check & adapt)
encoding.add = utf8
system.umask.set = 0007
system.cwd.set = (directory.default)
network.http.dns_cache_timeout.set = 25
schedule2 = monitor_diskspace, 15, 60, ((close_low_diskspace, 1000M))
dht.port.set = 10523
system.file.allocate.set = yes
# Run the rTorrent process as a daemon in the background
# (and control via XMLRPC sockets)
#system.daemon.set = true
network.scgi.open_local = (cat,(session.path),".rtorrent.sock")
execute.nothrow = chmod,770,(cat,(session.path),".rtorrent.sock")
# Logging:
# Levels = critical error warn notice info debug
# Groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_*
print = (cat, "Logging to ", (cfg.logfile))
log.open_file = "log", (cfg.logfile)
log.add_output = "info", "log"
method.insert = get_public_ip_address, simple|private, "execute.capture=curl,-f,ifconfig.me/ip"
# The IP address reported to the tracker. (ip) This handles dynamic IP's as well.
schedule2 = ip_tick, 0, 1800, "network.local_address.set=(get_public_ip_address)"

View File

@ -0,0 +1,13 @@
{ config, pkgs, lib, ... }: {
users.users.torrent = {
isSystemUser = true;
createHome = false;
group = "torrent";
home = "/torrent";
};
users.groups.torrent = {};
systemd.tmpfiles.rules = [
"d /torrent 770 torrent torrent"
];
users.users.yorick.extraGroups = [ "torrent" ];
}