User:Mwberry/rtorrent-systemd

From ArchWiki
Jump to navigation Jump to search

Description

The purpose of this package is to provide systemd service units and a controller script that will invoke one or more instances of rtorrent when the system starts and cleanly kill them when the system shuts down. This is particularly useful for so-called 'seedboxes' (headless servers whose dedicated purpose is seeding torrents). Since rtorrent is an interactive (ncurses) application, instances are run under screen. tmux support is also planned for the future.

Installation

Simply install from the AUR by cloning and running makepkg

git clone ssh+git://aur@aur.archlinux.org/rtorrent-systemd.git
cd rtorrent-systemd
makepkg -sri

Configuration

rtorrent's main configuration file is, by default, ~/.rtorrent.rc. Since the goal of this package is to enable multiple instances of rtorrent, that file is not used. Instead, you must create an rtorrent.rc for each instance you want to run under /etc/rtorrent.d/. If you want, these rtorrent.rc files can import ~/.rtorrent.rc for common configuration. Any rtorrent specific configuration lives in these files. Additional configuration for systemd is located in correspondingly named .config files in the same directory. This configuration includes such information as the user that rtorrent should run as and the working directory to use.

ls /etc/rtorrent.d
-rw-r--r-- 1 root root  54 Nov 22 20:01 trackerA.config
-rw-r--r-- 1 root root  97 Nov 22 19:59 trackerA.rtorrent.rc
-rw-r--r-- 1 root root  61 Nov 22 20:36 trackerB.config
-rw-r--r-- 1 root root 111 Nov 22 20:36 trackerB.rtorrent.rc

sudo systemctl enable rtorrent@trackerA.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rtorrent@trackerA.service to /usr/lib/systemd/system/rtorrent@.service.

sudo systemctl enable rtorrent@trackerB.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rtorrent@trackerB.service to /usr/lib/systemd/system/rtorrent@.service.

ls /etc/systemd/system/multi-user.target.wants | grep rtorrent
rtorrent@trackerA.service
rtorrent@trackerB.service


cat /etc/rtorrent.d/trackerA.rtorrent.rc 
session=/torrents/trackerA/sess
encryption=require
directory=/torrents/trackerA/done

cat /etc/rtorrent.d/trackerB.rtorrent.rc 
session=/torrents/trackerB/sess
encryption=require
directory=/torrents/trackerB/done

cat /etc/rtorrent.d/trackerA.config 
CONFIG+=([user]="me")
CONFIG+=([dir]="/torrents/trackerA")

cat /etc/rtorrent.d/trackerB.config 
CONFIG+=([user]="me")
CONFIG+=([dir]="/torrents/trackerB")

Configuration Directives

The .config file is a bash snippet that populates a globally defined associate array called "CONFIG".

Directive Type Purpose
user username The user that rtorrent (and screen) will be run under
dir absolute path The working directory to give to rtorrent

Future Plans & Contributing

Improvements planned but not yet implemented

  • Input Validation
  • Tests
  • More documentation
  • tmux support
  • Ability to reuse screen session for multiple rtorrent instances
  • Ability for rtorrentctl to generate skeleton rtorrent.rc and .config files

Pull requests accepted. Leave a comment on the AUR package page with the clone URL.