giovedì 19 settembre 2013

Torrent and DLNA station with Raspberry Pi

A router, a Raspberry Pi and an external hard disk.
This is a quick guide that explains how to make a torrent and DLNA station with a Raspberry Pi. I'm writing this guide as a note for self, but it may also be useful for others. I use Ubuntu, therefore all the instructions in this guide are considered for a Linux system.

Advantages

The main advantage of this system is that you can basically leave your Raspberry Pi on 24/7 with a minimum power consumption and have a self managed server that downloads and stream your movies.

Raspberry Pi

The Raspberry Pi is a credit-card size single-board computer that you can buy for around 35e on this web site.

Install the OS

There are several Linux distribution available for installation on the Raspberry Pi on this web site. I personally use the Raspbian distribution. Once you have downloaded the zip file, extract it. Plug your SD card (on a computer that is not your Raspberry Pi) and run the ImageWriter application. This is a very easy software that makes you select the image you want to write (the one you have just extracted from the zip file) on the left, and the device you want to write on (the SD card) on the right. You need a 4GB SD card, I personally use a 32GB one.

Run the OS

Once you have copied the image on the SD, put it in your Raspberry Pi and run it. The first time you will be presented with a menu. From this menu the only entry that you have to select is "Expand root partition to fill SD card" that, obviously, expand the root partition and makes sure that the Raspbian OS can make use of all the space available, otherwise it will only see 2GB.

SSH

You won't use the Raspberry Pi through the desktop interface, so you need a way to communicate with your little PC, and this way is the SSH protocol. The following commands will install SSH on Raspbian and make it run at the start-up as system service:

sudo apt-get install ssh

sudo /etc/init.d/ssh start

sudo update-rc.d ssh defaults 

Now you can access the Raspberry Pi from another computer entering this command from a system terminal:

ssh pi@a.b.c.d

Where a.b.c.d is the network address of your Raspberry Pi, e.g. 192.168.1.100, and usually you can get this from the admin interface of your home router. You will be asked for the password, the default one is raspberry.

Transmission 

This is the software that will download your torrent files. You can install it with:
sudo apt-get install transmission-daemon
At this point you need to create at least two folders: one for the complete files and one for the downloading one. You can do so by entering the following commands:

mkdir movies

mkdir incomplete

Now, we need to stop Transmission to edit its configuration file. If you don't stop Transmission it will erase your settings, restoring the default, at the next start-up. Then, to stop Transmission:

sudo service transmission-daemon stop

Then, open the file to edit with:

sudo nano/etc/transmission-daemon/settings.json

In questo file dobbiamo modificare alcune voci:
  • "download-dir" : "/home/pi/movies"
  • "incomplete-dir" : "/home/pi/incomplete"
  • "incomplete-dir-enabled" : true
  • "download-queue-enabled" : false
  • "rpc-enabled" : true
  • "rpc-password" : "CHOOSE A PASSWORD"
  • "rpc-username" : "CHOOSE A USERNAME"
  • "rpc-whitelist-enabled" : false
At this point we can restart Transmission with:

sudo service transmission-daemon start

We want Transmission to start when the Raspberry Pi turns on, we can do so by entering the following command:

sudo update-rc.d transmission-daemon defaults

You can now control your Transmission server by web browser, accessing the following URL: http://a.b.c.d:9091/transmission where a.b.c.d is once again your Raspberry Pi IP. You will be asked to enter your username and password (the same you have set in the configuration file), at this point you can add and manage torrent files from the web interface.

Mediatomb

This is the software the streams your movies through the DLNA protocol. You can easily install it with:

sudo apt-get install mediatomb

When the installation is complete, you can launch it with:

mediatom

You can control Mediatomb through its web interface, available at: http://a.b.c.d:49153/ and you can use it to tell Mediatomb which movies you want to stream. To watch the movies you can use any DLNA client, I personally use my PS3 which works great.

Useful Links

Raspberry Pi: http://www.raspberrypi.org/
Raspberry Pi OS's: http://www.raspberrypi.org/downloads 
Transmission: http://www.transmissionbt.com/
Mediatomb: http://mediatomb.cc/

Nessun commento:

Posta un commento