I have created 'autodl_vidangeur' in /etc/init.d
Code:
#!/bin/sh
# chkconfig: 2345 85 15
# description: Start autodl-irssi and rtorrent
### BEGIN INIT INFO
# Provides: autodl_vidangeur
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start autodl-irssi and rtorrent
# Description: Start autodl-irssi and rtorrent
### END INIT INFO
NAME=autodl_vidangeur
USER=vidangeur
SESSIONNAME=autodl
resetPath() {
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
}
resetPath
# Make sure the path is correct, and make sure we're in the home dir.
USER_INIT="umask 022; cd; PATH=\$PATH:$PATH"
# Run user command, ignoring any messages sent to stdout (eg. 'No mail.')
runUserCmd() {
su - $USER -c "$USER_INIT; $1" >/dev/null && return 0
return 1
}
isStarted() {
su - $USER -c "$USER_INIT; screen -ls | grep -qE \"[ ][0-9]+\\.$SESSIONNAME[ ]\"" >/dev/null && return 0
return 1
}
startIt() {
isStarted && return 0
local START_IRSSI=n
local START_RTORRENT=n
which irssi > /dev/null 2>&1 && START_IRSSI=y
which rtorrent > /dev/null 2>&1 && START_RTORRENT=y
case $START_IRSSI$START_RTORRENT in
yy)
runUserCmd "screen -S $SESSIONNAME -d -t rtorrent -m rtorrent"
runUserCmd "screen -d -r $SESSIONNAME -X screen -t irssi irssi"
;;
yn)
runUserCmd "screen -S $SESSIONNAME -d -t irssi -m irssi"
;;
ny)
runUserCmd "screen -S $SESSIONNAME -d -t rtorrent -m rtorrent"
;;
nn)
;;
esac
return 0
}
stopIt() {
isStarted || return 0
runUserCmd "screen -d -r $SESSIONNAME -p irssi -X stuff \"/quit
/quit
\""
runUserCmd "screen -d -r $SESSIONNAME -p rtorrent -X xon"
for i in 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4; do
isStarted || break
sleep 1
done
# If it's still not stopped, kill the whole screen session
if isStarted; then
echo -n "Couldn't stop it. Killing screen session..."
runUserCmd "screen -d -r $SESSIONNAME -p rtorrent -X xon"
sleep 2
runUserCmd "screen -d -r $SESSIONNAME -X quit"
echo "Done."
fi
return 0
}
v_restartIt() {
v_stopIt
v_startIt
}
v_showStatus() {
if isStarted; then
echo "$NAME is running."
else
echo "$NAME is stopped."
fi
}
. /lib/lsb/init-functions
v_startIt() {
log_begin_msg "Starting $NAME..."
startIt
log_end_msg $?
}
v_stopIt() {
log_begin_msg "Stopping $NAME..."
stopIt
log_end_msg $?
}
resetPath # Some include files may have reset it
LOCKFILE=
updateLock() {
[ -z "$LOCKFILE" ] && return
if isStarted; then
touch $LOCKFILE
else
rm -f $LOCKFILE
fi
}
RETVAL=0
case $1 in
start)
v_startIt
;;
stop)
v_stopIt
;;
force-reload|restart)
v_restartIt
;;
try-restart)
isStarted && v_restartIt
;;
status)
v_showStatus
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
RETVAL=1
;;
esac
updateLock
exit $RETVAL
This is a copy of other user, I have edited the first 3 parameters.
After I haved added user in /etc/apache2/rutorrent_passwd
And I have edited the file in /etc/apache2/sites-available/rutorrent
I have added lines for 'vidangeur'
Code:
ServerName localhost
<VirtualHost *:80>
ServerAdmin admin@rutorrent
ServerName ***hidden for security***
DocumentRoot /var/rutorrent
<Directory />
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Location />
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require valid-user
Order allow,deny
Allow from all
</Location>
<Location ~ "^/rutorrent/(conf|share)">
Order deny,allow
Deny from all
</Location>
<Location ~ "/\\.svn">
Order deny,allow
Deny from all
</Location>
<Location "/RPC00001">
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require user levelkro
</Location>
<Location "/RPC00002">
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require user macgyver
</Location>
<Location "/RPC00003">
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require user ggmagla
</Location>
<Location "/RPC00004">
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require user vidangeur
</Location>
</VirtualHost>
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/rutorrent.pem
ServerAdmin admin@rutorrent
ServerName ***hidden for security***
DocumentRoot /var/rutorrent
<Directory />
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Location />
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require valid-user
Order allow,deny
Allow from all
</Location>
<Location ~ "^/rutorrent/(conf|share)">
Order deny,allow
Deny from all
</Location>
<Location ~ "/\\.svn">
Order deny,allow
Deny from all
</Location>
<Location "/RPC00001">
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require user levelkro
</Location>
<Location "/RPC00002">
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require user macgyver
</Location>
<Location "/RPC00003">
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require user ggmagla
</Location>
<Location "/RPC00004">
AuthType Basic
AuthName "My ruTorrent web site"
AuthUserFile "/etc/apache2/rutorrent_passwd"
Require user vidangeur
</Location>
</VirtualHost>
#SCGIMount /RPC00001 127.0.0.1:23876
#SCGIMount /RPC00002 127.0.0.1:23879
#SCGIMount /RPC00003 127.0.0.1:23885
#SCGIMount /RPC00004 127.0.0.1:23890
For the user directory;
/home/vidangeur/downloads
/home/vidangeur/rtorrent
/home/vidangeur/rtorrent/watch
/home/vidangeur/rtorrent/session
And the config file for rtorrent, rtorrent.rc look like;
Code:
scgi_port = 127.0.0.1:23890
encoding_list = UTF-8
system.umask.set = 022
port_range = 23895-23895
port_random = no
check_hash = no
directory = /home/vidangeur/downloads
session = /home/vidangeur/rtorrent/session
encryption = allow_incoming, try_outgoing, enable_retry
schedule = watch_directory,1,1,"load_start=/home/vidangeur/rtorrent/watch/*.torrent"
#schedule = untied_directory,5,5,"stop_untied=/home/vidangeur/rtorrent/watch/*.torrent"
trackers.enable = 1
#min_peers = 40
#max_peers = 100
#min_peers_seed = 10
#max_peers_seed = 50
#max_uploads = 15
#download_rate = 0
#upload_rate = 0
use_udp_trackers = yes
dht = auto
dht_port = 6881
peer_exchange = yes
#hash_read_ahead = 10
#hash_interval = 100
#hash_max_tries = 10
execute = {sh,-c,/usr/bin/php /var/rutorrent/rutorrent/php/initplugins.php vidangeur &}
And for finish, I have created files for WebUi rutorrent;
added directory 'vidangeur' for user in /var/rutorrent/rutorrent/conf/users
config.php look like;
Code:
<?php
$scgi_port = 23890;
$scgi_host = "127.0.0.1";
$XMLRPCMountPoint = "/RPC00004";
?>
All other users created by the setup of 'autodl-setup' work fine. (levelkro, ggmagla and macgyver)
Apache is restarted
'autodl_vidangeur' was started, the process rtorrent exists for user 'vidangeur'
All files and code is copied from user 'macgyver'
I'm running Debian 6 X64 with Apache 2 and Webmin is installed.