Seedbox

With rtorrent

rtorrent is a light and efficient torrent client.

It's text-based interface is nice if you don't want to bother with a webapp and remote control your seedbox with SSH.

# pkg_add rtorrent

Add a dedicated user _rtorrent for privileges separation.

Now log in as _rtorrent :

# su _rtorrent

Create required directories :

$ mkdir -p seedbox/{download,session,torrents}

Now create ~/.rtorrent.rc from the example :

$ cp /usr/local/share/examples/rtorrent/rtorrent.rc ~/.rtorrent.rc

Edit that file.

# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 0
upload_rate = 20
directory = ~/seedbox/download 
session = ~/seedbox/session
# When a torrent file is copied in torrents dir, it's added to rtorrent
schedule = watch_directory,5,5,load_start=~/seedbox/torrents/*.torrent
schedule = untied_directory,5,5,stop_untied=~/seedbox/torrents/*.torrent
check_hash = yes
use_udp_trackers = yes
encryption = allow_incoming,try_outgoing,enable_retry
dht = auto
peer_exchange = yes
# Run script to get alerts when download finish
system.method.set_key = event.download.finished,notify_me,"execute=~/.rtorrent_mail.sh,$d.get_name="
# add dht node so magnets works fine
schedule2 = dht_node_1, 5, 0, "dht.add_node=router.utorrent.com:6881"
schedule2 = dht_node_2, 5, 0, "dht.add_node=dht.transmissionbt.com:6881"
schedule2 = dht_node_3, 5, 0, "dht.add_node=router.bitcomet.com:6881"
schedule2 = dht_node_4, 5, 0, "dht.add_node=dht.aelitis.com:6881"

Fill the script "~/.rtorrent_mail.sh" to get alerts when a download is complete.

#!/bin/sh
echo "$(date) : $1 - Download completed." | mail -s "[rtorrent] - Download completed : $1" root

To add a new torrent file, you may use scp :

$ scp *.torrent _rtorrent@chezmoi.tld:/home/_rtorrent/seedbox/torrents/

To have rtorrent automatically started at boot, edit _rtorrent user's crontab and add :

@reboot /usr/bin/tmux new -s rtorrent -d /usr/local/bin/rtorrent

We use tmux to put rtorrent in the background.

If you need to display rtorrent, log in as _rtorrent with ssh and run "tmux a -t rtorrent". Press ctrl-b then "d" to detach.

To add a magnet link, press "backspace" and copy the link.

When in doubt :

$ rtorrent -h

Transmission

Transmission works very well and offer a web interface.

# pkg_add transmission

We start and stop daemon so we can create then edit configuration file.

# rcctl enable transmission_daemon
# rcctl start transmission_daemon
# rcctl stop transmission_daemon

Creates directories to download files and store .torrent.

# mkdir -p /var/transmission/{downloads,incomplete,torrents}
# chown -R _transmission:_transmission /var/transmission

If others can see the above directories :

# chmod a+rX /var/transmission

Now edit this file to configure transmission :

/var/transmission/.config/transmission-daemon/settings.json

You may set :

"download-dir": "/var/transmission/downloads",
"incomplete-dir": "/var/transmission/incomplete",
"incomplete-dir-enabled": true,
"peer-port-random-on-start": true,

I suggest to add the following lines to automatically start downloading torents you copied (with SFTP as example) in /var/transmission/torrents.

"watch-dir": "/var/transmission/torrents",
"watch-dir-enabled": true

To get an alert when a download is complete :

"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/var/transmission/dl-done.sh",

"dl-done.sh" script looks like this :

#!/bin/sh
echo "$(date) : $TR_TORRENT_NAME - Download completed." | mail -s "[transmission] - Download completed : $TR_TORRENT_NAME" toto@example.com

Remepler it must be executable :

# chmod +x /var/transmission/dl-done.sh

When you're done configuring, restart transmission :

# rcctl start transmission_daemon

The easiest to display the web interface is to use an SSH tunnel. From your computer, dig a tunnel to the server :

ssh -N -L 9999:127.0.0.1:9091 batman@athome.tld

Now open a browser at http://localhost:9999.