Zachary Loeber

I eat complexity and am never without a meal.

Linux: Headless Ubuntu Torrent Home Server

So it got to that time of the year where I feel the itch to upgrade my aging home server. I assessed the situation and realized that, for what it does, my current server does not need any kind of hardware upgrade. So I just decided to rebuild it with Ubuntu 11.04 64 bit and change up the server software a bit to be more accessible to my wife as well as to be a bit more modern (torrentflux and derivatives have been dead for a while now).

Preface

In this rebuild I wanted to make the services on the server more accessible for my wife. So my software selection is a bit more cohesive as I want all the services to be accessible to more than just the technically inclined. I also wanted her to be able to download missed TV shows without my help should she find the need to do so.

Software I chose to install:

  • Peer Guardian for Linux – Blocks IP addresses from known haters and other groups of your choice.
  • Mediatomb PS3 Media Server – A upnp server for playing movies and other media
  • Transmission – A pretty cool bittorrent client
  • Torrentwatch-x – Web based RSS tracker for bittorrents, integrates with transmission
  • Mollify – A simple web based file browser
  • Samba – For windows workstation integration
  • Webmin – I didn’t want to mess with a manual samba configuration so I set this up to simplify things 🙂

Initial Server Install

As I refuse to just post a bunch of screenshots of pressing “next” I’m going to skip the base install documentation. The brief rundown of what to do is to install Ubuntu server 11.04 64 bit, do not select drive encryption, select “OpenSSH server”, “LAMP Server”, and “SAMBA file server” for the core software. If you flubbed this up for whatever reason you can always run “sudo tasksel” to select these metapackages later on.

I started out with some generic apps. For whatever reason add-apt-repository was not available in the 64bit server version of ubuntu 11.04. Install this to make that handy command available again. I add in rkhunter, screen and htop cause I like them 🙂 We also install ntp to update our time automatically:

I also modified the base apt repository list: Uncomment the following in /etc/apt/sources.list (sudo nano /etc/apt/sources.list):

Update your system and make our working directory used in the rest of this post. All scripting and commands posted are assuming that this Downloads folder exists, should you do things any other way then you will have to keep that in mind throughout the post and modify things as needed. Adding to that, the whole post is not simply a copy and paste fully scripted out procedure so do things intelligently and with fair warning that your results may vary based on your environment and technical acuity:

Peer Guardian for Linux Install

Install the repository and the software. You will be asked a series of questions. You can skip them and modify the pglcmd.conf file directly afterwards if you like. I do recommend you be careful when selecting your block lists. The default should be fine but you may want to add a few more from the list when given the option:

If you skipped or just chose the default wizards then update the default config file to allow services that have nothing to do with torrent traffic in and out of your server:

If you ever find that an update makes PeerGuardian unable to be started run sudo dpkg-reconfigure –force pglcmd. Here is some extra information taken directly from pgl when it failed to start for me. Make of it what you will:

If any blocklists are missing, they will be downloaded. This may take several

minutes. Please be patient and don’t abort. If you want to follow the update

process, then do in another terminal a

tail -f /var/log/pgl/pglcmd.log

The lists are saved to /var/spool/pgl/.

The installation of pglcmd will fail, if starting pgld fails. So if

downloading the blocklists fails temporarily, the installation will fail. In

this case you may turn the automatic starting off by setting in

/etc/pgl/pglcmd.conf:

INIT=”0″

Then complete the installation and turn the automatic start on again:

sudo dpkg-reconfigure –force pglcmd

Transmission Install

This small guide  should get you going but you still have to look at enabling UPnP/NAT-PMP on your firewall. If you are running TomatoUSB (my new favorite) then go to port forwarding -> UPnP/NAT-PMP to enable this setting. (Note: I wrote this up with without explaining a whole lot, I was looking for something else entirely when I found this well written guide with good explanations on the settings: http://1000umbrellas.com/2010/10/04/updated-transmission-installationconfiguration-on-ubuntu-server).

First install Transmission. Create a new home for transmission, Note that we add the incomplete directory so if a torrent dies or gets interrupted it remains in that directory instead of mucking up your downloads directory. We enable this behavior later on. Make it so you can modify this directory and all its contents by simply being in the debian-transmission group (this coincides with a transmission umask setting we will make shortly). Enable ports 9091 and 51413 (if using ufw, by default this is not enabled and therefore not needed). Finally update the transmission configuration, you need to do this with the daemon entirely stopped or the configuration changes will get overwritten the next time you restart the services:

Replace the following lines to (optionally) set downloaded torrents umask so that members of the debian-transmission group can read and write completed torrents (so you don’t have to sudo to move and delete the files). Also, get rid of authentication and update to your new directory layout:

Add your primary user account to the transmission group, replace with your own login ID:

Startup Transmisison:

Test Transmission by going to http://servername:9091/transmission/ and uploading a torrent of your choice. When it starts downloading and connecting to peers validate that our blocklist configuration is indeed working by checking the logs in real time:

Torrentwatch-X Install

Torrentwatch-X is a nifty web interface for tracking rss feeds which point to torrents for such things as TV shows. I set this up so if my wife needs to get some TV show she missed it is as simple as a few clicks in a browser to download. Below should get everything setup in a way that is integrated with your prior transmission install:

Modify /etc/torrentwatch/torrentwatch.config and replace the [Settings] area only with the following to integrate transmission with torrentwatch-x:

Mollify Install

I opted for installing Mollify for my wife to be able to easily access the server files from any computer. Here is how to get it setup:

Enter the following

Create your database with whatever login and password you want to use:

Go to http:///mollify/backend/install/ to complete the mollify installation (basically select next then create an admin account admin/admin). Logon to http:///mollify/backend/admin/.

Select Published Folders on left, Click on the add folder button, Put in the path of /home/torrents/downloaded with the description of “Downloaded Torrents”, Select the new published path and then click on “Add Folder for New Users/Groups”, check your admin account. Give your wife the admin account or create a new one, up to you. Other configuration settings for mollify can be set manually, here is a link to possible options : http://code.google.com/p/mollify/wiki/ConfigurationAdditionalOptions. There are also example configurations at /var/www/mollify/backend/examples

PS3 Media Server Installation

Originally I was going to use mediatomb but I was having all kinds of issues getting it working the way I wanted and the xml config file and extra scripts you would need to get it working well is a total pain in the rear to setup. I finally scratched the mediatomb idea and went with PS3 Media Server. It runs on java and is more memory intensive but I simply do not care at this point (last sentence said in a frustrated tone).  Besides someone already wrote an awesome script to automate the install 🙂

Double-check that your user name is still part of the admin group, I found for some reason it was not after running the install process (nano /etc/group, look for the admin group and make sure your account name is listed at the end of the line). Then start a new terminal session with your server with X11 forwarding set (ie. ssh -X yourserver). From here you you have to stop the service, edit your settings, and restart the service:

Edit your settings so that you are streaming /home/torrents/download and /home/torrents/upload (or whatever directory you want to stream, I chose these two to be able to automatically stream downloaded torrents and uploaded content quickly). Save your settings, exit, start pms-linux:

You can now just access the simple web terminal to kick off rescans of your media folders should you find the need to do so. The site will be http://:5001/console/

Webmin Installation

This isn’t really needed but I wanted to setup the /home/torrents/download directory to be accessible via samba and I did not want to deal with doing it all via command-line. So I opted for webmin’s samba module to do the configuration:

You can now logon to your webmin interface by going to https://:10000/ and using /. If this does not work then use root/, select webmin -> Webmin Users -> Convert Unix Users -> select your username and select to convert now. Finally, share out any files/folders that you wish to share using the samba plugin within webmin.