Mittwoch, 2. Juli 2008
webgui status rtorrent over cgi
http://www.g-loaded.eu/2007/06/23/rtorstat-a-simple-rtorrent-status-web-page-generator/
1) to get it run
edit rtorstat.py and get rid of this:
Requirement
try:
from bencode import bdecode
except ImportError:
try:
from BitTorrent.bencode import bdecode
except ImportError:
sys.stderr.write("%s: ERROR: Missing dependency\nbencode.py was not found in current directory or in local BitTorrent Client (Mainline) installation.\n" % sys.argv[0])
sys.stderr.flush()
sys.exit(1)
download somewhere from the web "bencode.py" file and JUST paste it where the previouys lines above were....
2) access over the your installation
place 3 files in your cgi-bin (/usr/lib/cgi-bin/) : rtorstat.py, rtorstat.cgi and bencode.py.
Now, you can visit the web page http://yourdomain.example.org/cgi-bin/rtorstat.cgi
Samstag, 26. Januar 2008
rtorrent+TOR+Windows= bittorrent fun on the easy and save way
Reboot the system (
a) mount on your windows the BOX over samba
Do it this way in windows explorer
Tools -> map Network drive and assign a drive letter to the samba share (quite handy)
Browse into the boxuser folder
Then
b) drop the the torrent trackr files (*.torrent) into the folder called torrents
c) as soon as the torrent is finished it apears in the finished folder
you can the copy and delete from your windooze machine whatever you want
- To see the performance of your torrent download, log with putty or similar into the box and call
screen –r
to exit without destroing the downloads do: Ctrl A D
in the .rtorrent.rc you can change
- the bandwith used on a daily schedule
- if the torrents can not connect to the tracker: uncomment the last line
Torrent client
Install rtorrent (really really great app)
sudo apt-get install rtorrent
# This is an example resource file for rTorrent. Copy to
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.
# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
#max_peers = 100
# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
#max_peers_seed = 50
# Maximum number of simultanious uploads per torrent.
max_uploads = 1
# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 0
upload_rate = 5
# downlad rate higher at night
schedule = throttle_1,01:00:00,23:00:00,download_rate=0
schedule = throttle_2,08:00:00,23:00:00,download_rate=40
# Default directory to save the downloaded torrents.
directory = /home/mybox/torrents/
# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
#session = ./session
session = /home/mybox/session
# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=/home/mybox/torrents/*.torrent
schedule = untied_directory,5,5,stop_untied=/home/mybox/stopped/
# When the torrent finishes, it executes "mv -n~/Download/" mybox
# and then sets the destination directory to "~/Download/". (0.7.7+)
#on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,~/Download/ ;d.set_directory=~/Download/"
on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/home//finished/ ;d.set_directory=/home/ mybox/finished/"
# Close torrents when diskspace is low.
schedule = low_diskspace,5,60,close_low_diskspace=10M
# Stop torrents when reaching upload ratio in percent,
# when also reaching total upload in bytes, or when
# reaching final upload ratio in percent.
# example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0
# schedule = ratio,60,60,stop_on_ratio=200,200M,2000
schedule = ratio,60,60,"stop_on_ratio=2,2M,20"
# The ip address reported to the tracker.
#ip = 127.0.0.1
#ip = rakshasa.no
# The ip address the listening socket and outgoing connections is
# bound to.
#bind = 127.0.0.1
#bind = rakshasa.no
#bind = 127.0.0.1
# Port range to use for listening.
#port_range = 6890-6999
port_range = 62000-64000
# Start opening ports at a random position within the port range.
#port_random = no
port_random = yes
# Check hash for hed torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
#check_hash = no
# Set whetever the client should try to connect to UDP trackers.
use_udp_trackers = yes
# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa
# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
#
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
#
# encryption = allow_incoming,enable_retry,prefer_plaintext
#
# Do not modify the following parameters unless you know what you're doing.
#
# Hash read-ahead controls how many MB to request the kernel to read
# ahead. If the value is too low the disk may not be fully utilized,
# while if too high the kernel might not be able to keep the read
# pages in memory thus end up trashing.
#hash_read_ahead = 10
# Interval between attempts to check the hash, in milliseconds.
#hash_interval = 100
# Number of attempts to check the hash while using the mincore status,
# before forcing. Overworked systems might need lower values to get a
# decent hash checking rate.
#hash_max_tries = 10
# Max number of files to keep open simultaniously.
#max_open_files = 128
# Number of sockets to simultaneously keep open.
#max_open_sockets =
# Example of scheduling commands: Switch between two ip's every 5
# seconds.
#schedule = "ip_tick1,5,10,ip=torretta"
#schedule = "ip_tick2,10,10,ip=lampedusa"
# Remove a scheduled event.
#schedule_remove = "ip_tick1"
#TOR & Privoxy proxy
http_proxy = http://127.0.0.1:8118/
in /home/boxuser, rename it to: .rtorrent.rc
to activate rtorrent on startup
copy this filecontent
#! /bin/bash
#############
###
#############
# 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.
##############
###
##############
#######################
##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=mybox
# 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")
# 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=("")
# 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}"
# name of screen session
srnname="rtorrent"
#######################
###END CONFIGURATION###
#######################
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="rtorrent"
NAME=rtorrent
DAEMON=/usr/bin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
# 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() {
[ -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
from wherever to
make sure that
ls -l /etc/init.d/rtorrent
returns
-rwxr-xr-x 1 root root 3000 2007-03-06 22:40 /etc/init.d/rtorrent
next do
sudo update-rc.d rtorrent defaults
then restart the beauty
sudo /etc/init.d/rtorrent start