Motivation
Most people use Dropbox and other cloud services to share their files. But if you want to be in control of your files - without any restrictions - than you need to setup your own share server. The simplest way to do so is to setup a FTP or HTTP server. I didn't want to use a FTP because the person you want to share your files with has first to setup the connection - too much work. Another problem with both options is that they don't handle a connection lost very well. So I decided to use a torrent network.- it can handles a connection lost very well
- the peers will upload too (important if you share you files with many people)
- easy to use: just send a magnet link or a torrent file
Setup a Torrent Tracker - opentracker
At first we setup our own torrent tracker using opentracker.
sudo apt-get install cvs
cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co libowfat
cd libowfat
make
cd ..
cvs -d:pserver:anoncvs@cvs.erdgeist.org:/home/cvsroot co opentracker
cd opentracker
make
chmod a+x opentracker
That's it. Just start the torrent tracker
./opentracker
Setup a Torrent Client - rtorrent
The tracker connects the peers with each other but it doesn't seed (upload) anything. So we need a torrent client which will seed our shared files. Get the program
sudo apt-get install rtorrent
Configure rtorrent
wget http://libtorrent.rakshasa.no/export/1303/trunk/rtorrent/doc/rtorrent.rc
mv rtorrent.rc ~/.rtorrent.rc
nano ~/.rtorrent.rc
The most important configuration settings
# sure use udp
use_udp_trackers = yes
# encryption is always a good idea
encryption = require
# change it so it doesn't conflict with our torrent tracker which uses the port 6969
port_range = 6890-6960
# where the files are saved
directory = ~/downloads/torrents/
# load automatically all torrent files from the directory and start downloading or seeding
schedule = watch_directory,5,5,load_start=/var/www/torrents/*.torrent
# if the torrent files are removed stop downloading or seeding
schedule = untied_directory,5,5,stop_untied=
Now you could start rtorrent and start downloading torrents.
Create a Torrent File - mktorrent
Now we need to create a torrent for the files we want to share.
sudo apt-get install mktorrent
mktorrent -p -a http://${YOUR_IP_OR_DOMAIN}:6969/announce -a udp://${YOUR_IP_OR_DOMAIN}:6969/announce FILE_OR_DIRECTORY -o OUTPUT_FILE.torrent
That's it. Put the torrent file in you torrent watch directory and start rtorrent. Rtorrent will read the file and start seeding. Don't forget the source file must be in the right directory (see the rtorrent setting directory=).
Setup your router and start sharing
You probably need to setup a port forwarding to your Raspberry Pi for the necessary ports.Then you can start sharing your files in your own private torrent network :)
Further reading
How to automatically start opentracker and rtorrentHow to generate a magnetic link form a torrent file (convert torrent file to magnetic link)