Using Bittorrent

From WL-HDD Wiki

Jump to: navigation, search

The last 2 days I spent a lot of time finding out how btorrent works - I think it's time to give a short introduction for newcomers here:


Contents

Features

--> btget


btget is the basic function of btorrent. btget -h gives you an overview about the options. It is used for manually downloading torrents into the current folder.


Examples:

btget <mytorrent>.torrent


will download <mytorrent>.torrent into the current folder. The *.torrent file has to be copied into this folder before, for example using FTP or wget (wget <URL of the *.torrent file>. The command is connected to the Shell, so you're updated continously about the download status. The download will abort as soon as you close the Shell. To prevent this you can use nohup.


nohup btget <mytorrent>.torrent


will do the same, but the output is written into a file called "nohup.out" in the current folder. Don't forget to delete this file after the download has finished, otherwise you will generate plenty of useless data. After about 1 min you are save to close the Shell, your download will continue.

If you don't want to download the *.torrent file before, you can use the btget -u option.


btget -u <URL of your torrent>
nohup btget -u <URL of your torrent>


Downloading manually makes it a little bit difficult to manage your downloads - there for the author has implemented some


Scripts

--> cron


cron is a process allows you running scripts periodically - we will see later what it's used for. cron and its configuration comes with the btorrent installation, the config file is /opt/etc/crontab. Unfortunately cron comes with btorrent as an improper installation - lets re-install it:


ipkg -force-reinstall install cron


The /opt/etc/crontab already exists on your system, so a message will appear:


Installing cron (4.1-4) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/unslung/wl500g/cron_4.1-4_mipsel.ipk
    Configuration file '/opt/etc/crontab'
    ==> File on system created by you or by a script.
    ==> File also in package provided by package maintainer.
       What would you like to do about it ?  Your options are:
        Y or I  : install the package maintainer's version
        N or O  : keep your currently-installed version
          D     : show the differences between the versions (if diff is installed)
     The default action is to keep your current version.
    *** crontab (Y/I/N/O/D) [default=N] ?


Just acknowledge with "Y"

Afterwards we have to correct the /opt/etc/crontab:


nano /opt/etc/crontab


SHELL=/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=""

HOME=/
# ---------- ---------- Default is Empty ---------- ---------- #
*/30 * * * * <your admin account name, e.g. "root"> nice /opt/sbin/torrent_watchdog
Ctrl-O
Ctrl-X
reboot
ps


You should see the cron process running.


--> torrent_admin


This script is your "Download Manager". torrent_admin -h gives you an overview about the options.


--> torrent_watchdog


Is checking, if your started downloads are still running. If one ore more are not, it will restart them automatically. That's the point where cron is used. cron is running this script every 30 minutes by default.

Using the Scripts

In order to use the scripts you have to follow certain procedures. Remember, during installation we've made three directories:


/opt/torrent/source
/opt/torrent/work
/opt/torrent/target


Right now all you have to do is to copy your <mytorrent>.torrent file(s) into the /opt/torrent/source folder. Now the're ready for processing - they're queued. You can see that using


torrent_admin -l


You can have queued as many torrents as you want - now choose which one you want to download by using


torrent_admin -p <mytorrent>.torrent


The torrent is pushed from the queue to the active downloads, in fact that means the *.torrent file is copied into the /opt/torrent/work directory where the watchdog takes care of. So far I've tried up to 10 active downloads at the same time, my system was running stable and I was still able to access movies on the HDD via VLC.

You can check the status of your downloads using


torrent_admin -u


After the download is finished, it's moved to /opt/torrent/target and seeded for upload automatically.

Now you should be able to get your downloads done. You still think that's too difficult or complicated? Don't worry btorrent comes with another great thing:


The Webinterface

Now btorrent gets convenient. Unfortunately to get that thing running we have to do some modifications for the webserver


--> busybox_httpd


which was already installed with btorrent. But now we want to get it working and automatically starting after reboot.


cd /opt/etc/init.d/

ls


you should see the files in there, for example like


S10xinetd  S97Samba  S80busybox_httpd  rc.unslung


I don't know why, but at all systems I've set up, busybox_httpd was only starting automatically when it was set as last script to start. So let's change the filename:


mv S80busybox_httpd S99busybox_httpd


The path specifief for the httpd.conf file is the home directory of the current user, this has nothing to do there so we have to change it:


nano S99busybox_httpd


Watch out the head and change the highlighted line:


#!/bin/sh

PATH=/sbin:/bin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin

# Uncomment path to busybox httpd to enable startup
BUSYBOX_HTTPD=/usr/sbin/busybox_httpd

HTTPD_CONFIG=/opt/etc/httpd.conf

LISTENING_PORT=8008


If you want you can also change the port in there, for example if you're using 8008 already for another application.

DONT FORGET TO FORWARD THE SPECIFIED PORT ON YOUR ROUTER!!!

now let's check if busybox_httpd is running:


reboot
ps


you should see something like


118 root        108 S   /usr/sbin/busybox_httpd -c /opt/etc/httpd.conf -p 8008 -h /opt/share/www


Let's check out the Webinterface!!!!! Just open your browser -->


http://IP.of.your.WL-HDD/cgi-bin/torrent.cgi


Enjoy using the torrent_admin options just by klicking the buttons!!!


I think that's it for you to get started - so Good Luck and always a lot of seeds!

Greetz Michael

Personal tools