first attempt at nas rtorrent service
inspired by 7cf0d801d0
and also by https://www.krank.se/2014/06/25/rtorrent-magic-moving-finished-torrents-based-on-labels/
This commit is contained in:
parent
c5aa3bdcf4
commit
0eebe6f973
5 changed files with 63 additions and 17 deletions
|
|
@ -33,17 +33,5 @@
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# rtorrent = {
|
|
||||||
# enable = true;
|
|
||||||
# serviceConfig = {
|
|
||||||
# User = "flood";
|
|
||||||
# Type = "forking";
|
|
||||||
# ExecStart = "${pkgs.rtorrent}/bin/rtorrent";
|
|
||||||
# Restart = "on-failure";
|
|
||||||
# };
|
|
||||||
# wantedBy = [ "multi-user.target" ];
|
|
||||||
# after = [ "network.target" ];
|
|
||||||
# };
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
nix/home/programs/rtorrent/default.nix
Normal file
16
nix/home/programs/rtorrent/default.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{ pkgs, finalDir, downloadDir, watchDir }:
|
||||||
|
{
|
||||||
|
|
||||||
|
services.rtorrent = {
|
||||||
|
enable = true;
|
||||||
|
downloadDir = downloadDir;
|
||||||
|
group = "users";
|
||||||
|
configText =
|
||||||
|
builtins.readFile (pkgs.substituteAll {
|
||||||
|
src = ./rtorrent.rc;
|
||||||
|
watchDir = watchDir;
|
||||||
|
finalDir = finalDir;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
41
nix/home/programs/rtorrent/rtorrent.rc
Normal file
41
nix/home/programs/rtorrent/rtorrent.rc
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Enable the default ratio group.
|
||||||
|
ratio.enable=
|
||||||
|
|
||||||
|
# Change the limits, the defaults should be sufficient.
|
||||||
|
ratio.min.set = 100
|
||||||
|
ratio.max.set = 300
|
||||||
|
ratio.upload.set = 20M
|
||||||
|
|
||||||
|
# Changing the command triggered when the ratio is reached.
|
||||||
|
# (the default is "d.try_close= ; d.ignore_commands.set=1")
|
||||||
|
method.set = group.seeding.ratio.command, "d.close= ; d.erase="
|
||||||
|
|
||||||
|
# Add new method to get finished dir (called get_finished_dir)
|
||||||
|
method.insert = d.get_finished_dir,simple,"cat=@finalDir@/,$d.custom1="
|
||||||
|
|
||||||
|
# Bind event "torrent has finished" to action "move to new directory based on label"
|
||||||
|
# method.set_key = event.download.finished,move_complete
|
||||||
|
# Modifies the event.download.finished event to also have a new “key”
|
||||||
|
# called “move_complete”. From what I understand, rTorrent executes all
|
||||||
|
# “keys” in an event whenever that event is fired. The
|
||||||
|
# event.download.finished event fires whenever a torrent has finished
|
||||||
|
# downloading. The stuff within the quotation marks is the new key’s
|
||||||
|
# commands. Each command is separated by a semicolon (;).
|
||||||
|
# d.directory.set=$d.get_finished_dir=;
|
||||||
|
# d.directory.set sets the directory of the torrent in rTorrent’s own
|
||||||
|
# information. It does not move the torrent, just means rTorrent will
|
||||||
|
# look in that directory from now on. $d.get_finished_dir just runs the
|
||||||
|
# get_finished_dir method preciously inserted; constructing a path name
|
||||||
|
# by combining [folder]/finished/ with whatever label was applied
|
||||||
|
# ($d.custom1 contains the label).
|
||||||
|
# execute=mkdir,-p,$d.get_finished_dir=;
|
||||||
|
# Gets the same path name and makes sure the directory actually exists.
|
||||||
|
# Mkdir is the standard *nix command for creating directories. -p means
|
||||||
|
# creating parent directories if needed and not complaining if directory
|
||||||
|
# already exists.
|
||||||
|
# execute=mv,-u,$d.base_path=,$d.get_finished_dir=
|
||||||
|
# Uses the same “execute” functionality as above to run the standard *nix
|
||||||
|
# mv command to move the torrent’s files (whose location is stored in
|
||||||
|
# d.base_path) to, once again, the directory whose name was constructed
|
||||||
|
# by the get_finished_dir method.
|
||||||
|
method.set_key = event.download.finished,move_complete,"d.directory.set=$d.get_finished_dir=;execute=mkdir,-p,$d.get_finished_dir=;execute=mv,-u,$d.base_path=,$d.get_finished_dir="
|
||||||
|
|
@ -26,11 +26,6 @@
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/storage" = {
|
|
||||||
device = "192.168.1.168:/storage";
|
|
||||||
fsType = "nfs";
|
|
||||||
};
|
|
||||||
|
|
||||||
swapDevices =
|
swapDevices =
|
||||||
[{ device = "/dev/disk/by-uuid/97c769a2-55da-475a-8dc0-d74d8bbde514"; }];
|
[{ device = "/dev/disk/by-uuid/97c769a2-55da-475a-8dc0-d74d8bbde514"; }];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,12 @@
|
||||||
# Include the results of the hardware scan.
|
# Include the results of the hardware scan.
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
../common/users.nix
|
../common/users.nix
|
||||||
|
(import ../../home/programs/rtorrent {
|
||||||
|
pkgs = pkgs;
|
||||||
|
downloadDir = "/storage/temp";
|
||||||
|
finalDir = "/storage";
|
||||||
|
watchDir = "/storage/torrents";
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
# Bootloader.
|
# Bootloader.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue