NSLU2-Linux
view · edit · print · history

Optware.Btpd History

Hide minor edits - Show changes to markup

June 08, 2009, at 02:36 PM by HN -- answer to girish
Changed lines 284-287 from:

Is there anything I am doing wrong?

to:

Is there anything I am doing wrong?

From HN (08-06-09):

Girish, btpd had been upgraded to version 0.15, which didn't work. To make it work: ipkg remove btpd, ipkg update, ipkg install btpd

February 06, 2009, at 09:07 AM by Girish --
Changed lines 277-284 from:

@]

to:

@]

From Girish (06-FEB-09):

When I run btpd, I get following error

[err] clock_gettime: Invalid argument

Is there anything I am doing wrong?

July 03, 2008, at 07:08 AM by CR --
Changed lines 276-285 from:

if [ "ps ax | grep -v grep | grep btpd" ]; then

 echo "btpd  running"

else

 echo "btpd not running"
 btpd --bw-in $bandwidth_in --bw-out $bandwidth_out -p $port

fi @] Got some errors with that (my script is named btpdScript, so guess what...), so i changed to a simple: [@ if [ "$(pidof btpd)" ]

to:

if [ "$(pidof btpd)" ]; then

July 03, 2008, at 07:07 AM by CR --
Added lines 282-285:

@] Got some errors with that (my script is named btpdScript, so guess what...), so i changed to a simple: [@ if [ "$(pidof btpd)" ]

June 27, 2008, at 05:18 AM by CR -- minor edit regarding env variables
Added lines 184-186:

edit by CR (27-JUN-2008): This is due to the environment variables - they differ from cron to actual shell environment. You could have saved a lot of work if you just set PATH to /opt/bin :)

June 26, 2008, at 01:38 PM by CR -- btpd running check
Changed lines 267-279 from:

Tumaini, have you CHMODed? your /torrents and /downloads directory right? it kinda sounds like the slug can't move the .torrent to a new directory.

to:

Tumaini, have you CHMODed? your /torrents and /downloads directory right? it kinda sounds like the slug can't move the .torrent to a new directory.

From CR (26-JUN-08):

Your "btpd running" check did not work for me (don't know why, check did always return that btpd was not running), so checked with

# --- check whether btpd is running; it tends to quit every few hours when down$
if [ "ps ax | grep -v grep | grep btpd"  ]; then
 echo "btpd  running"
else
 echo "btpd not running"
 btpd --bw-in $bandwidth_in --bw-out $bandwidth_out -p $port
fi
June 15, 2008, at 12:13 AM by HN -- answer to tumaini
Changed lines 264-267 from:

@]

to:

@]

From HN (15-JUN-08):

Tumaini, have you CHMODed? your /torrents and /downloads directory right? it kinda sounds like the slug can't move the .torrent to a new directory.

June 02, 2008, at 11:17 AM by Tumaini --
Changed line 253 from:

My slug keeps beeping twice about every 2 minutes, unless I uncomment the line here:

to:

My slug keeps beeping twice about every 2 minutes, unless I uncomment the line here (marked with ->):

Changed line 261 from:

Set_Led beep2 &

to:
Set_Led beep2 &
June 02, 2008, at 11:17 AM by Tumaini -- Comment
Added lines 251-264:

From Tumaini (2-JUN-08):

Is there something missing in the current version of the btpd.sh-script? My slug keeps beeping twice about every 2 minutes, unless I uncomment the line here:

 newdir=`btinfo "$torrentfile" | grep Name | sed -e "s/Name: //" | sed -e "s/[/\]/./g"`
 mkdir "$finisheddir/$newdir"
 chmod 777 "$finisheddir/$newdir"
 mv "$torrentfile" "$finisheddir/$newdir"
 cd "$finisheddir/$newdir"
 btcli add -d . "$torrentfile"
!!! Set_Led beep2 &
 sleep 1
 killall Set_Led
April 19, 2008, at 07:39 PM by DAG --
Changed lines 191-193 from:

Created a php script to do basic monitoring. I put the following into /opt/share/www/lighttpd/bt.php:

to:

Created a php script to do basic monitoring. I dropped the following into /opt/share/www/lighttpd/bt.php. To monitor goto http://unslung:8081/bt.php?refresh=60.

April 19, 2008, at 07:38 PM by DAG -- PHP script
Added lines 189-248:

From DAG (19-APR-08):

Created a php script to do basic monitoring. I put the following into /opt/share/www/lighttpd/bt.php:

<?php
if ($refresh = $_GET['refresh']) {
?>
        <meta http-equiv="refresh" content="<?php echo $refresh; ?>" />
<?php
}
?>
<html><title>BTPD monitor</title>
<h1>BTPD monitor</h1>
<body><p>
<?php
if ($delete=$_GET['delete'])
{
        $output=shell_exec("/opt/bin/btcli del $delete; sleep 2");
        echo "<pre>$output</pre>";
}
$output=shell_exec("/opt/bin/btcli list");
$array=explode("\n",$output);
if ( count($array) == 2 )
{
?>
<p><b>No torrents</b></p>
<?php
}
else
{
?>

</p>
<p>

<table  bordercolor="#0066FF" border="1">
        <tr><th align=left border=0>Name</th><th border=0 align=left>Complete</th></tr>

<?php
$pos=strpos( $array[0], "NUM" );
for ($i=1; $i < count($array)-1; $i++ )
{
        $t=$i-1;
        $row=preg_split("/[\s]+/",substr($array[$i],$pos,strlen($array[$i])-$pos ));
        $name=substr($array[$i],0,$pos);
        echo "<tr><td>$name</td><td>$row[3]/$row[4]</td><td><a href='bt.php?delete=$row[1]'>remove</a></td>";
}
}
?>
</table>
</p>
<p>
<?php
        echo "<a href='bt.php?refresh=60'>refresh</a>";
?>
</p>
</body>
</html>
April 13, 2008, at 12:15 AM by HN -- changed a line; added a comment
Changed line 44 from:

torrentfile=`find . -maxdepth 1 -name "*.torrent" | head -n 1 | cut -d "/" -f 2`

to:

torrentfile=`ls | grep .torrent | head -n 1`

Changed lines 187-188 from:
to:

From HN (13-APR-08):

I just had to reinstall my slug. Seems that the newest version of coreutils and busybox have a stripped version of 'find', which doesn't allow the -maxdepth option. So I changed the line to torrentfile=`ls | grep .torrent | head -n 1` . This is probably even faster.

April 03, 2008, at 04:54 AM by Alan -- additional path variables... now it works well.
Changed lines 166-167 from:

Works very well, but I couldn't get it to execute under cron for root user until I made the following modifications:

to:

Works very well, but I couldn't get it to execute under cron (ipkg cron) for root user until I made the following modifications:

Added line 170:

btpd_conf_directory="/root"

Added line 174:

BTINFO="/opt/bin/btinfo"

Added lines 176-178:

CUT="/opt/bin/cut" TR="/opt/bin/tr" FIND="/opt/bin/find"

April 02, 2008, at 10:12 PM by christhenowheremancom --
Added lines 178-182:

From Nowhere Man (02-APR-08):

Awesome little script. I did have to add a "-d /root/.btpd" option when invoking btpd to get it to work properly on my slug, but it seems to be doing the job as expected. Thanks!

April 02, 2008, at 01:28 AM by Alan -- formatting fix for my previous change.
Added line 169:

[@

Changed lines 174-175 from:
to:

@]

April 02, 2008, at 01:26 AM by Alan -- added command variables to script
Changed lines 163-175 from:

@Adam: thanks! Glad I could help.

to:

@Adam: thanks! Glad I could help.

From Alan (02-apr-08):

Works very well, but I couldn't get it to execute under cron for root user until I made the following modifications:

Declared some new variables (find these paths using 'which xxx' with xxx being the command name) WC="/opt/bin/wc" BTCLI="/opt/bin/btcli" BTPD="/opt/bin/btpd" SEQ="/opt/bin/seq"

then replaced the commands in the scripts with the appropriate variables i.e. for btcli, replace with $BTCLI

March 24, 2008, at 01:36 PM by HN -- info on usage edit
Changed line 126 from:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The downloadfolder is a subdirectory of $finisheddir and its name is determined by the name found inside the .torrent file.\\

to:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. Should the torrent be found to be defective, the slug will beep once (haven't seen this happen in months, but if it does: try another program. It probably WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The downloadfolder is a subdirectory of $finisheddir and its name is determined by the name found inside the .torrent file.\\

March 24, 2008, at 01:31 PM by HN -- Small edits to the script, using svennoe & bram\'s suggestions
Changed lines 23-24 from:

I have made the following script for automatic downloading (in my case /root/btpd.sh):

to:

I have made the following script for automatic downloading (in my case /usr/sbin/btpd.sh):

Changed line 65 from:

for (( i = 1 ; i <= $btnod; i++ ))

to:

for i in $(seq 1 $btnod);

Changed lines 122-123 from:
  • add to cron: echo '*/2 * * * * root /usr/sbin/btpd.sh' >> /etc/crontab
to:
  • add to cron: echo '*/2 * * * * root /usr/sbin/btpd.sh &>/dev/null' >> /etc/crontab
Changed lines 126-128 from:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found t o be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The downloadfolder is a subdirectory of $finisheddir and its name is determined by the name found inside the .torrent file.
Once the download is finished, the slug will beep twice again. As long as it's still seeding, you'll see a text file in the download directory, called SEEDING.txt. Once the seeding has reached the desired ratio, the slug will beep three times.

to:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The downloadfolder is a subdirectory of $finisheddir and its name is determined by the name found inside the .torrent file.
Once the download is finished, the slug will beep twice again. As long as it's still seeding, you'll see a text file in the download directory, called SEEDING.txt. Once the seeding has reached the desired ratio, the torrent will stop seeding, the slug will beep three times, and the torrentname will be added to the file 'finished_seeding.txt'.

Changed lines 159-163 from:

'*/2 * * * * root /usr/sbin/btpd.sh &>/dev/null' >> /etc/crontab

to:

'*/2 * * * * root /usr/sbin/btpd.sh &>/dev/null' >> /etc/crontab

From HN (24-mar-08):

@Svennoe, @Bram: thanks for your input. I've changed the script according to your suggestions. @Adam: thanks! Glad I could help.

March 22, 2008, at 07:17 PM by Svennoe -- my edit
Changed line 158 from:

&>/dev/null needs to be added to the crontab right after the command

to:

&>/dev/null needs to be added to the crontab right after the command, so your command should look like this

March 22, 2008, at 07:16 PM by Svennoe -- Crontab didnt work
Changed lines 154-159 from:

NEW: for i in $(seq 1 $btnod);

to:

NEW: for i in $(seq 1 $btnod);

From Svennoe (23-mar-08):

&>/dev/null needs to be added to the crontab right after the command '*/2 * * * * root /usr/sbin/btpd.sh &>/dev/null' >> /etc/crontab

March 21, 2008, at 08:16 PM by makka -- edit folder
Changed line 31 from:

finisheddir="/public/finished_downloads"

to:

finisheddir="/public/downloads"

Changed line 112 from:
  • ipkg install bash coreutils btpd
to:
  • ipkg install bash coreutils btpd findutils
March 21, 2008, at 07:32 PM by makka -- create a command for each torrent folder
Changed lines 113-115 from:
  • mkdir /public/torrents, /public/torrents/invalid and /public/downloads (or whatever folder suits you)
to:
  • mkdir /public/torrents
  • mkdir /public/torrents/invalid
  • mkdir /public/downloads (or whatever folder suits you)
February 21, 2008, at 11:22 PM by Bram Snip --
Changed lines 151-153 from:
  1. for ( i = 1 ; $i <= $btnod; i++ )

for i in $(seq 1 $btnod); do

to:

OLD: for ( i = 1 ; i <= $btnod; i++ ) NEW: for i in $(seq 1 $btnod);

February 21, 2008, at 11:21 PM by Bram Snip -- Fix for-loop
Changed lines 147-153 from:

Works flawlessly, "out of the box". Big thank you to the author of this topic! :)

to:

Works flawlessly, "out of the box". Big thank you to the author of this topic! :)

From Bram (22-Feb-08):

Change the for-loop code as follows

  1. for ( i = 1 ; $i <= $btnod; i++ )

for i in $(seq 1 $btnod); do

January 31, 2008, at 11:30 PM by Adam --
Changed lines 144-147 from:

facing the same problem ...

to:

facing the same problem ...

From Adam (01-Feb-08):

Works flawlessly, "out of the box". Big thank you to the author of this topic! :)

January 26, 2008, at 05:11 PM by hbel --
Changed lines 142-144 from:

I can't find any token matching problem...

to:

I can't find any token matching problem...

From hbel (26/1-2008) :

facing the same problem ...

January 09, 2008, at 08:44 PM by Timer -- Maybe noob question but keep getting error on line 40
Changed lines 136-142 from:

Re: Gabriel: I think your error has been resolved now.

to:

Re: Gabriel: I think your error has been resolved now.

From Timer (09/1-2008) :

Maybe a noob question but keep getting error on line 40: 'tpd2.sh: line 40: syntax error near unexpected token ` 'tpd2.sh: line 40: `for (( i = 1 ; i <= $btnod; i++ )) I can't find any token matching problem...

October 11, 2007, at 09:22 AM by HN --
Changed line 85 from:
   chmod -R 777 .
to:
   chmod -R 755 .
Changed line 94 from:
    chmod -R 777 .
to:
    chmod -R 755 .
October 11, 2007, at 09:20 AM by HN -- small script change, changed installation guide
Changed lines 79-81 from:
  [ -e "./ DOWNLOADING.txt" ] && `rm "./ DOWNLOADING.txt"`
  btcli stat $btnr | grep -v DLOAD > "./ DOWNLOADING.txt"
  chmod 777 "./ DOWNLOADING.txt"
to:
  [ -e "./DOWNLOADING.txt" ] && `rm "./DOWNLOADING.txt"`
  btcli stat $btnr | grep -v DLOAD > "./DOWNLOADING.txt"
  chmod 777 "./DOWNLOADING.txt"
Changed lines 87-88 from:
   [ -e "./ DOWNLOADING.txt" ] && `rm "./ DOWNLOADING.txt"`
   [ -e "./ SEEDING.txt" ] && `rm "./ SEEDING.txt"`
to:
   [ -e "./DOWNLOADING.txt" ] && `rm "./DOWNLOADING.txt"`
   [ -e "./SEEDING.txt" ] && `rm "./SEEDING.txt"`
Changed line 93 from:
   if [ -e "./ DOWNLOADING.txt" ]; then
to:
   if [ -e "./DOWNLOADING.txt" ]; then
Changed line 95 from:
    rm "./ DOWNLOADING.txt"
to:
    rm "./DOWNLOADING.txt"
Changed lines 100-102 from:
   [ -e "./ SEEDING.txt" ] && `rm "./ SEEDING.txt"`
   btcli stat $btnr | grep -v DLOAD > "./ SEEDING.txt"
   chmod 777 "./ SEEDING.txt"
to:
   [ -e "./SEEDING.txt" ] && `rm "./SEEDING.txt"`
   btcli stat $btnr | grep -v DLOAD > "./SEEDING.txt"
   chmod 755 "./SEEDING.txt"
Changed lines 111-125 from:

-copy the above text (and change the directories and ip address to whichever you like) -telnet/ssh into your nslu2, -ipkg install bash btpd -make sure you can execute 'wc', otherwise install the newest busybox/coreutils/whatever -create the folders (e.g. /public/torrents, /public/torrents/invalid, /public/downloads) -chmod all these folders -go to the desired script directory -type cat > btpd.sh << EOF -paste the script -type EOF -type chmod 555 btpd.sh -type echo '*/2 * * * * root /root/btpd.sh &>/dev/null' >> /etc/crontab -??? -PROFIT

to:
  • ipkg update
  • ipkg install bash coreutils btpd
  • mkdir /public/torrents, /public/torrents/invalid and /public/downloads (or whatever folder suits you)
  • chmod -R 777 /public/torrents
  • chmod 755 /public/downloads
  • edit the script to change the port and directories to your desire
  • save the script in desired directory (ie /usr/sbin) as btpd.sh
  • chmod 555 btpd.sh
  • update your firewall to allow incoming traffic on your desired torrent port
  • add to cron: echo '*/2 * * * * root /usr/sbin/btpd.sh' >> /etc/crontab
Changed line 124 from:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The downloadfolder is a subdirectory of $finisheddir and its name is determined by the name found inside the .torrent file.\\

to:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found t o be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The downloadfolder is a subdirectory of $finisheddir and its name is determined by the name found inside the .torrent file.\\

October 03, 2007, at 08:55 PM by HN --
Changed lines 140-141 from:

Re: Gabriel: I think your error has been resolved now. I also fixed a bug that prevented the script from executing btpd. Edit (27/9-2007): there's still a bug here. working on it.

to:

Re: Gabriel: I think your error has been resolved now.

October 03, 2007, at 08:55 PM by HN -- edited the script somewhat
Deleted line 31:

ip="1.2.3.4"

Changed lines 37-38 from:

[ "`echo ps | grep -i btpd | grep -v grep | wc | cut -b 7-8`" -lt 1 ] && `exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out`

to:

if [ "`ps | grep "btpd --" | grep -v grep | wc | cut -b 7-8`" -lt 1 ]; then

 btpd --bw-in $bandwidth_in --bw-out $bandwidth_out -p $port

fi

September 27, 2007, at 04:24 PM by HN --
Changed lines 38-40 from:

psresult=`ps` [ "`echo $ps | grep -i btpd | grep -v grep | wc | cut -b 7-8`" -lt 1 ] && `exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out`

to:

[ "`echo ps | grep -i btpd | grep -v grep | wc | cut -b 7-8`" -lt 1 ] && `exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out`

Changed lines 138-139 from:

Re: Gabriel: I think your error has been resolved now. I also fixed a bug that prevented the script from executing btpd.

to:

Re: Gabriel: I think your error has been resolved now. I also fixed a bug that prevented the script from executing btpd. Edit (27/9-2007): there's still a bug here. working on it.

September 25, 2007, at 11:52 PM by HN -- fixed a strange error that caused the script to not execute btpd if it wasn\'t running
Changed lines 38-39 from:

[ "`ps | grep -i btpd | grep -v grep | wc | cut -b 7-8`" -lt 1 ] && `exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out`

to:

psresult=`ps` [ "`echo $ps | grep -i btpd | grep -v grep | wc | cut -b 7-8`" -lt 1 ] && `exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out`

Changed line 139 from:

Re: Gabriel: I've done some bugfixing. I'm very curious if it'll work on your slug now. p.s. forgive my buggy work, but I had to learn shell scripting from scratch do make this script.

to:

Re: Gabriel: I think your error has been resolved now. I also fixed a bug that prevented the script from executing btpd.

September 24, 2007, at 09:34 PM by HN --
Changed line 126 from:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The downloadfolder is a subdirectory of $finisheddir and it's name is determined by the name found inside the .torrent file.\\

to:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The downloadfolder is a subdirectory of $finisheddir and its name is determined by the name found inside the .torrent file.\\

September 24, 2007, at 09:31 PM by HN --
Changed line 138 from:

Re: Gabriel: I've done some bugfixing. I'm very curious if it'll work on your slug now.

to:

Re: Gabriel: I've done some bugfixing. I'm very curious if it'll work on your slug now. p.s. forgive my buggy work, but I had to learn shell scripting from scratch do make this script.

September 24, 2007, at 09:15 PM by HN --
Added line 136:
September 24, 2007, at 09:12 PM by HN --
Changed lines 126-128 from:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The name of the downloadfolder is a subdirectory from $finisheddir and is determined by the name found inside the .torrent file. Once the download is finished, the slug will beep twice again. As long as it's still seeding, you'll see a text file in the download directory, called SEEDING.txt. Once the seeding has reached the desired ratio, the slug will beep three times.
Please be advised: I have no idea what happens if you move/rename the downloadfolder of a torrent while it's still seeding. Most likely it'll work out though.

to:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The downloadfolder is a subdirectory of $finisheddir and it's name is determined by the name found inside the .torrent file.
Once the download is finished, the slug will beep twice again. As long as it's still seeding, you'll see a text file in the download directory, called SEEDING.txt. Once the seeding has reached the desired ratio, the slug will beep three times.

Changed lines 136-137 from:

From HN (24/9-2007): Re: Gabriel: I've done some bugfixing. I'm very curious if it'll work on your slug now.

to:

From HN (24/9-2007):

Re: Gabriel: I've done some bugfixing. I'm very curious if it'll work on your slug now.

September 24, 2007, at 09:05 PM by HN --
Changed lines 126-128 from:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defected (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the script and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The name of the downloadfolder is a subdirectory from $finisheddir and is determined by the name found inside the .torrent file. Once the download is finished, the slug will beep twice again. As long as it's still seeding, you'll see a text file in the download directory, called SEEDING.txt. Once the seeding has reached the desired ratio, the slug will beep three times.
Please be advised: I have no idea what happens if you move/rename the downloadfolder of a torrent while it's still seeding. Most likely it'll work out though. Your files may be chmod'ed wrong.

to:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defective (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the torrent and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The name of the downloadfolder is a subdirectory from $finisheddir and is determined by the name found inside the .torrent file. Once the download is finished, the slug will beep twice again. As long as it's still seeding, you'll see a text file in the download directory, called SEEDING.txt. Once the seeding has reached the desired ratio, the slug will beep three times.
Please be advised: I have no idea what happens if you move/rename the downloadfolder of a torrent while it's still seeding. Most likely it'll work out though.

September 24, 2007, at 09:03 PM by HN -- if someone has seeded to >1 before finishing the download, it wasn\'t CHMOD\'ed properly. Fixed.
Added line 83:
   chmod -R 777 .
September 24, 2007, at 01:12 AM by HN --
Deleted lines 122-125:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defected (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the script and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The name of the downloadfolder is a subdirectory from $finisheddir and is determined by the name found inside the .torrent file. Once the download is finished, the slug will beep twice again. As long as it's still seeding, you'll see a text file in the download directory, called SEEDING.txt. Once the seeding has reached the desired ratio, the slug will beep three times. Please be advised: I have no idea what happens if you move/rename the downloadfolder of a torrent while it's still seeding. Most likely it'll work out though. Your files may be chmod'ed wrong.

Added lines 125-127:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defected (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the script and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The name of the downloadfolder is a subdirectory from $finisheddir and is determined by the name found inside the .torrent file. Once the download is finished, the slug will beep twice again. As long as it's still seeding, you'll see a text file in the download directory, called SEEDING.txt. Once the seeding has reached the desired ratio, the slug will beep three times.
Please be advised: I have no idea what happens if you move/rename the downloadfolder of a torrent while it's still seeding. Most likely it'll work out though. Your files may be chmod'ed wrong.

September 24, 2007, at 01:11 AM by HN -- explanation of the script
Added lines 122-126:

Some info on usage: if you save a .torrent to the torrentdir, the script will pick it up in max 2 minutes. It'll beep once if the torrent is found to be defected (most likely, another program WILL accept it!). If the slug beeps twice, it has accepted the script and started downloading (a DOWNLOADING.txt will appear in the folder it's downloading to). The name of the downloadfolder is a subdirectory from $finisheddir and is determined by the name found inside the .torrent file. Once the download is finished, the slug will beep twice again. As long as it's still seeding, you'll see a text file in the download directory, called SEEDING.txt. Once the seeding has reached the desired ratio, the slug will beep three times. Please be advised: I have no idea what happens if you move/rename the downloadfolder of a torrent while it's still seeding. Most likely it'll work out though. Your files may be chmod'ed wrong.

September 24, 2007, at 01:00 AM by HN --
Changed line 129 from:

line 13: [: -lt: unary operator expected

to:

line 13: [: -lt: unary operator expected \\

Changed line 131 from:

Re: Gabriel (24/9-2007): I've done some bugfixing. I'm very curious if it'll work on your slug now. (HN)

to:

From HN (24/9-2007): Re: Gabriel: I've done some bugfixing. I'm very curious if it'll work on your slug now.

September 24, 2007, at 12:59 AM by HN -- bugfixed!
Changed lines 38-39 from:

[ `ps | grep -i btpd | grep -v grep | wc | cut -b 7-8` -lt 1 ] && `exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out`

to:

[ "`ps | grep -i btpd | grep -v grep | wc | cut -b 7-8`" -lt 1 ] && `exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out`

Changed line 44 from:
 if [ `btinfo $torrentfile 2> /dev/null | wc | cut -b 4-10` -eq 0 ]; then
to:
 if [ "`btinfo "$torrentfile" 2> /dev/null | wc | cut -b 4-10`" -eq 0 ]; then
Changed line 50 from:
 newdir=`btinfo $torrentfile | grep Name | sed -e "s/Name: //" | sed -e "s/[/\]/./g" | cut -b 1-40`
to:
 newdir=`btinfo "$torrentfile" | grep Name | sed -e "s/Name: //" | sed -e "s/[/\]/./g"`
Changed line 55 from:
 btcli add -d . $torrentfile
to:
 btcli add -d . "$torrentfile"
Changed lines 129-131 from:

line 13: [: -lt: unary operator expected

to:

line 13: [: -lt: unary operator expected
Re: Gabriel (24/9-2007): I've done some bugfixing. I'm very curious if it'll work on your slug now. (HN)

September 21, 2007, at 01:06 PM by Gabriel S Hansen --
Changed lines 127-129 from:

Running the script i keep getting error: \\ line 13: [: -lt: unary operator expected

to:

Running the script i keep getting error:

line 13: [: -lt: unary operator expected

September 21, 2007, at 01:06 PM by Gabriel S Hansen --
Changed lines 126-127 from:

Running the script i keep getting error around line 13: line 13: [: -lt: unary operator expected

to:

Running the script i keep getting error: \\ line 13: [: -lt: unary operator expected

September 21, 2007, at 12:51 PM by Gabriel S Hansen --
Changed lines 125-127 from:

Very nice - if it worked! 1. Where do You get 'btinfo' from? - by pure accident i had a similar alias running, but what is 'btinfo' in this context? 2. running the script i keep getting error around line 13: line 13: [: -lt: unary operator expected

to:

Very nice - if it worked!

Running the script i keep getting error around line 13: line 13: [: -lt: unary operator expected

September 21, 2007, at 12:48 PM by Gabriel S Hansen --
Changed line 127 from:

2. running the script i keep getting error around line 13: line 13: [: -lt: unary operator expected

to:

2. running the script i keep getting error around line 13: line 13: [: -lt: unary operator expected

September 21, 2007, at 12:47 PM by Gabriel S Hansen -- ERRORS!
Changed lines 122-127 from:

@]

to:

@]

From Gabriel (21/9-2007):

Very nice - if it worked! 1. Where do You get 'btinfo' from? - by pure accident i had a similar alias running, but what is 'btinfo' in this context? 2. running the script i keep getting error around line 13: line 13: [: -lt: unary operator expected

September 19, 2007, at 09:54 PM by HN --
Changed lines 38-39 from:

exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out

to:

[ `ps | grep -i btpd | grep -v grep | wc | cut -b 7-8` -lt 1 ] && `exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out`

September 19, 2007, at 08:01 PM by HN --
Changed lines 122-128 from:

@]


edit: this line still doesn't work if it's executed within the script (when the daemon shuts down due to an error) [ `ps | grep -i btpd | grep -v grep | wc | cut -b 7-8` -lt 1 ] && `nohup btpd -p $port --ip $ip --bw-in 1200 --bw-out 100 > /dev/null 2> /dev/null &`

can anyone shed some light on the matter? I'm currenly trying to get screen to do it.

to:

@]

September 19, 2007, at 08:00 PM by HN -- scripts works perfectly now
Changed lines 34-37 from:
  1. --- check whether btpd is running ---

[ `ps | grep -i btpd | grep -v grep | wc | cut -b 7-8` -lt 1 ] && `nohup btpd -p $port --ip $ip --bw-in 1200 --bw-out 100 > /dev/null 2> /dev/null &`

to:

bandwidth_out="100" bandwidth_in="1200"

  1. --- check whether btpd is running; it tends to quit every few hours when downloading ---

exec btpd -p $port --ip $ip --bw-in $bandwidth_in --bw-out $bandwidth_out

Added lines 110-111:

-ipkg install bash btpd -make sure you can execute 'wc', otherwise install the newest busybox/coreutils/whatever

September 05, 2007, at 11:57 PM by HN --
Changed line 28 from:

wantedratio="1"

to:

wantedratio="100" # percentage

September 05, 2007, at 11:52 PM by HN --
Changed line 68 from:
 btratio=`echo "$btrest" | cut -d "*" -f 6`
to:
 btratio=`echo "$btrest" | cut -d "*" -f 6 | sed "s/\.//g"`
Changed line 79 from:
  if [ expr -n $btratio ">=" $wantedratio ];
to:
  if [ $btratio -ge $wantedratio ];
Added line 98:
  fi
Deleted line 99:
 fi
Changed line 124 from:

can anyone shed some light on the matter?

to:

can anyone shed some light on the matter? I'm currenly trying to get screen to do it.

September 05, 2007, at 11:05 PM by HN --
Added lines 119-124:

edit: this line still doesn't work if it's executed within the script (when the daemon shuts down due to an error) [ `ps | grep -i btpd | grep -v grep | wc | cut -b 7-8` -lt 1 ] && `nohup btpd -p $port --ip $ip --bw-in 1200 --bw-out 100 > /dev/null 2> /dev/null &`

can anyone shed some light on the matter?

September 05, 2007, at 10:54 PM by HN -- removed my ip ;)
Changed lines 32-34 from:
to:

ip="1.2.3.4" port="2101"

Changed lines 36-37 from:

[ `ps | grep -i btpd | grep -v grep | wc | cut -b 7-8` -lt 1 ] && `nohup btpd -p 2101 --ip 85.145.139.80 --bw-in 1200 --bw-out 100 > /dev/null 2> /dev/null &`

to:

[ `ps | grep -i btpd | grep -v grep | wc | cut -b 7-8` -lt 1 ] && `nohup btpd -p $port --ip $ip --bw-in 1200 --bw-out 100 > /dev/null 2> /dev/null &`

Changed line 106 from:

-copy the above text (and change the directories to whichever you like)

to:

-copy the above text (and change the directories and ip address to whichever you like)

September 05, 2007, at 10:48 PM by HN --
Deleted lines 0-1:

(sorry about the lame layout, someone with wiki skills please edit it)

September 05, 2007, at 10:47 PM by HN --
Changed line 104 from:
to:

[@

Changed lines 116-118 from:

-

to:

-??? -PROFIT @]

September 05, 2007, at 10:46 PM by HN --
Added line 13:

[@

Changed line 18 from:
to:

@]

September 05, 2007, at 10:46 PM by HN --
Changed lines 3-4 from:

Btpd

to:

Btpd

Changed lines 7-8 from:

How to install

to:

How to install

Changed lines 11-12 from:

Contents

to:

Contents

Changed lines 18-19 from:

Advantages & disadvantages

to:

Advantages & disadvantages

Changed lines 22-23 from:

Script

to:

Script

Added lines 102-103:

installation

September 05, 2007, at 10:45 PM by HN -- visual changes
Added lines 3-4:

Btpd

Changed lines 7-8 from:

How to install: ipkg install btpd

to:

How to install

ipkg install btpd

Contents

Added lines 18-19:

Advantages & disadvantages

Changed lines 22-23 from:

I have made the following script for automatic downloading:

to:

Script

I have made the following script for automatic downloading (in my case /root/btpd.sh):

Changed lines 102-103 from:

this script assumes you have something like '*/2 * * * * root /root/btpd.sh &>/dev/null' in your crontab

to:

to run this: -copy the above text (and change the directories to whichever you like) -telnet/ssh into your nslu2, -create the folders (e.g. /public/torrents, /public/torrents/invalid, /public/downloads) -chmod all these folders -go to the desired script directory -type cat > btpd.sh << EOF -paste the script -type EOF -type chmod 555 btpd.sh -type echo '*/2 * * * * root /root/btpd.sh &>/dev/null' >> /etc/crontab -

September 05, 2007, at 10:37 PM by HN --
Changed line 16 from:

{quote}

to:

[@

Changed lines 90-92 from:
to:

@]

September 05, 2007, at 10:36 PM by HN --
Added line 16:

{quote}

September 05, 2007, at 10:35 PM by HN --
Added lines 1-92:

(sorry about the lame layout, someone with wiki skills please edit it)

Btpd is a lightweight bittorrent daemon. It is able to handle multiple torrents in one process.

How to install: ipkg install btpd

Btpd consists of 3 files: -btpd - the daemon -btcli - the command line program to add / remove / stop / start / give stats / list /etc -btinfo - a program designed to show the contents of a .torrent file

btpd can, like enhanced-ctorrent, be combined with a script to automatically start downloading .torrents that are saved in a certain folder. It has the advantage that you don't need screen for monitoring, but on the other hand: there is no webbased control script available (yet).

I have made the following script for automatic downloading:

  1. !/bin/bash
  2. set -x

wantedratio="1" torrentdir="/public/torrents" invaliddir="/public/torrents/invalid" finisheddir="/public/finished_downloads"

  1. --- check whether btpd is running ---

[ `ps | grep -i btpd | grep -v grep | wc | cut -b 7-8` -lt 1 ] && `nohup btpd -p 2101 --ip 85.145.139.80 --bw-in 1200 --bw-out 100 > /dev/null 2> /dev/null &`

  1. --- check for new torrents ---

cd $torrentdir torrentfile=`find . -maxdepth 1 -name "*.torrent" | head -n 1 | cut -d "/" -f 2` if [ "$torrentfile" != "" ]; then

 if [ `btinfo $torrentfile 2> /dev/null | wc | cut -b 4-10` -eq 0 ]; then
  mv "$torrentfile" "$invaliddir"
  Set_Led beep1
  exit
 fi

 newdir=`btinfo $torrentfile | grep Name | sed -e "s/Name: //" | sed -e "s/[/\]/./g" | cut -b 1-40`
 mkdir "$finisheddir/$newdir"
 chmod 777 "$finisheddir/$newdir"
 mv "$torrentfile" "$finisheddir/$newdir"
 cd "$finisheddir/$newdir"
 btcli add -d . $torrentfile
 Set_Led beep2 &
 sleep 1
 killall Set_Led

fi

  1. --- check status ---

btnod=`btcli list | grep % | wc | sed -e 's/ */ /g' | cut -d " " -f 2` for (( i = 1 ; i <= $btnod; i++ )) do

 line=`btcli list | grep % | tr "\n" "\t" | cut -f $i`
 btrest=`echo "$line" | cut -b 43- | sed -e 's/ */\*/g'`

 btname=`echo "$line" | cut -b 1-42 | sed -e 's/   *//g'`
 btnr=`echo "$btrest" | cut -d "*" -f 2`
 btratio=`echo "$btrest" | cut -d "*" -f 6`
 btpct=`echo "$btrest" | cut -d "*" -f 4`
 btdir=`echo "$btname" | sed -e 's/[/\]/./g'`

 cd "$finisheddir/$btdir"*
 if [ $btpct != "100.0%" ];
 then
  [ -e "./ DOWNLOADING.txt" ] && `rm "./ DOWNLOADING.txt"`
  btcli stat $btnr | grep -v DLOAD > "./ DOWNLOADING.txt"
  chmod 777 "./ DOWNLOADING.txt"
 else
  if [ expr -n $btratio ">=" $wantedratio ];
  then
   btcli del $btnr
   [ -e "./ DOWNLOADING.txt" ] && `rm "./ DOWNLOADING.txt"`
   [ -e "./ SEEDING.txt" ] && `rm "./ SEEDING.txt"`
   Set_Led beep3 &
   sleep 1
   killall Set_Led
  else
   if [ -e "./ DOWNLOADING.txt" ]; then
    chmod -R 777 .
    rm "./ DOWNLOADING.txt"
    Set_Led beep2 &
    sleep 1
    killall Set_Led
   fi
   [ -e "./ SEEDING.txt" ] && `rm "./ SEEDING.txt"`
   btcli stat $btnr | grep -v DLOAD > "./ SEEDING.txt"
   chmod 777 "./ SEEDING.txt"
 fi
 fi

done

this script assumes you have something like '*/2 * * * * root /root/btpd.sh &>/dev/null' in your crontab

view · edit · print · history · Last edited by HN.
Based on work by Girish, CR, HN, Tumaini, DAG, Alan, christhenowheremancom, Svennoe, makka, Bram Snip, Adam, hbel, Timer, and Gabriel S Hansen.
Originally by HN.
Page last modified on June 08, 2009, at 02:36 PM