Installing Transmission with Clutch WebUI

Transmission is a fast, easy, and free multi-platform BitTorrent client with a focus on being lightweight yet feature-packed.

Clutch web page: http://clutchbt.com/
Transmission web page: http://transmission.m0k.org
PHP web site: http://nl2.php.net/
Apache 2 and PHP 5: http://dan.drydog.com/apache2php.html

Contents

  1. Install PHP
    1. Build Libxml
    2. Build PHP
    3. Configure Lighttpd
    4. Testing
  2. Install OpenSSL
    1. Build OpenSSL
  3. Install Pkg-Config
    1. Build Pkg-Config
  4. Install Transmission
    1. Build Transmission
    2. Install Clutch
    3. Configure Clutch and Transmission
      1. Socket Settings
      2. Auto Start/Stop
      3. Auto Startup/Shutdown
      4. Password Protected Web Interface

1. Install PHP

1.1. Build libxml

Libxml is required by PHP so is needed.

Find your latest version: http://ftp.gnome.org.

# cd /tmp/myfiles/
# wget http://ftp.gnome.org/pub/gnome/sources/libxml2/2.6/libxml2-2.6.27.tar.gz
# tar xfz libxml2-2.6.27.tar.gz
# cd libxml2-2.6.27
# ./configure
# make
# make install

PHP needs a copy of libxml2 in the /lib/ directory.

# cp /usr/local/lib/libxml2.so.2 /lib

1.2. Build PHP

Find your latest version: http://be2.php.net.

# cd /tmp/myfiles/
# wget http://uk.php.net/distributions/php-5.2.5.tar.gz
# tar xvfz php-5.2.5.tar.gz
# cd php-5.2.5
# ./configure —without-iconv —without-pear —enable-fastcgi —enable-discard-path —enable-force-cgi-redirect —without-mysql —enable-sockets
# make 
# make install

You can also do a make test to run an extensive test on PHP...

1.3. Configure Lighttpd

You can read a tutorial here: http://trac.lighttpd.net/trac/wiki/TutorialLighttpdAndPHP

You need to edit lighttpd's config file as follows:

# cd /etc/lighttpd

Make a backup in case you mess up.

# cp lighttpd.conf lighttpd.conf.backup

Edit lighttpd.conf and replace this:

 “nasMaster.pl” => (( “socket” => “/tmp/lighttpd.fcgi.socket”, 
                      “check-local” => “disable”,
 ))
 )

with this:

 “nasMaster.pl” => (( “socket” => “/tmp/lighttpd.fcgi.socket”, 
                      “check-local” => “disable”,
 )),
 “.php” => ((  “bin-path” => “/usr/local/bin/php-cgi”, 
              “socket” => “/tmp/php.socket”,
 ))
 )

Change the line that reads:

index-file.names = ( "nasMaster.pl" )

with this:

index-file.names = ( "nasMaster.pl", "index.html", "index.php" )

After you make these changes, you need to restart lighttpd:

# /etc/init.d/lighttpd.sh restart

1.4. Testing

Now to test PHP with a simple webpage.

# cd /usr/www/lib
# mkdir test
# cd test
# vi index.php

Enter this line below into index.php.

<?php phpinfo(); ?>

Browse to http://<MyBook-IP>/test/index.php You should see all the information about the PHP installation.

2. Install OpenSSL

This package is required and so must be installed.

2.1. Build OpenSSL

Find your latest version: http://www.openssl.org.

# cd /tmp/myfiles/
# wget http://www.openssl.org/source/openssl-0.9.8g.tar.gz
# tar -xvf openssl-0.9.8g.tar.gz
# cd openssl-0.9.8g/
# ./configure
# make
# make install

3. Install Pkg-Config

This package is required and so must be installed.

3.1. Build Pkg-Config

Find your latest version: http://pkgconfig.freedesktop.org.

# cd /tmp/myfiles/
# wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.22.tar.gz
# tar -xvf pkg-config-0.22.tar.gz
# cd pkg-config-0.22/
# ./configure
# make
# make install

4. Installing Transmission

First of all, you MUST set the following path:

export PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig/

4.1. Install Transmission Daemon

4.1.1. Install Transmission Daemon from source

Find your latest version: http://download.m0k.org/transmission/

# wget http://download.m0k.org/transmission/files/transmission-1.01.tar.bz2
# tar jxvf transmission-1.01.tar.bz2
# cd transmission-1.01

Now configure and install.

# ./configure --disable-gtk
# make
# make install

4.1.2. Install Transmission Daemon from SVN repositor

Building Transmission from SVN (First Time):

# svn co svn://svn.m0k.org/Transmission/trunk Transmission
# cd Transmission
# ./autogen.sh
# ./configure --disable-gtk
# make
# make install

Building Transmission from SVN (Updating):

# cd Transmission
# svn up
# make
# make install

4.2. Install Clutch

Download and install the Web Interface for Transmission.

# cd /usr/www/lib/
# wget http://clutchbt.com/Files/Clutch-0.2.tar.gz
# tar -xvf Clutch-0.2.tar.gz
# mv Clutch-0.2 Clutch
# chmod -R 777 Clutch/
# rm Clutch-0.1.tar.gz

4.3. Configuring Clutch and Transmission

Put a soft-link to the /usr/www/lib/ path:

# ln -s /shares/internal/PUBLIC/http-server/Clutch/ /usr/www/lib/

4.3.1. Socket Settings

Now edit the socket path, and point it to your server root dir ...

# cd Clutch
# nano remote/data/socket.txt

Point it to your server root dir ...

/root/.transmission/daemon/socket

Save and close socket.txt.

You start transmission with "transmission-daemon -s /root/.transmission/daemon/socket"
You can add torrents and change prefs from the webui.

# transmission-daemon -s /root/.transmission/daemon/socket

You can see if transmission-deamon is running:

# ps aux | grep transmission-daemon

root 2721  0.1 16.1 8364 4852 ? S Dec01   2:57 transmission-daemon -s /root/.transmission/daemon/socket
root 2722  0.0 16.1 8364 4852 ? S Dec01   0:00 transmission-daemon -s /root/.transmission/daemon/socket
root 2723 26.0 16.1 8364 4852 ? R Dec01 766:27 transmission-daemon -s /root/.transmission/daemon/socket

Now set the download path of the remote daemon:

# transmission-remote -f /shares/internal/PUBLIC/torrent/

Now go to http://<MyBook-IP>/Clutch and start downloading ...

If at this point transmission-daemon is not running, or giving errors, or your Clutch webui is giving errors,
probably some of your file or directory permissions are not correct.

Here are my permission settings :

.transmission/daemon/socket : 
[root@MyBookWorld ~]# ls -l -a .transmission/daemon/socket
drwxrwxrwx 2 www-data www-data 4096 Dec  3 14:27 .

/shares/internal/PUBLIC/http-server/Clutch :
[root@MyBookWorld ~]# ls -l -a /shares/internal/PUBLIC/http-server/
drwxrwxrwx 6 www-data www-data  4096 Oct 25 05:45 Clutch

Looks to me they are all set to the user www-data.

4.3.2. Auto start/stop

To start transmission automatically with all correct permissions, create a simple shell script.

# cd /etc/init.d
# nano transmission

Add the following into the file:

#!/bin/sh
#
# Copyright (C) 2007 Bart Franco
#
# Starts or stops the transmission daemons.
# Writes directory permissions and changes owner for
# the transmission.socket.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME="transmission"
DESC="BitTorrent client"

case "$1" in
  start)
    echo -n "Starting $DESC: $NAME"
    transmission-daemon -s /root/.transmission/daemon/socket
    echo "..."
    sleep 4
    chmod -R 777 /root/.transmission
    chown -R www-data:www-data /root/.transmission
    sleep 3
    # Setting torrent download directory (not working in Clutch/Preferences yet)
    transmission-remote -f /shares/internal/PUBLIC/torrent/ 
    sleep 1
    ps aux | grep transmission-daemon
  ;;
  stop)
    echo -n "Stopping $DESC: $NAME"
    killall transmission-daemon
    echo "."
  ;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop}" >&2
    exit 2
  ;;
esac

exit 0

Run it like this: /etc/init.d/transmission start

4.3.3. Auto Startup/Shutdown

And run the following to have it startup and stop on system start/shutdown.
Give transmission its access rights. Then make a symbolic link to stop the service when the MBWE is shutting down.

# cd /etc/init.d
# chmod 0700 /etc/init.d/transmission
# chown root:root /etc/init.d/transmission
# ln -s /etc/init.d/transmission S98transmission
# ln -s /etc/init.d/transmission K03transmission

The scripts in the directory /etc/init.d/ starting with S[number] are automatically run during system startup with parameter start.
The number defines the order the scripts are run.
Likewise, scripts starting with K[number] are run when the system is shutting down with parameter stop.

4.3.4. Password Protected Web Interface

I love the idea of being at work an just letting my HD what to download and when.
Its a great concept, however I was wondering if there was any way I could password protect the clutch gui.
I'd like to somehow authenticate before it lets me mess around with it.
I'd hate for someone to portscan me and mess with all my torrents when I'm away.

Add the following to your /etc/lighttpd/lighttpd.conf file to set auth on your Clutch directory:

auth.require               = ( "/auth" =>
                               (
                                  "method"  => "digest",
                                  "realm"   => "nas admin",
                                  "require" => "valid-user"
# bruce - removed user=
#                                  "require" => "user=admin"
                               ),
                               "/Clutch/" =>
                               (
                                  "method"  => "digest",
                                  "realm"   => "nas admin",
                                  "require" => "valid-user"
                               ) 

This will use the same password you use to access your Mybook Webinterface.