Transmission & Clutch – a Torrent Server

I have an openSUSE 11 box at work that I use for testing, development, and file storage.  I resurrected an old RAID array that had a failed RAID controller by pulling out the controller and rewiring it to be just a SCSI chain.  It’s hooked up to the openSUSE box and configured as a 500GB software RAID5 array.

To set up the torrent server, you’ll need Transmission and Clutch.  Transmission is in the Packman repos, so you can enable that repo via YaST, search for Transmission, and install it.  Or of course, you could download the source and compile it.  If memory serves, I did that once and it compiled easily.
With clutch, it’s just a bunch of web files made to run on your favorite web server.  I use Apache, so make sure that’s installed and turned on.  You’ll also need PHP, JSON for PHP, and the PHP socket extension.  These are all in YaST too.  After they’re installed, restart the server so they’ll take affect.  Then unzip the files to the server root, in my case is /srv/www/htdocs/.  I use the web server to test several different things, so I put them in a subdirectory /srv/www/htdocs/clutch, and I can get to it by typing http://server/clutch in my browser.  The rest of the instructions are here under the Installation (Linux) section, and the do work fine assuming you follow them step by step.  I know because the first time I tried, I missed a step concerning permissions and had to backtrack to find it.
The important parts in the instructions above are the permissions and file locations.  A key to making this easier for you is knowing which user your web server runs as.  In my case it was wwwrun, and group www.  I edited the necessary files, and did a chown -R wwwrun:www to the top level directory.  Now my web server owns those files and can modify them as needed.

The last portion of this puzzle is to turn transmission into a service by creating this script in /etc/init.d:
[sourcecode language=“bash”]


# Copyright © 2007 JRM

# Starts or stops the transmission daemons.
# Writes directory permissions and changes owner for
# the transmission.socket. 

DESC=“torrent daemon”

case “$1” in
echo -n “Starting $DESC: ”
su – user -c “/usr/bin/transmission-daemon -s /opt/transmission/socket”
echo “$NAME.”
sleep 2
chmod -R 777 $SOCK
chown -R wwwrun:www $SOCK
sleep 2
transmission-remote -f $DLDIR
echo -n “Stopping $DESC: ”
killall transmission-daemon
echo “$NAME.”
echo “Usage: $N {start|stop}” >&2
exit 1
exit 0

I got that script from this page linked from the clutch directions above, but I modified it a little to fit my needs.  The main thing is who it runs as… “user” on the line [sourcecode language=“bash”]su – user -c ….[/sourcecode]  You’ll need to change that to a user on your system that you want the Torrent downloads to belong to. Other things you’ll need to change are SOCK and DLDIR.

Now that you have that set, you can do [sourcecode language=”bash”]sudo /sbin/service transmission start|stop[/sourcecode].  From there you should be able to go to the web page and add torrents, and watch them download!  If you want, you can set it to where the service will start on it’s own with each reboot:  [sourcecode language=”bash”]chkconfig transmission on[/sourcecode].
I’m not really happy with this write-up.  I should have spent more time on elaborating the finer points of permissions and installing the necessary apache/php modules as well as how to start up and configure apache.  I’ll try to go back and edit that later as time permits.  If you have any questions, please don’t hesitate to leave a comment.