Setting up a headless torrent daemon in FreeBSD
I have FreeBSD running as a home server for a while now. One of the things I wanted the server to take care of is downloading torrents, so I could shut down my PC whenever I am downloading stuff.
With transmission-daemon (net-p2p/transmission-daemon from ports) this is really simple.
To install:
#!shell
cd /usr/ports/net-p2p/transmission-daemon && make install clean
To fire up:
#!shell
/usr/local/etc/rc.d/transmission onestart
or add transmission_enable=YES
to your /etc/rc.conf and run /usr/local/etc/rc.d/transmission start
There's a few gotcha's, though:
The settings file transmission uses lives in /usr/local/etc/transmission/home/settings.json
. This file is overwritten by transmission on startup, so that isn't the place to put your custom configurations. After doing a bit of reading of the rc script (/usr/local/etc/rc.d/transmission
), I found out that the easiest way to configure transmission-daemon for your needs is editing your /etc/rc.conf and adding a transmission_flags var. This var is passed as parameters to transmission-daemon, so check out transmission-daemon --help
for available options.
My transmission rc config looks like this (in /etc/rc.conf
):
#!shell
transmission_enable=YES
transmission_flags="-a 192.168.178.*,127.0.0.* --incomplete-dir /var/spool/transmission -w /srv/files/download -e /var/log/transmission.log" --paused
-a
makes sure both the web client (available at port 9091 when transmission-daemon is running) and the transmission-remote cli tool are accessible by the specified addresses--incomplete-dir
is used to store incomplete downloads while downloading.-w
is the "work" dir, where files are stored when completed, and while downloading if--incomplete-dir
isn't running-e
tells transmission to log messages and warnings to /var/log/transmission, especially useful while configuring transmission or you're encountering errors--paused
makes sure the daemon is started, but all torrents are paused. You need to start the torrents manually by using either the web interface (running at port 9091 by default) or using the transmission-remote command line utility
I have created the necessary files and folders with the transmission user and group as the owner. As root:
#!shell
install -d {/var/spool/transmission,/srv/files/download} -g transmission -u transmission -m 644
touch /var/log/transmission.log && chown transmission:transmission /var/log/transmission.log
As always, you need to restart the daemon after changing settings, so call /usr/local/etc/rc.d/transmission restart
after doing your modifications to /etc/rc.conf.
Of course you need to make sure the drives the directories live in have enough space left, or you might run into some weird results.
Happy torrenting :)