Problem using rtorrent + rutorrent for multiple user

randac56

Member
May 25, 2018
915
0
16
Hi everyone,

I've just finished install my server with rtorrent + rutorrent, but I have actually a little problem with multiple user usage.

So, for now I have 2 users we will call USER1 and USER2.

Dirs for both users :
/home/USER1/rtorrent/
ls -a -l
drwxr-xr-x 4 root root 4096 Apr 21 12:46 download
drwxr-xr-x 2 root root 4096 Apr 21 14:19 .session
drwxr-xr-x 2 root root 4096 Apr 20 16:38 watch
and
/home/USER2/rtorrent/
ls -a -l
drwxr-xr-x 6 root root 4096 Apr 22 06:56 download
drwxr-xr-x 2 root root 4096 Apr 22 07:24 .session
drwxr-xr-x 2 root root 4096 Apr 21 09:29 watch

.rtorrent.rc file :
/home/USER1/
Code:
[...]

# Default directory to save the downloaded torrents.
directory = /home/USER1/rtorrent/download

# Default session directory. Make sure you don't run multiple instance
# of seeder1rent using the same session directory. Perhaps using a
# relative path?
session = /home/USER1/rtorrent/.session

# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=/home/USER1/rtorrent/watch/*.torrent
schedule = untied_directory,5,5,stop_untied=

# Close torrents when diskspace is low. */
schedule = low_diskspace,5,60,close_low_diskspace=100M

# 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


# When the torrent finishes, it executes "mv -n <base_path> ~/Download/"
# and then sets the destination directory to "~/Download/". (0.7.7+)
# on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/home/USER1/download/complete/ ;d.set_directory=/home/USER1/download/complete/"

# 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

# Port range to use for listening.
port_range = 55995-56000

# Start opening ports at a random position within the port range.
#port_random = yes

scgi_port = 127.0.0.1:5000

[...]

/home/USER2/
Code:
[...]

# Default directory to save the downloaded torrents.
directory = /home/USER2/rtorrent/download

# Default session directory. Make sure you don't run multiple instance
# of seeder1rent using the same session directory. Perhaps using a
# relative path?
session = /home/USER2/rtorrent/.session

# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=/home/USER2/rtorrent/watch/*.torrent
schedule = untied_directory,5,5,stop_untied=

# Close torrents when diskspace is low. */
schedule = low_diskspace,5,60,close_low_diskspace=100M

# 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


# When the torrent finishes, it executes "mv -n <base_path> ~/Download/"
# and then sets the destination directory to "~/Download/". (0.7.7+)
# on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/home/USER2/download/complete/ ;d.set_directory=/home/USER2/download/complete/"

# 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

# Port range to use for listening.
port_range = 56001-56005

# Start opening ports at a random position within the port range.
#port_random = yes

scgi_port = 127.0.0.1:5001
[...]

Apache2 configuration :
/etc/apache2/apache2.conf
At the end of the file
Code:
SCGIMount /RPC2 127.0.0.1:5000
SCGIMount /RPC3 127.0.0.1:5001
servername localhost

I have to domains managed by ISPConfig which we will call domaine1.com and domaine2.com
The content of the vhost :
/etc/apache2/sites-enabled/100-domaine2.com.vhost :
Code:
<Directory /var/www/domaine2.com>
AllowOverride None
Order Deny,Allow
Deny from all
</Directory>

<VirtualHost *:80>
DocumentRoot /var/www/domaine2.com/web

ServerName domaine2.com
ServerAlias www.domaine2.com
ServerAdmin [email protected]

ErrorLog /var/log/ispconfig/httpd/domaine2.com/error.log


<IfModule mod_ssl.c>
</IfModule>

<Directory /var/www/domaine2.com/web>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/clients/client3/web7/web>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<IfModule mod_fcgid.c>
IdleTimeout 300
ProcessLifeTime 3600
# MaxProcessCount 1000
DefaultMinClassProcessCount 0
DefaultMaxClassProcessCount 100
IPCConnectTimeout 3
IPCCommTimeout 360
BusyTimeout 300
</IfModule>
<Directory /var/www/domaine2.com/web>
AddHandler fcgid-script .php .php3 .php4 .php5
FCGIWrapper /var/www/php-fcgi-scripts/web7/.php-fcgi-starter .php
Options +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/clients/client3/web7/web>
AddHandler fcgid-script .php .php3 .php4 .php5
FCGIWrapper /var/www/php-fcgi-scripts/web7/.php-fcgi-starter .php
Options +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


<VirtualHost *:443>
ServerAdmin webmaster@localhost

ServerName domaine2.com
ServerAlias www.domaine2.com

SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem

DocumentRoot /var/www/clients/client3/web7/web/rutorrent

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/clients/client3/web7/web/rutorrent>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"

<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

<Location />
AuthType Digest
AuthName "seedbox"
AuthDigestDomain /var/www/clients/client3/web7/web/rutorrent/ http://127.0.0.1/rutorrent

AuthDigestProvider file
AuthUserFile /etc/apache2/passwords
Require valid-user
SetEnv R_ENV "/var/www/clients/client3/web7/web/rutorrent"
</Location>
</VirtualHost>

And domaine1.com
/etc/apche2/sites-enabled/100-domaine1.com.vhost :
Code:
<Directory /var/www/domaine1.com>
AllowOverride None
Order Deny,Allow
Deny from all
</Directory>

<VirtualHost *:80>
DocumentRoot /var/www/domaine1.com/web

ServerName domaine1.com
ServerAlias www.domaine1.com
ServerAlias torrent.domaine1.com

ErrorLog /var/log/ispconfig/httpd/domaine1.com/error.log

<IfModule mod_ssl.c>
</IfModule>

<Directory /var/www/domaine1.com/web>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/clients/client1/web3/web>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

# php as fast-cgi enabled
# For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
<IfModule mod_fcgid.c>
IdleTimeout 300
ProcessLifeTime 3600
# MaxProcessCount 1000
DefaultMinClassProcessCount 0
DefaultMaxClassProcessCount 100
IPCConnectTimeout 3
IPCCommTimeout 360
BusyTimeout 300
</IfModule>
<Directory /var/www/domaine1.com/web>
AddHandler fcgid-script .php .php3 .php4 .php5
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php
Options +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/clients/client1/web3/web>
AddHandler fcgid-script .php .php3 .php4 .php5
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php
Options +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<Location /rutorrent>
AuthType Digest
AuthName "seedbox"
AuthDigestDomain /var/www/clients/client1/web3/web/rutorrent/ http://127.0.0.1/rutorrent
AuthDigestProvider file
AuthUserFile /etc/apache2/passwords
Require valid-user
SetEnv R_ENV "/var/www/clients/client1/web3/web/rutorrent"
</Location>

RewriteEngine on
RewriteCond %{HTTP_HOST} ^torrent\.domaine1\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/rutorrent/
RewriteRule ^/(.*)$ /rutorrent/$1 [L]


</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost

ServerName domaine1.com
ServerAlias torrent.domaine1.com

SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem

DocumentRoot /var/www/clients/client1/web3/web/rutorrent

RewriteCond %{HTTP_HOST} ^torrent\.domaine1\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/rutorrent/
RewriteRule ^/(.*)$ /rutorrent/$1 [L]

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/clients/client1/web3/web/rutorrent>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"

<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

<Location />
AuthType Digest
AuthName "seedbox"
AuthDigestDomain /var/www/clients/client1/web3/web/rutorrent/ http://127.0.0.1/rutorrent

AuthDigestProvider file
AuthUserFile /etc/apache2/passwords
Require valid-user
SetEnv R_ENV "/var/www/clients/client1/web3/web/rutorrent"
</Location>
</VirtualHost>

And the config.php from rutorrent :
for USER1:
/var/www/clients/client1/web3/web/rutorrent/conf/config.php
Code:
<?php
[...]

$scgi_port = 5000;
$scgi_host = "127.0.0.1";

// For web->rtorrent link through unix domain socket
// (scgi_local in rtorrent conf file), change variables
// above to something like this:
//
// $scgi_port = 0;
// $scgi_host = "unix:///tmp/rpc.socket";

$XMLRPCMountPoint = "/RPC2"; // DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!

[...]
and for USER2:
/var/www/clients/client3/web7/web/rutorrent/conf/config.php :
Code:
<?php
[...]

$scgi_port = 5001;
$scgi_host = "127.0.0.1";

// For web->rtorrent link through unix domain socket
// (scgi_local in rtorrent conf file), change variables
// above to something like this:
//
// $scgi_port = 0;
// $scgi_host = "unix:///tmp/rpc.socket";

$XMLRPCMountPoint = "/RPC3"; // DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!

$pathToExternals = array(
[...]
And finally my rtorrent scripts for launching rtorrent instances :
/etc/init.d/rtorrent:
Code:
#!/bin/bash

### BEGIN INIT INFO
# Provides: rtorrent.USER1
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Start-Stop rtorrent USER1 session
### END INIT INFO

#############
###<Notes>###
#############
# 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
##############
###</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
user="USER1"

# 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/USER1/.rtorrent.rc"

# set of options to run with
options=""

# default directory for screen, needs to be an absolute path
base="/home/USER1"

# name of screen session
srnname="rtorrent"

# file to log to (makes for easier debugging if something goes wrong)
logfile="/var/log/rtorrentInit.log"
#######################
###END CONFIGURATION###
#######################
[...]

and rtorrent2 for USER2 :
Code:
#!/bin/bash

### BEGIN INIT INFO
# Provides: rtorrent.USER2
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Start-Stop rtorrent USER2 session
### END INIT INFO

#############
###<Notes>###
#############
# 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
##############
###</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
user="USER2"

# 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/USER2/.rtorrent.rc"

# set of options to run with
options=""

# default directory for screen, needs to be an absolute path
base="/home/USER2"

# name of screen session
srnname="rtorrent"

# file to log to (makes for easier debugging if something goes wrong)
logfile="/var/log/rtorrentInit.log"
#######################
###END CONFIGURATION###
#######################
[...]

The command give me this result :
root:/home/USER1/rtorrent# /etc/init.d/rtorrent start
Starting rtorrent: rtorrent.
root:/home/USER1/rtorrent# /etc/init.d/rtorrent2 start
Starting rtorrent: rtorrent.

But no rtorrent in the process list, but rtorrent command work good.

So in my Log of rutorrent for USER1 and https://torrent.domaine1.com
I have :
Quote
[22.04.2013 14:07:58] WebUI started.[22.04.2013 14:08:01] mediainfo: Le plug-in ne fonctionnera pas. rTorrent ne peut pas accéder au(x) programme(s) externe(s). (mediainfo).[22.04.2013 14:08:01] screenshots: Le plug-in ne fonctionnera pas. rTorrent ne peut pas accéder au(x) programme(s) externe(s). (ffmpeg).​


But for USER2 on https://domaine2.com
I have
Quote
[22.04.2013 14:06:37] WebUI started.[22.04.2013 14:06:37] Lien incorrect avec rTorrent. Vérifier qu'il est bien en cours d'exécution. Vérifier la configuration de $scgi_port et de $scgi_host dans config.php et scgi_port dans le fichier de configuration de rTorrent.​


which is normal because /etc/init.d/rtorrent2 doesn't want to execute neither /etc/init.d/rtorrent only rtorrent works

So, what am I doing wrong ?

Thank you in advance for your help.
 

randac56

Member
May 25, 2018
915
0
16
Thank you Novik65, so if I want to launch multiple instance of rtorrent, I need to do something like that ?
Code:
screen -dm -S RTorrent1 rtorrent
screen -dm -S RTorrent2 rtorrent
No need to identify which user use which instance of rtorrent ?
 

randac56

Member
May 25, 2018
915
0
16
I've modified for USER2
Code:
# name of screen session
srnname="rtorrent"
to

Code:
# name of screen session
srnname="rtorrent2"
but
Code:
/etc/init.d/rtorrent startand
Code:
/etc/init.d/rtorrent2 startdoesn't launch rtorrent instance.
 

randac56

Member
May 25, 2018
915
0
16
Here the complete code for starter files :
USER1 : /etc/init.d/rtorrent
Code:
#!/bin/bash

### BEGIN INIT INFO
# Provides: rtorrent.USER1
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Start-Stop rtorrent USER1 session
### END INIT INFO

#############
###<Notes>###
#############
# 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
##############
###</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
user="USER1"

# 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/USER1/.rtorrent.rc"

# set of options to run with
options=""

# default directory for screen, needs to be an absolute path
base="/home/USER1"

# name of screen session
srnname="rtorrent"

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

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 "$logfile" >&2
# this works for the screen command, but starting rtorrent below adopts screen session gid
# even if it is not the screen session we started (e.g. 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\"" ${user} | tee -a "$logfile" >&2
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=`cat "$1" | grep "^[[:space:]]*session[[:space:]]*=" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//" `
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

and USER2 : /etc/init.d/rtorrent2
Code:
#!/bin/bash

### BEGIN INIT INFO
# Provides: rtorrent.USER2
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Start-Stop rtorrent USER2 session
### END INIT INFO

#############
###<Notes>###
#############
# 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
##############
###</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
user="USER2"

# 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/USER2/.rtorrent.rc"

# set of options to run with
options=""

# default directory for screen, needs to be an absolute path
base="/home/USER2"

# name of screen session
srnname="rtorrent2"

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

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 "$logfile" >&2
# this works for the screen command, but starting rtorrent below adopts screen session gid
# even if it is not the screen session we started (e.g. 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\"" ${user} | tee -a "$logfile" >&2
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=`cat "$1" | grep "^[[:space:]]*session[[:space:]]*=" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//" `
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

Thanks
 

randac56

Member
May 25, 2018
915
0
16
There is something strange
If I go to /etc/init.d/
then I do a
Code:
sudo rtorrent start, I can see the rtorrent in my console, but I'm obliged to do a CTRL+Q to come back to console but
Code:
/etc/init.d/rtorrent startprint only a
Code:
Starting rtorrent: rtorrent.And for rtorrent2 in /etc/init.d
Code:
/etc/init.d# /etc/init.d/rtorrent2 start
Starting rtorrent: rtorrent.

and
Code:
/etc/init.d# rtorrent2 start
bash: rtorrent2: command not found

Code:
-rwxr-xr-x 1 root root 4709 Apr 21 13:22 rtorrent
-rwxr-xr-x 1 root root 4723 Apr 22 10:41 rtorrent2

A little weird this story ...
 

peshua19

Member
May 25, 2018
897
0
16
Quote :
sudo rtorrent start


You run rtorrent's binary from PATH. With a unnecessary parameter "start".

Quote:
/etc/init.d# /etc/init.d/rtorrent2 start
Starting rtorrent: rtorrent.


You run bash script from /etc/init.d

Quote :
/etc/init.d# rtorrent2 start


You do something strange. If you want to launch bash script from the current directory, you must write ./rtorrent2 start.

As result. Sorry, but with such level of knowledge you can't make proper configuration by self. Try to hire someone.
 

randac56

Member
May 25, 2018
915
0
16
Quote :
You do something strange. If you want to launch bash script from the current directory, you must write ./rtorrent2 start.​


Ok, I wasn't aware about that, but I've already tried ./rtorrent2 start, same result as /etc/init.d/rtorrent2 start ...

Quote :
As result. Sorry, but with such level of knowledge you can't make proper configuration by self. Try to hire someone.​


Yes, my knowledge about Linux are not huge, but you know, I tried to learn as much as I can in a very short of time, but it's the first time I met someone on the net which tell me : "Try to hire someone"...

I've finally understood that displaying result of "screen -ls" logged as root display empty list because /etc/init.d/rtorrent start and /etc/init.d/rtorrent2 start launch screen to the corresponding user (USER1 and USER2).

So I have (logged with USER1)
Code
/var/www$ screen -ls
There is a screen on:
3617.rtorrent (23/04/13 04:17:33) (Detached)
1 Socket in /var/run/screen/S-USER1.

and for USER2 :
Code:
/var/www$ screen -ls
There is a screen on:
3913.rtorrent (23/04/13 04:20:04) (Detached)
1 Socket in /var/run/screen/S-USER2.


For USER2 I have now,
Quote
[23.04.2013 14:33:10] WebUI started.
[23.04.2013 14:33:11] ratio: Some functionality will be unavailable. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] unpack: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] history: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] trafic: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] autotools: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] create: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] retrackers: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] rss: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] scheduler: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] rutracker_check: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 14:33:11] mediainfo: Plugin will not work. rTorrent user can't access external program (mediainfo).
[23.04.2013 14:33:11] create: Some functionality will be unavailable. rTorrent user can't access external program (pgrep).
[23.04.2013 14:33:11] _task: Some functionality will be unavailable. rTorrent user can't access external program (pgrep).
[23.04.2013 14:33:11] screenshots: Plugin will not work. rTorrent user can't access external program (ffmpeg).
[23.04.2013 14:33:11] rss: Some functionality will be unavailable. rTorrent user can't access external program (curl).
[23.04.2013 14:33:13] DataDir plugin: rTorrent user can't access php interpreter. Plugin will not work.
[23.04.2013 14:33:13] Unpack plugin: rTorrent user can't access 'unzip' program.
[23.04.2013 14:33:13] Unpack plugin: rTorrent user can't access 'unrar' program.​


For USER1 I get now :
Quote
[23.04.2013 10:57:30] ratio: Some functionality will be unavailable. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] unpack: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] history: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] trafic: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] autotools: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] create: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] retrackers: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] rss: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] scheduler: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] rutracker_check: Plugin will not work. rTorrent user can't access external program (php).
[23.04.2013 10:57:30] mediainfo: Plugin will not work. rTorrent user can't access external program (mediainfo).
[23.04.2013 10:57:30] create: Some functionality will be unavailable. rTorrent user can't access external program (pgrep).
[23.04.2013 10:57:30] _task: Some functionality will be unavailable. rTorrent user can't access external program (pgrep).
[23.04.2013 10:57:30] screenshots: Plugin will not work. rTorrent user can't access external program (ffmpeg).
[23.04.2013 10:57:30] rss: Some functionality will be unavailable. rTorrent user can't access external program (curl).
[23.04.2013 10:57:35] DataDir plugin: rTorrent user can't access php interpreter. Plugin will not work.
[23.04.2013 10:57:35] Unpack plugin: rTorrent user can't access 'unzip' program.
[23.04.2013 10:57:35] Unpack plugin: rTorrent user can't access 'unrar' program.​


I think my mistake must be about user permissions because configuration files seems to be well configured.
 

saroos1

Member
May 25, 2018
718
0
16
Hi,

Is it possible for you to give us; The tutorial that thought you how to install rutorrent?

It is because with the error you had given; It is most probably some application not install yet;