ma torrent: add state, torrent.<hostname>.r

This commit is contained in:
makefu 2018-10-21 23:20:19 +02:00
parent 4a44570451
commit f2b532c7ea
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -3,12 +3,11 @@
with import <stockholm/lib>; with import <stockholm/lib>;
let let
daemon-user = "tor";
basicAuth = import <torrent-secrets/auth.nix>; basicAuth = import <torrent-secrets/auth.nix>;
peer-port = 51412; peer-port = 51412;
web-port = 8112; web-port = 8112;
daemon-port = 58846; daemon-port = 58846;
base-dir = config.makefu.dl-dir; base-dir = config.krebs.rtorrent.workDir;
in { in {
users.users = { users.users = {
@ -23,17 +22,6 @@ in {
}; };
}; };
# todo: race condition, do this after download user has been created
system.activationScripts."download-dir-chmod" = ''
for i in finished watch; do
if test ! -d $i;then
mkdir -p "${base-dir}/$i"
chown rtorrent:download "${base-dir}/$i"
chmod 775 "${base-dir}/$i"
fi
done
'';
users.extraGroups = { users.extraGroups = {
download = { download = {
gid = lib.mkDefault (genid "download"); gid = lib.mkDefault (genid "download");
@ -57,15 +45,17 @@ in {
rutorrent.enable = true; rutorrent.enable = true;
enableXMLRPC = true; enableXMLRPC = true;
listenPort = peer-port; listenPort = peer-port;
downloadDir = base-dir + "/finished"; downloadDir = config.makefu.dl-dir;
watchDir = base-dir + "/watch";
# dump old torrents into watch folder to have them re-added # dump old torrents into watch folder to have them re-added
}; };
services.nginx.virtualHosts."torrent.${config.krebs.build.host.name}.r".locations."/" = { proxyPass = "http://localhost:${toString web-port}/"; };
networking.firewall.extraCommands = '' networking.firewall.extraCommands = ''
iptables -A INPUT -i retiolum -p tcp --dport ${toString web-port} -j ACCEPT iptables -A INPUT -i retiolum -p tcp --dport ${toString web-port} -j ACCEPT
''; '';
networking.firewall.allowedTCPPorts = [ peer-port ]; networking.firewall.allowedTCPPorts = [ peer-port ];
networking.firewall.allowedUDPPorts = [ peer-port ]; networking.firewall.allowedUDPPorts = [ peer-port ];
state = [ config.krebs.rtorrent.sessionDir ]; # state which torrents were loaded
} }