PDA

Bekijk de volledige versie : rTorrent and libTorrent



wrom
01-01-2007, 23:01
Is there rTorrent/libTorrent packets for oleg firmware?
http://libtorrent.rakshasa.no/

And if not, is there any chance to build them?


--
wrom

oleo
01-01-2007, 23:51
The problem is with libsigc++ as it is badly written. Then we have problem with uclibc++. So there is little chance to get the thing working.

oleo
01-02-2007, 11:38
rtorrent is now available. Similary like with amule I have solved this problem with linking against libstdc++ and not with uClibc++. http://trac.nslu2-linux.org/optware/changeset/5371

rtorrent should work as expected. Bear in mind that this is not lightweight app like transmission as it is linked with large c++ library.
libstdc++ is delivered with latest uclibc-opt package.

wrom
01-02-2007, 12:19
rtorrent is now available. Similary like with amule I have solved this problem with linking against libstdc++ and not with uClibc++. http://trac.nslu2-linux.org/optware/changeset/5371

rtorrent should work as expected. Bear in mind that this is not lightweight app like transmission as it is linked with large c++ library.
libstdc++ is delivered with latest uclibc-opt package.

Thanks for your hard work.
I installed uclibc-opt and ipkg-opt with -force-overwrite flag.
Where i can find rtorrent and libtorrent packages?


--
wrom

oleo
01-02-2007, 15:56
Autobuild machine (http://logs.nslu2-linux.org/buildlogs/autobuild-nudi-last.txt) choked on missing reconfigure check. r5376 (http://trac.nslu2-linux.org/optware/changeset/5376) should solve this and you should see rtorrent, libtorrent, and libsigc++ at the top of the oleg package listing (http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/?C=M;O=D) soon.
Sorry for inconvenience.

wrom
01-02-2007, 21:34
Autobuild machine (http://logs.nslu2-linux.org/buildlogs/autobuild-nudi-last.txt) choked on missing reconfigure check. r5376 (http://trac.nslu2-linux.org/optware/changeset/5376) should solve this and you should see rtorrent, libtorrent, and libsigc++ at the top of the oleg package listing (http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/?C=M;O=D) soon.
Sorry for inconvenience.

No harm done, working fine now.
Need to test running it with nice for smoothness.
Another question, why you use unstable version and not stable?:)

--
wrom

oleo
02-02-2007, 08:20
As you see in http://trac.nslu2-linux.org/optware/log/trunk/make/rtorrent.mk I do not maintan the package. Brian takes the care of it. Newer software usually means better software with many things solved. I am running unstable Debian linux for many many years, an I can tell you from experience that this is true.

What we need from You is to add your experience Optware Packages (http://www.nslu2-linux.org/wiki/Optware/Packages) page and maybe some default startup scripts and configs.

wirespot
02-02-2007, 10:25
This is really great news Oleg. :) I can't wait to test it. I'll compare with the load and cpu graphs from transmissiond and let you know how rtorrent makes out.

wrom
02-02-2007, 12:00
As you see in http://trac.nslu2-linux.org/optware/log/trunk/make/rtorrent.mk I do not maintan the package. Brian takes the care of it. Newer software usually means better software with many things solved. I am running unstable Debian linux for many many years, an I can tell you from experience that this is true.

What we need from You is to add your experience Optware Packages (http://www.nslu2-linux.org/wiki/Optware/Packages) page and maybe some default startup scripts and configs.

Ok, I have always preferred stable versions, my experience from linux started about 10 years ago, tough mipsel arch is new for me.

I use rtorrent inside of screen with nice -n 19, working fine for my taste.
It's simple, i just save from other computer over samba .torrent and rtorrent start download it automatic.

--
wrom

wirespot
02-02-2007, 12:20
wrom, what configurations have you done? Can you post the relevant config options in your rtorrent.rc? Have you changed the "tos" option to something other than "throughput"?

How do you make it automatically detect added torrent files? I'm looking at the config options but nothing seems like it does this.

wrom
02-02-2007, 12:37
wrom, what configurations have you done? Can you post the relevant config options in your rtorrent.rc? Have you changed the "tos" option to something other than "throughput"?

How do you make it automatically detect added torrent files? I'm looking at the config options but nothing seems like it does this.

I attached my .rtorrent.rc which is in user home dir.


--
wrom

wrom
02-02-2007, 16:16
I running rtorrent now without nice because download speeds dropped and that's not acceptable. Hardware sets limits how many torrents can downloaded at same time, but i think this working much better than my previous python+bittornado system.


--
wrom

oleo
02-02-2007, 20:03
I have prepared patchlevel 4 (http://trac.nslu2-linux.org/optware/changeset/5397) rtorrent package which include wrom config file and wrote
/opt/bin/rtor script which uses dtach for terminal deattachment. Although this rtor script
uses similar syntax as startup scripts in /opt/etc/init.d

Usage: /opt/bin/rtor (start|stop|restart|attach)
I do not know any program that can be used as terminal emulator at system boot, so that rtorrent can act as daemon to which we can attach. The problem is that rtorrent query many (ncurses) questions about controlling terminal.

Until then use

rtor start
and
rtor attach
restart maybe is not well written, but rtorrent does not have any pidfile or similar daemon functionality.

So no autostart at reboot until solution is found. See ticket #23 (http://libtorrent.rakshasa.no/ticket/23).

Jeremia
08-02-2007, 22:39
Hi oleo,

your rtor script works like a charm, but i have a little problem with it.

After


rtor start
rtor attach

I'm in the rtorrent gui. But somehow the keys are not the same as they where if I start rtorrent manually without your script. The arrow keys can now used to change dl/ul speed instead of showing torrent details. For torrent details I have to press ctrl+right_arrow instead of pressing only right_arrow. I don't know why, but this happens not if I start your Script and attach rtorrent in one command


rtor start && rtor attach

After that everything is fine.
So I altered the Line in your script from:


dtach -n ${RTORRENT_SOCKET} rtorrent -n -o import=${RTORRENT_CONF}


to:


dtach -n ${RTORRENT_SOCKET} rtorrent -n -o import=${RTORRENT_CONF} && rtor attach


There is surely a better way, but for the moment it works.

Thanks for the great work on rtorrent.

Greetz Jeremia

Sean
09-02-2007, 00:10
I m sorry, but can someone write how can i install extra packages for use my WL500g.Deluxe as a bittorrent client? :confused:

al37919
19-05-2007, 12:50
There is a script which can be used to run rTorrent on system startup suggested here: http://libtorrent.rakshasa.no/wiki/RTorrentCommonTasks

So, I have slightly modified it and put in /opt/etc/init.d/S99rtorrent
It starts rtorrent as user p2p with configuration file located in /opt/etc/rtorrent.conf and working directory /opt/share/torrent


# !/bin/sh
#############
###<Notes>###
#############
# This script depends on screen.
# For the stop function to work, you must set an
# explicit session directory using absolute paths in your rtorrent.rc.
# If you typically just start rtorrent with just "rtorrent" on the
# command line, all you need to change is the "user" option.
# Attach to the screen session as your user with
# "screen -dr rtorrent". Change "rtorrent" with srnname option.
##############
###</Notes>###
##############


#######################
##Start Configuration##
#######################
# You can specify your configuration in a different file
# (so that it is saved with upgrades, saved in your home directory,
# or whateve reason you want to)
# by commenting out/deleting the configuration lines and placing them
# in a text file (say /home/user/.rtorrent.init.conf) exactly as you would
# have written them here (you can leave the comments if you desire
# and then uncommenting the following line correcting the path/filename
# for the one you used. note the space after the ".".
# . /etc/rtorrent.init.conf


#Do not put a space on either side of the equal signs e.g.
# user = user
# will not work
# system user to run as (can only use one)
user="p2p"

# the full path to the filename where you store your rtorrent configuration
# must keep parentheses around the entire statement, quotations around each config file
#config=("/home/${user}/.rtorrent.rc")
config=("/opt/etc/rtorrent.conf")
# Examples:
# config=("/home/user/.rtorrent.rc")
# config=("/home/user/.rtorrent.rc" "/mnt/some/drive/.rtorrent2.rc")
# config=("/home/user/.rtorrent.rc"
# "/mnt/some/drive/.rtorrent2.rc"
# "/mnt/another/drive/.rtorrent3.rc")

# set of options to run with each instance, separated by a new line
# must keep parentheses around the entire statement
#if no special options, specify with: ""
options=("-n -o import=/opt/etc/rtorrent.conf")
# Examples:
# starts one instance, sourcing both .rtorrent.rc and .rtorrent2.rc
# options=("-o import=~/.rtorrent2.rc")
# starts two instances, ignoring .rtorrent.rc for both, and using
# .rtorrent2.rc for the first, and .rtorrent3.rc for the second
# we do not check for valid options
# options=("-n -o import=~/.rtorrent2.rc" "-n -o import=~/rtorrent3.rc")

# default directory for screen, needs to be an absolute path
#base="/home/${user}"
base="/opt/share/torrent"

# name of screen session
srnname="rtorrent"
#######################
###END CONFIGURATION###
#######################
PATH=/opt/local/bin:/opt/sbin:/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="rtorrent"
NAME=rtorrent
DAEMON=/opt/bin/$NAME
SCRIPTNAME=/opt/etc/init.d/S99rtorrent

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

checkcnfg() {
for (( i=0 ; i < ${#config[@]} ; i++ )) ; do
if ! [ -r "${config[i]}" ] ; then
echo "cannot find readable config ${config[i]}. check that it is there and permissions are appropriate">&2
exit 3
fi
session=$(cat "${config[i]}" | grep "^[[:space:]]*session" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//")
if ! [ -d "${session}" ] ; then
echo "cannot find readable session directory ${session} from config ${config[i]}. check permissions">&2
exit 3
fi
done
}

d_start() {
logger "Starting."
[ -d "${base}" ] && cd "${base}"
stty stop undef && stty start undef
su -c "screen -ls | grep "\.${srnname}[[:space:]]" > /dev/null" ${user} || su -c "screen -dm -S ${srnname}" ${user}
for (( i=0 ; i < ${#options[@]} ; i++ )) ; do
sleep 3
su -c "screen -S "${srnname}" -X screen rtorrent ${options[i]}" ${user}
done
}

d_stop() {
for (( i=0 ; i < ${#config[@]} ; i++ )) ; do
session=$(cat "${config[i]}" | grep "^[[:space:]]*session" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//")
pid=$(cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g")
# make sure the pid doesn't belong to another process
# skip the pid otherwise
if ps -A | grep ${pid}.*rtorrent > /dev/null ; then
kill -s INT ${pid}
fi
done
}

checkcnfg

case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0

oleo
21-05-2007, 11:52
Included into optware with http://trac.nslu2-linux.org/optware/changeset/6061

Please report any problems with script here!

Pim Borst
01-10-2007, 14:32
Cool to hear rtorrent has been packaged!

Any chance the DHT patch could be included in the package?
See: http://tk.ttdpatch.net/~jdrexler/dht/
This will give trackerless torrents functionality.

thanks,
Pim.

al37919
23-10-2007, 16:45
here is updated version of S99rtorrent:

It is a little simplified, so that is it uses only one configuration file and only one line with options. Now it conforms to /bin/sh sintaxis and works reliably during startup.

UPDATE 1/2008: I keep this script for historic reference only, as current version of S99rtorrent included in the optware package has even better S99rtorrent. However, the microhowto below applies also to a new standard version.


#! /bin/sh

# This script depends on screen.
# For the stop function to work, you must set an
# explicit session directory using absolute paths in your rtorrent.rc.
# If you typically just start rtorrent with just "rtorrent" on the
# command line, all you need to change is the "user" option.
# Attach to the screen session as your user with
# "screen -dr rtorrent". Change "rtorrent" with srnname option.
# See http://libtorrent.rakshasa.no/wiki/RTorrentCommonTasks

# Do not proceed unless some apps are available.

test -x /opt/bin/screen || exit 0
test -x /opt/bin/su -o -x /bin/su || exit 0

#######################
##Start Configuration##
#######################
# You can specify your configuration in a different file
# (so that it is saved with upgrades, saved in your home directory,
# or whateve reason you want to)
# by commenting out/deleting the configuration lines and placing them
# in a text file (say /home/user/.rtorrent.init.conf) exactly as you would
# have written them here (you can leave the comments if you desire
# and then uncommenting the following line correcting the path/filename
# for the one you used. note the space after the ".".
# . /etc/rtorrent.init.conf


#Do not put a space on either side of the equal signs e.g.
# user = user
# will not work
# system user to run as (can only use one)
# Add this user to /etc/passwd
user="p2p"

# the full path to the filename where you store your rtorrent configuration
# must keep parentheses around the entire statement, quotations around each config file
#config="/home/${user}/.rtorrent.rc"
config="/opt/home/${user}/.rtorrent.rc"
#config="/opt/etc/rtorrent.conf"

# Examples:
# config="/home/user/.rtorrent.rc"

# set of options to run with each instance
# if no special options, specify with: ""

# if rtorrent is started without options it will read it's config from ~/.rtorrent.rc
options=""

# Examples:
# starts one instance, sourcing both .rtorrent.rc and .rtorrent2.rc
# options="-o import=~/.rtorrent2.rc"
# starts two instances, ignoring .rtorrent.rc for both, and using
# .rtorrent2.rc for the first, and .rtorrent3.rc for the second
# we do not check for valid options
# options="-n -o import=~/.rtorrent2.rc" "-n -o import=~/rtorrent3.rc"
#options="-n -o import=/opt/etc/rtorrent.conf"

# default directory for screen, needs to be an absolute path
#base="/home/${user}"
base="/opt/home/torrent"

# name of screen session
srnname="rtorrent"
#######################
###END CONFIGURATION###
#######################
PATH=/opt/local/bin:/opt/sbin:/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="rtorrent"
NAME=rtorrent
DAEMON=/opt/bin/$NAME
SCRIPTNAME=/opt/etc/init.d/S99rtorrent

# Gracefully exit if the package has been removed.
test -x $DAEMON || (logger -t rtorrent "no daemon" && exit 0)

checkcnfg() {
if ! [ -r "${config}" ] ; then
logger -t rtorrent "cannot find readable config ${config}. check that it is there and permissions are appropriate"
exit 3
fi
session=$(awk '/^[[:space:]]*session[[:space:]]*=[[:space:]]*/{print($3)}' "${config}")
if ! [ -d "${session}" ] ; then
logger -t rtorrent "cannot find readable session directory ${session} from config ${config}. check permissions"
exit 3
fi
}

d_start() {
[ -d "${base}" ] && cd "${base}"
stty stop undef && stty start undef
su -c "screen -ls | grep ".${srnname}[[:space:]]" > /dev/null" ${user} || su -c "screen -dm -S ${srnname}" ${user}
sleep 3
su -c "screen -S "${srnname}" -X screen rtorrent ${options}" ${user}
su -c "screen -S "${srnname}" -p 0 -X kill" ${user}
logger -t rtorrent "started."
}

d_stop() {
session=$(awk '/^[[:space:]]*session[[:space:]]*=[[:space:]]*/{print($3)}' "${config}")
pid=$(cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g")
# make sure the pid doesn't belong to another process
# skip the pid otherwise
grep rtorrent /proc/${pid}/cmdline > /dev/null && kill -s INT ${pid}
sleep 6s
logger -t rtorrent "stopped."
}

checkcnfg

case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0

Here is a short instruction how to use rtorrent by user another than root.

1) Create user:

adduser p2p
If necessary:

ipkg install adduser

2) Add the following lines to ~/.profile:

alias rt='su -c "screen -r" p2p'
chmod a+rw `tty`
stty start undef
stty stop undef

tty is unfortunately also a part of coreutils :( However,. Oleg included it already in the next version of his fw (after preview 8.8)

Don't forget to save changes:

flashfs save && flashfs commit && flashfs enable && reboot

3) This utility requires to have installed: screen

ipkg install screen
and su. With su current situation is more complicated. The latest Oleg's firmware (1.9.2.7-8.7) includes /bin/su , so nothing have to be done. However if you have earlier version then su has to be installed. It is a part of adduser and coreutils packages.

4) Create configuration file in the p2p's user home directory ( ~/.rtorrent.rc ) based on /opt/home/rtorrent.conf

5) set correct ownership and permissions on the rtorrent working directories depending on which directories are written in ~/.rtorrent.rc file

chown -R p2p:p2p /opt/share/torrent/work
chown -R p2p:p2p /opt/share/torrent/session
chown -R p2p:p2p /opt/share/torrent/dl

6) when you want to attach to it use:

rt

P.S. This script has 1 small bug/feature. An extra screen window with /bin/sh is started which can be afterwards exited manually. Up to now nobody knows how to eliminate it :(

suleyma
01-11-2007, 19:50
Please accept my apologies for my English...

My ps command hasn't any options.

[admin@suleyma root]$ ps -?
ps: illegal option -- ?
BusyBox v1.1.3 (2007.01.01-14:37+0000) multi-call binary

Usage: ps

wirespot
01-11-2007, 20:04
That's the default ps that comes with the firmware, and is embedded in the flash. Install the procps package (ipkg install procps) to get a better ps.

If S99rtorrent uses ps with arguments it's a bit of an oversight. It should test what kind of ps it's dealing with. If the advanced ps becomes a requirement, the rtorrent package would have to require (or at least recommend) the procps package. Which would be a bit silly.

al37919, you don't need ps -A for that if block in your script. You can do this instead:


grep rtorrent /proc/${pid}/cmdline && \
kill -s INT ${pid}

suleyma
01-11-2007, 20:52
I've installed procps.

There is a mention of procps by wengi:http://wl500g.info/showthread.php?t=10307&highlight=rc.unslung&page=4


Cron must be in the process list (ps) after a reboot.
Remark: If you installed procps you should execute:
: ps axf


Thanks for your quick response.

wirespot
01-11-2007, 20:58
It's just that I've had my WL-500g for quite a while now and so far I've haven't felt the need for the advanced ps. Installing it just for a ps -A, which can be accomplished in a more efficient manner anyway, is a bit overkill.

suleyma
01-11-2007, 22:33
I think I quite agree with you.
Look below where a short instruction how to use rtorrent by user another than root.
What do you think about:

ipkg install coreutils

I've done it.

al37919
02-11-2007, 16:12
Thanks for the comemnts. I changed the script posted above so that now it explicitly uses busybox's /bin/ps. So, there is no need now to install procps package, other than ps in it is much nicer than the standard one :)

I agree that coreutils is a big package, that should be installed here only to be able to use su. However, su is required to be able to start rtorrent as non-root user, and it is not included in our version of busybox. May be we can ask Oleg to include it in the future releases...

suleyma
02-11-2007, 19:23
You dont't need install coreutils for su.
It's enough to install adduser.
I've removed coreutils now and reinstall adduser - su is working (executing).

It seems: ipkg -force-reinstall install adduser

To be on the safe side, after executed ipkg remove coreutils, I've reinstalled all installed packages by one line awk script taken somewhere from the Forum:

/usr/bin/awk '/^Package:/{system("/opt/bin/ipkg install -force-reinstall -force-defaults " $2)}' /opt/lib/ipkg/status

But now I have next records in my /opt/var/log/messages:

Nov 2 16:00:40 admin: Starting.
Nov 2 16:00:40 su: + none admin:p2p
Nov 2 16:00:40 su: + none admin:p2p
Nov 2 16:00:43 su: + none admin:p2p
I think that is result executing this code:

for (( i=0 ; i < ${#options[@]} ; i++ )) ; do
sleep 3
su -c "screen -S "${srnname}" -X screen rtorrent ${options[i]}" ${user}
done

But the same was before install coreutils...

Pulver
25-11-2007, 19:41
Anyone tried nTorrent (http://code.google.com/p/ntorrent/) accessing rTorrent on a Oleg Asus router ?

Would be pretty nice if it worked :)

Its not a web-gui, but still...

Edit:

Also found wTorrent (http://canbruixa.homelinux.net/wt/) - web-gui for rTorrent, anyone tried that ?

wirespot
25-11-2007, 21:32
I plan to test it as soon as possible. Of course, it depends on whether Oleg compiled rtorrent with --with-xmlrpc-c. Sure, I can compile my own and still test it, but for mass use it will still have to have it.

The entire XMLRPC support thingy is very interesting and I'm glad there are finally applications using it. Controlling rtorrent remotely would be the final bit of goodness.

Some more info:
http://rakshasa.no/pipermail/libtorrent-devel/2007-May/001154.html

LE: sorry, no XMLRPC support compiled in.

al37919
25-11-2007, 23:46
last version in repository has been compiled with xmlrpc support

wirespot
25-11-2007, 23:50
Ah, sorry then, I must be late upgrading.

BTW, don't try setting the scgi_port option with older rtorrent builds, you'll crash them.

Pulver
03-12-2007, 15:40
Any success wirespot ?

I tried this today using the lighttpd (http://wl500g.info/showthread.php?t=5247) guide on this page.

After i got lighttpd running I tride the wtorrent script - but only got as far as the login-page.

Then I tried a (simpler) rtorrent web-gui called rTWi (http://projects.cyla.homeip.net/rtwi/) - but i could not get passed the login-page on that one either.

(some kind of user-problem right ?)

But I can feel that I am really close ;)

I even tried nTorrent - but I get an error saying "The SFTP Subsystem could not be initialized" when I connect.

Can anyone share success-stories ? :)

wirespot
03-12-2007, 15:51
Well I tried something simpler. I checked that rtorrent is indeed listening on the IP and port I told it to, then I connected to that with telnet. And it doesn't do a thing, the connection dies right away.

I also tried to set up an Apache /RPC2 gateway to the router, using the Apache on my desktop machine. I figured it's better to use a full grown machine for that. But it keeps throwing 500 Server Error.

Finally, nTorrent refused to start on my machine, apparently it doesn't like my Java version.

The next step would be to install the xmlrpc command line tool on my desktop machine and try to connect with that, see if it works any better.

But I'm not in any hurry. For the time being I got rtorrent working in screen, I got it to load when the router starts or reboots, I got it to die nicely when the router goes down, I connect to the regular interface with ssh, I've setup an autoload directory and a session directory and so on. So a remote interface is not really that much of a requirement for me at this moment. I'd just as soon better write a small tutorial for setting up rtorrent itself just like I did.

Pulver
03-12-2007, 16:09
A guide sounds fantastic :)

I personally think that most Asus users would switch from transmission to rtorrent if there were a simple guide for it.

I so much better ;)

Just to check - have you added:


scgi_port = localhost:5000

To your .rtorrent.rc ?

Without that line rtorrent does not listen for connections with xmlrpc at all.

al37919
03-12-2007, 16:49
I got it to die nicely when the router goes down

This is of interest to me, could you share your experience, pls.

wirespot
03-12-2007, 16:49
Pulver: Yes, of course. I also checked with 'netstat -tlnp' that rtorrent is actually listening on that port.

A remote interface can be useful, especially a Web interface, in some circumstances. But it may never be as complete and easy to use as rtorrent itself. And there are multiple advantages to rtorrent running in screen over ssh: the connection will only eat up a few KB/s, it will respond promptly, it won't need additional resources over what rtorent already consumes and so on.

I'll admit at some point I was loving transmission and didn't like the idea of rtorrent, but nowadays I'm surprised to see I've changed my mind completely.

al: edit /usr/local/sbin/pre-shutdown, put this in it:
#!/bin/sh
/bin/kill -INT $(/bin/pidof rtorrent) Make sure pre-shutdown is executable.

Also, you need to set a session directory (session = dir) in rtorrent.rc, rehash all the torrents at least once, and restart rtorrent, for the data to enter the session files.

But to be frank I've had mixed results so far. If I kill -INT rtorrent from the command line it works as expected, when I restart it the hash will jump to 100% and download will resume immediately. But it doesn't work like that with pre-shutdown. I believe rtorrent needs a few seconds to actually dump the session data, and the router reboots before that. So try this intead (untested yet):


#!/bin/sh
/bin/kill -INT $(/bin/pidof rtorrent) &
/bin/sleep 10

Try with bigger sleep intervals as well, although I read somewhere that about 5 seconds should be enough for rtorrent to do its thing.

Of course, remember to do 'flashfs save && flashfs commit' to save pre-shutdown to flash!

The idea is that when I modify something in the config and need to restart the router I shouldn't have to rehash anything in rtorrent, just resume smoothly where it left off.

Pulver
04-12-2007, 09:46
A remote interface can be useful, especially a Web interface, in some circumstances. But it may never be as complete and easy to use as rtorrent itself. And there are multiple advantages to rtorrent running in screen over ssh: the connection will only eat up a few KB/s, it will respond promptly, it won't need additional resources over what rtorent already consumes and so on.


Yes, connection to rtorrent over ssh is really nice.

However, one thing I miss is the function to upload a torrent - direct download in rtorrent is not working with many (most) trackers.

A web-gui is also nice for places where you dont have access to ssh, such as internet coffeeshops etc.

al37919
04-12-2007, 10:19
Thanks for the info. According to http://libtorrent.rakshasa.no/wiki/RTorrentUserGuide

SIGINT Normal shutdown with 5 seconds to send the stopped request to trackers.
SIGTERM Shut down immediately.

So, these five seconds have a fundamental background.

wirespot
04-12-2007, 13:55
That must be it. I've tested with sleep added to pre-shutdown and now it works as intended, so that did the trick.

Pulver, for uploading torrents I've set up vsftpd and told rtorrent to watch the upload directory for files.

But you are right that there are cases where it's nicer to simply use a web browser. Not that I'd enter any private passwords in an Internet cafe computer, mind you.

BTW, here's a screenshot of rtorrent as seen over ssh, via putty running on a Nec MobilePro 900c handheld, over wireless. Gadget to gadget, so to speak. :cool:

al37919
04-12-2007, 14:53
you don't even need to open your ftp to outside, because you can transfer files through ssh also using scp or sftp protocol. Command line tools are included in putty distribution, as gui you can use, e.g. Far + WinSCP plugin

wirespot
04-12-2007, 14:56
Very true. I forgot to mention that the reason I use ftp is that it's only open for the LAN. And ftp doesn't consume so much CPU like sftp or scp, which can be a factor when transferring larger files. But for torrent files it should be fine.

wirespot
07-07-2008, 00:13
Just a quick update: mancub has written a tutorial for setting up XMLRPC in lighttpd and using that with rTorrent and a GUI of your choice:
http://www.wl500g.info/showthread.php?t=12110

There are several GUI's, google for "rtorrent gui" or see the wikipedia page. I use rtGui on my desktop machine, I've set it to connect to lighttpd on the router over LAN. It allows you to add torrent files too! But you'll need a webserver on your desktop too for rtGui (I run Linux on the desktop as well so it wasn't much of a problem). I have no idea how well rtGui runs on a webserver installed on Windows.

So, now I have rtorrent with XMLRPC connected to lighttpd, both on the router, and the GUI on the desktop, which makes sense, because usually these clients are based on PHP or other stuff that is too heavy for the router.

The only problem left for me now is to figure out how to obtain a simple lightweight command line xmlrpc client. The xmlrpc-c package apparently has only the library. The purpose is to be able to query rtorrent for total bytes transferred up/down from a shell script and input that data into RRDTool. I already got graphs going that show total bytes transferred in/out of the route, it would be very interesting to be able to see how much of that is P2P.

wirespot
09-07-2008, 02:30
I couldn't compile the xmlrpc client from the xmlrpc-c source package, got all kinds of errors until I gave up. Another possibility was to write a client in PHP but it runs slow as hell; plus PHP on the Asus doesn't have xmlrpc libs and I'd have to use all kinds of third party libs and it gets really annoying.

So the hell with all the xmlrpc crap. I figured out what lighttpd expects to receive at the special "/RPC2" url you set up (see mancub's tutorial). Which is this:


<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>d.multicall</methodName>
<params>
<param>
<value>
<string>main</string>
</value>
</param>
<param>
<value>
<string>d.get_down_total=</string>
</value>
</param>
<param>
<value>
<string>d.get_up_total=</string>
</value>
</param>
</params>
</methodCall>

To make use of it, you put it in a file, let's call it "post.txt" then you can simply use wget (ipkg install wget) like this:


wget -T10 -q --no-check-certificate --post-data=post.txt -O - http://localhost/RPC2

Replace localhost/RPC2 with the address you've set up your lighttpd with. -T10 means to timeout after 10 seconds. -q means to be quiet (no progress bar). --no-check-certificate is useful if your lighttpd uses SSL. --post-data tells wget where to get the stuff above. -O - means to output what it gets back on the console, so you can pipe it to something else, replace - with a file name if you like that better.

This is what wget should return if everything was set up properly:


<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param><value><array><data>
<value><array><data>
<value><i8>4271258199</i8></value>
<value><i8>1437056179</i8></value>
</data></array></value>
<value><array><data>
<value><i8>4271258199</i8></value>
<value><i8>1437056179</i8></value>
</data></array></value>
<value><array><data>
<value><i8>4271258199</i8></value>
<value><i8>1437056179</i8></value>
</data></array></value>
<value><array><data>
<value><i8>4271258199</i8></value>
<value><i8>1437056179</i8></value>
</data></array></value>
</data></array></value></param>
</params>
</methodResponse>

Obviously, the values will be different each time you do this. But you'll notice that all four value sets are identical, so you can use only the first set. I dunno why rtorrent does that but I had 4 torrents running so it may be that.

Don't worry, the values you get this way are good. I've checked against the overall WLAN transfer numbers and against the limits I've set in rtorrent, and they match.

So, all you need to do next is use shell commands to extract those two values from there, then you can use them with rrdtool or whatever.

If anybody has some cool sed or awk magic they can use to extract them, please tell us. For now, all I've been able to come up with is this:


wget bla bla bla |\
grep i8|sed 's/[^0-9]//g'|tr '[:space:]' ' '|awk '{print $1":"$2}'

This will print the numbers separated by colons, good to be sent directly to rrdtool. If you want something else adjust as needed.

What happens here: I select only the lines with "i8" on them, 'cause I know they have the numbers. Then I strip everything but the digits. Then I put everything on the same line. Then I extract the first and second things on the line.

dclagoa
14-08-2008, 11:13
P.S. This script has 1 small bug/feature. An extra screen window with /bin/sh is started which can be afterwards exited manually. Up to now nobody knows how to eliminate it :(

Hey, al37919, when you do "screen -S rtorrent -X screen rtorrent" what you're doing is creating a new screen window window with the rtorrent program running on it. There is window #0 and then you are creating window #1 with rtorrent attached. If you want to get rid of that extra window (window #0), you can do two things:

1) Send an stuff command to screen, with rtorrent and the carriage return code (Control-M). With -p 0 you select the window #0 and stuff sends the parameter string to that window:


screen -S rtorrent -p 0 -X stuff 'rtorrent^M'

2) Send the kill command to the same window:


screen -S rtorrent -p 0 -X kill

The second command can also be used to kill the window after rtorrent exits, if you want to.

al37919
13-10-2008, 17:16
Hi! Thanks for the advice, I've somehow missed this message. Now I tested both possibilities:

Thing #1 unfortunately is not completely effective. Using it we really have only single window #0 in the session, however the junk /bin/sh process is still sitting in the 'ps aux' output. Killing of this /bin/sh naturally kills both rtorrent and screen.

Thing #2 seems to solve the issue. If we add it at the end of the d_start() function we get rtorrent started without annoying process in the memory. Exiting of the rtorrent results in termination of teh screen session.

Thanks a lot again,
al