📜 ⬆️ ⬇️

installing rTorrent + wTorrent on Ubuntu 8.10

My home server is enabled 24x7. And at night he stands idle, I wanted to load him with something. Than it is possible to load the home server with the unlimited Internet ≈ clear business torrents. And since the server is on Linux, then the torrent client needs to be searched for the console and with the Web interface.

And my eyes fell on rTorrent + wTorrent. For a long time, Google realized on various Internet sites that most people are trying to raise this link on the Lighty web server (lighttpd), but unfortunately there are no smart manuals for the Apache.
Well, I'll try to write my manual.

so, let's begin

we put the necessary packages
')
apt-get install rtorrent screen apache2 php5-cgi php5-common php5-sqlite php5-xmlrpc sqlite unzip php5-curl

here it should be noted that the rtorrent package for Ubuntu is already compiled with xmlrpc for Debian Etch will have to build itself, or use the version of the package from the testing

So let's set up the rTorrent package. It should be noted that rTorrent should be run from the user account. in my case it was a randomtoy account

in the folder / home / randomtoy create a file .rtorrent.rc with the following content

scgi_port = localhost:5000
min_peers = 40
max_peers = 100
min_peers_seed = 10
max_peers_seed = 50
max_uploads = 15
#upload_rate = 50
directory = /home/randomtoy/torrents/doing
session = /home/randomtoy/torrents/.rtsession/
schedule = watch_directory,5,5,load_start=/home/randomtoy/torrents/watch/*.torrent
schedule = tied_directory,5,5,start_tied=
schedule = untied_directory,5,5,close_untied=
on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/home/randomtoy/torrents/done/ ;d.set_directory=/home/randomtoy/torrents/done/"
on_start = link1,"create_link=tied,,.started"
on_stop = link1,"delete_link=tied,,.started"
on_finished = link1,"create_link=tied,,.finished"
on_erase = link1,"delete_link=tied,,.finished"
schedule = low_diskspace,5,60,close_low_diskspace=100M
#schedule = ratio,60,60,"stop_on_ratio=120,200M,2000"
port_range = 10000-10001
port_random = no
check_hash = yes
use_udp_trackers = yes
encryption = allow_incoming,try_outgoing,enable_retry
dht = auto
dht_port = 63982


immediately create the following directories

torrents
torrents / watch
torrents / doing
torrents / done
torrents / .rtsession

run rtorrent, if there are no errors, continue. Next problem. How to start rtorrent from the user when the system starts?
create rtorrent script with the following contents
#!/bin/bash

### BEGIN INIT INFO
# Provides: rtorrent
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start rtorrent as a daemon
### END INIT INFO

#!/bin/sh
#############
######
#############
# This script depends on screen.
# For the stop function to work, you must set an
# explicit session directory using ABSOLUTE paths (no, ~ is not absolute) 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.
# Licensed under the GPLv2 by lostnihilist: lostnihilist _at_ gmail _dot_ com
##############
######
##############

#######################
##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)
#Do not put a space on either side of the equal signs eg
# user = user
# will not work
# system user to run as
user="randomtoy"

# the system group to run as, not implemented, see d_start for beginning implementation
# group=`id -ng "$user"`

# the full path to the filename where you store your rtorrent configuration
config="/home/randomtoy/.rtorrent.rc"

# set of options to run with
options=""

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

# name of screen session
srnname="rtorrent"

# file to log to (makes for easier debugging if something goes wrong)
logfile="/var/log/rtorrentInit.log"
#######################
PATH=/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
DESC="rtorrent"
NAME=rtorrent
DAEMON=$NAME
SCRIPTNAME=/etc/init.d/$NAME

checkcnfg() {
exists=0
for i in `echo "$PATH" | tr ':' '\n'` ; do
if [ -f $i/$NAME ] ; then
exists=1
break
fi
done
if [ $exists -eq 0 ] ; then
echo "cannot find rtorrent binary in PATH $PATH" | tee -a "$logfile" >&2
exit 3
fi
if ! [ -r "${config}" ] ; then
echo "cannot find readable config ${config}. check that it is there and permissions are appropriate" | tee -a "$logfile" >&2
exit 3
fi
# session=`getsession "$config"`
# if ! [ -d "${session}" ] ; then
# echo "cannot find readable session directory ${session} from config ${config}. check permissions" | tee -a "$logfile" >&2
# exit 3
# fi
}
d_start() {
[ -d "${base}" ] && cd "${base}"
stty stop undef && stty start undef
su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "screen -dm -S ${srnname} 2>&1 1>/dev/null" ${user} | tee -a "$log$
# this works for the screen command, but starting rtorrent below adopts screen session gid
# even if it is not the screen session we started (eg running under an undesirable gid
#su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "sg \"$group\" -c \"screen -fn -dm -S ${srnname} 2>&1 1>/dev/null$
su -c "screen -S "${srnname}" -X screen rtorrent ${options} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
}

d_stop() {
session=`getsession "$config"`
if ! [ -s ${session}/rtorrent.lock ] ; then
return
fi
pid=`cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g"`
if ps -A | grep -sq ${pid}.*rtorrent ; then # make sure the pid doesn't belong to another process
kill -s INT ${pid}
fi
}

getsession() {
session=`awk '/^[[:space:]]*session[[:space:]]*=[[:space:]]*/{print($3)}' "$config"`
echo $session
}

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



copy the script, make it executable and add to autoload

cp rtorrent /etc/init.d

chmod a+x /etc/init.d/rtorrent

update-rc.d rtorrent defaults 25



Now rtorrent will run in screen at system startup.

well and now we start the most tasty, to the web interface. from various webmord I chose based on wTorrent Ajax

Download wTorrent

cd /var/www

rm -f index.html

svn co svn://canbruixa.homelinux.net/repos/trunk/wtorrent/

cd wtorrent

mv * ..

mv .* ..

cd ..

rmdir wtorrent

touch ./db/database.db

chown -R www-data:www-data db torrents tpl_c



Now we have reached the Apache configuration.

we execute in the console
a2enmod scgi_module

in the apache file / etc / apache2 / sites-avaible / default add

SCGIMount /RPC2 127.0.0.1:5000


restart rtorrent and apache
/etc/init.d/rtorrent restart
/etc/init.d/apache2 restart


go to the localhost / install.php page

create an administrator account

go to localhost

voila. wTorrent works

Source: https://habr.com/ru/post/48618/


All Articles