NSLU2-Linux
view · edit · print · history

How to install CTorrent on OpenSlug:

Using ipkg to install CTorrent:

 
ipkg install ctorrent

If you are behind a firewall, you need to open at least port 2706 TCP incoming. CTorrent starts trying port 2706, and if it fails it starts counting downwards towards 2106 TCP.

You might want to install screen (ipkg install screen), so that you can run ctorrent in a screen session:

 
@@screen -dmS torrent ctorrent <torrentfile>@@

CTorrent uses quite a bit of memory (Currently, it's using about 58% on my slug), so you might run into problems if you run a lot of services on your slug.

The memory usage is adjustable with -C. The default cache size is 16MB, which explains the high mem usage. In the script below, it's changed to 4MB which is no problem for most slugs. Feel free to change it ;-)

Below is the script I use to automatically download torrents I save on a share: This script is run as a cron-job every now and then.

I start it as a screen session with "*/2 * * * * screen -dmS torrent /path/to/script"

It's not advanced, and doesn't check much for errors. Feel free to update it a bit ;-)

It doesn't handle filenames with spaces/special chars. You'll need mailx and ssmtp for it to be able to send mail

 
#!/bin/sh
set -x
TORRENTDIR="/path/to/share"
WORKDIR="/path/to/temporary/dir"
FINISHED_DIR="/where/to/put/stuff/when/finished/"
SEED_TIME="1"   # Seed for X hours after finishing
MAIL="your@mail.address"
MAX_KB="40"      # Limit bandwidth usage to 40KB/s
MAX_CON="200"    # Limit maximum connections to 200
CACHE_SIZE="4"   # Cache size 4MB instead of the default 16MB

cd $TORRENTDIR
[ -e $TORRENTDIR/Working.txt ] && exit
TORRENTFILE=`find . -maxdepth 1 -name "*.torrent" | head -n 1 | cut -d "/" -f 2`
[ "$TORRENTFILE" = "" ] && exit
mv "$TORRENTFILE" $WORKDIR
cd $WORKDIR
echo | mail -s "Torrent started: $TORRENTFILE" $MAIL
echo $TORRENTFILE > $TORRENTDIR/Working.txt
ctorrent -C $CACHE_SIZE -B $MAX_KB -M $MAX_CON -e $SEED_TIME "$TORRENTFILE"
mv $WORKDIR/* $FINISHED_DIR/
echo | mail -s "Torrent finished: $TORRENTFILE" $MAIL
rm $TORRENTDIR/Working.txt


My ctorrent was getting killed because it was hogging all the memory. Solution: add swap. http://www.nslu2-linux.org/wiki/HowTo/AddAdditionalSwapSpace
--
-Stein

view · edit · print · history · Last edited by Miikka.
Based on work by Stein, Eiffel, tman, and repvik.
Originally by repvik.
Page last modified on December 06, 2007, at 03:42 PM