Moving and script executing don't work?
NoLooseEnds opened this issue · 8 comments
Hi, I'm finally going over to a standalone rtorrent container (with flood in another separate container), and it seems to work fine except for two issues (that could be related).
1. My move on complete does not work anymore?
Relevant config:
method.insert = cfg.watch, private|const|string, (cat,"/downloads/watch/")
# watch subdirectory
schedule2 = audiobooks,1,5,(cat,"load.start=",(cfg.watch),"/audiobooks/*.torrent,d.directory.set=/downloads/incomplete/,d.custom1.set=audiobooks,d.custom2.set=/downloads/completed/audiobooks/")
# Move finished
method.insert = d.move_to_complete, simple, "d.directory.set=$argument.1=; execute=mkdir,-p,$argument.1=; execute=mv,-u,$argument.0=,$argument.1=; d.save_full_session="
method.set_key = event.download.finished,move_complete,"d.move_to_complete=$d.data_path=,$d.custom2="
2. Executing notification script no longer works
Relevant config:
# slacktee – https://github.com/course-hero/slacktee
method.set_key = event.download.finished,notify_me,"execute=/config/rt-notify.sh,$d.name="
Any input on this? Is the rtorrent image too limiting?
Appreciate your awesome work!
The jesec/rtorrent
container is distroless (no shell, no coreutils, no package manager, etc.) to ensure best security.
Thanks for the info. I appreciate the lightweight image.
How would you go about moving files? How is your personal setup? :)
I never move files. I keep them as-is so the structure of torrent is preserved (and I can continue seeding when needed). I use hardlinks to organize them if necessary.
@jesec Is all script execution prevented in this distribution? I can't get anything working, even logging through script execution and I can't figure out if it's stripped off, or if I am going at it completely wrong.
My bad, I had some issues in the script that preveted anything else from running (d.get_custom1 instead of d.custom1)
For anyone coming up on this, I ended up using a custom docker file, however, before doing so, you should read up on the Security precautions to understand the risks introduced by using a different base image.
This is for convinience, the security could be further harnened by stripping the busybox image off binaries that are not needed (shell for starters)
FROM jesec/rtorrent:0.9.8-r15 as base
FROM busybox
ENV HOME=/home/download
USER 1001:1001
COPY --from=base / /
ENTRYPOINT ["rtorrent"]
Ended up using the following script for moving completed torrents:
# Define function to retrieve path to the target directory where downloads will be moved upon completion
method.insert = d.get_finished_dir, simple, "if=(d.custom1), (cat,/downloads/completed/,(d.custom1)), /downloads/completed/unsorted/"
# Define function to retrieve full path of the downloaded files
method.insert = d.get_full_data_path, simple, "if=(d.is_multi_file), (d.directory), (cat, (d.directory),/,(d.name))"
# Define function to move files to the target dir
method.insert = d.move_to_completed, simple, "d.directory.set=$argument.1=; execute=mkdir,-p,$argument.1=; execute=mv,-n,$argument.0=,$argument.1=); d.save_full_session="
# Define event hook to run the function upon download
method.set_key = event.download.finished,move_complete,"d.move_to_completed=$d.get_full_data_path=,$d.get_finished_dir="
@Sharsie Thanks. I'll give this a go. Do you mind sharing your watch folder setup from .rtorrent.rc as well? I'm having a hard time getting it to work – afaik the config is correct.
@NoLooseEnds I am not using the watch schedules myself, but a quick test of the following was working fine for me. Not a big fan of functional programming, but I think you might have an invalid chaining of the commands with the cat
keyword. Try adjusting the following to your needs. I am not using your second var custom2 from your snippet here, because that would require modifying get_finished_dir
function from the previous snippet, which only uses custom1 to set final directory.
schedule2 = audiobooks,1,5,((load.start,(cat,"/config/audiobooks/","*torrent"), "d.directory.set=/downloads/incomplete", "d.custom1.set=audiobooks"))
Note that it's on a cron-like schedule, it won't start immediately when testing it (I forgot:)
I also hardcoded the paths to make sure I don't have some configuration mishaps elsewhere.
Also this is out of scope of this issue, if you wish to discuss this further, we should probably do so in jesec/flood#120 or elsewhere wherever the rtorrent config is discussed :)
@Sharsie I'm looking at this again. Do you mind showing your config files and how you organize your setup? :)