On ne présente plus le système de torrents, l’intérêt de mettre en place une session Rutorrent sur son dédié est d’avoir une session et un seed dispo h24. Si ca peut vous aider voici une liste de sites pour le telechargement legal de torrents.
On commence par mettre à jour les sources:
sudo nano /etc/apt/sources.list
Et collez:
deb http://deb.debian.org/debian bullseye main contrib non-free
deb-src http://deb.debian.org/debian bullseye main contrib non-free
deb http://security.debian.org/debian-security bullseye-security main contrib non-free
deb-src http://security.debian.org/debian-security bullseye-security main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb-src http://deb.debian.org/debian bullseye-updates main contrib non-free
deb http://deb.debian.org/debian bullseye-backports main contrib non-free
deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free
deb http://download.webmin.com/download/repository sarge contrib
Installation des paquets:
sudo apt update && sudo apt upgrade -y
sudo apt install -y apt-transport-https gnupg2
sudo apt install -y apache2-utils automake htop build-essential curl unrar rar ffmpeg gawk git libcppunit-dev libcurl4-openssl-dev libncurses5-dev libsigc++-2.0-dev libsox-fmt-all libsox-fmt-mp3 libssl-dev libtool mediainfo mktorrent net-tools php-geoip pkg-config psmisc python3-venv python3-pip screen subversion unzip sox vim zip zlib1g-dev
On vérifie sa version de php:
sudo php -v
Et on installe le reste des dépendances PHP:
sudo apt install -y php$PHPVERSION-{cli,common,curl,fpm,json,mbstring,opcache,readline,xml}
Installation de xmlrpc:
cd /tmp
git clone https://github.com/mirror/xmlrpc-c.git
cd xmlrpc-c/stable/
./configure
sudo make
sudo make install
Installation de libTorrent et rTorrent:
Pensez à vérifier les dernières versions disponibles ici.
cd /tmp
git clone https://github.com/rakshasa/libtorrent.git
cd libtorrent
git checkout v0.13.8
./autogen.sh
./configure --disable-debug
sudo make
sudo make install
cd /tmp
git clone https://github.com/rakshasa/rtorrent.git
cd rtorrent
git checkout v0.9.8
./autogen.sh
./configure --with-xmlrpc-c --with-ncurses --disable-debug
sudo make
sudo make install
sudo ldconfig
Installation de ruTorrent:
cd /var/www/html
sudo git clone https://github.com/Novik/ruTorrent.git rutorrent
Installation du plugin ruTorrent filemanager:
cd /tmp
git clone https://github.com/Micdu70/rutorrent-thirdparty-plugins.git
cd rutorrent-thirdparty-plugins
sudo mv filemanager /var/www/html/rutorrent/plugins/filemanager
Configuration Plugins:
sudo sed -i "s/false/\'mktorrent\'/g" /var/www/html/rutorrent/plugins/create/conf.php
sudo sed -i "s/'';/\'\/usr\/bin\/mktorrent\';/" /var/www/html/rutorrent/plugins/create/conf.php
sudo pip3 install cloudscraper
sudo nano /var/www/rutorrent/plugins/filemanager/conf.php
Et modifiez comme suivant:
$pathToExternals['rar'] = '/usr/bin/rar';
$pathToExternals['zip'] = '/usr/bin/zip';
$pathToExternals['unzip'] = '/usr/bin/unzip';
$pathToExternals['tar'] = '/usr/bin/tar';
$pathToExternals['gzip'] = '/usr/bin/gzip';
$pathToExternals['bzip2'] = '/usr/bin/bzip2';
Configuration Apache:
On créer un fichier qui contiendra le mot de passe de l’utilisateur
sudo htpasswd -c /etc/apache2/passwords $USERNAME
On édite le fichier .conf d’apache pour y ajouter la config rutorrent:
sudo nano /etc/apache2/sites-enabled/$VotreFichierConf
Et on ajoute:
Alias /rutorrent /var/www/html/rutorrent
<Directory /var/www/html/rutorrent/>
AuthType Basic
AuthName "Restricted Files"
# (Following line optional)
AuthBasicProvider file
AuthUserFile "/etc/apache2/passwords"
Require user $USERNAME
</Directory>
SetEnvIf Request_URI "^/rutorrent/.*$" rutorrent
CustomLog ${APACHE_LOG_DIR}/rutorrent-access.log common env=rutorrent
On redémarre Apache:
sudo service apache2 restart
Configuration de Rtorrent:
sudo mkdir /home/$USERNAME/.session
sudo nano /home/$USERNAME/.rtorrent.rc
Et on colle:
network.scgi.open_port = 127.0.0.1:500x
encoding.add = UTF-8
network.port_range.set = 45000-65000
network.port_random.set = no
pieces.hash.on_completion.set = no
directory.default.set = /home/<username>/torrents
session.path.set = /home/<username>/.session
protocol.encryption.set = allow_incoming, try_outgoing, enable_retry
schedule2 = watch_directory,1,1,load.start=/home/<username>/watch/*.torrent
schedule2 = untied_directory,5,5,stop_untied=/home/<username>/watch/*.torrent
schedule2 = espace_disque_insuffisant,1,30,close_low_diskspace=500M
trackers.use_udp.set = yes
dht.mode.set = off
protocol.pex.set = no
throttle.min_peers.normal.set = 40
throttle.max_peers.normal.set = 100
throttle.min_peers.seed.set = 10
throttle.max_peers.seed.set = 50
throttle.max_uploads.set = 15
execute2 = {sh,-c,/usr/bin/php /var/www/html/rutorrent/php/initplugins.php <username> &}
On adapte la conf:
sudo sed -i 's/127.0.0.1:500x/127.0.0.1:5001/g' /home/$USERNAME/.rtorrent.rc
sudo sed -i 's/<username>/$USERNAME/g' /home/$USERNAME/.rtorrent.rc
sudo chown $USERNAME:$USERNAME /home/$USERNAME/.rtorrent.rc
sudo chown -R $USERNAME:$USERNAME /home/$USERNAME/.session/
Configuration Rutorrent:
sudo mkdir /var/www/html/rutorrent/conf/users/$USERNAME
sudo nano /var/www/html/rutorrent/conf/users/$USERNAME/config.php
Et on colle:
<?php
$pathToExternals = array(
"curl" => '/usr/bin/curl',
"stat" => '/usr/bin/stat',
"php" => '/usr/bin/php$PHPVersion',
"pgrep" => '/usr/bin/pgrep',
"python" => '/usr/bin/python3'
);
$topDirectory = '/home/$USERNAME';
$scgi_port = 5001;
$scgi_host = '127.0.0.1';
$XMLRPCMountPoint = '/$USERNAMEenMAJUSCULE';
sudo chown -R www-data:www-data rutorrent
Pour rendre Rtorrent persistant au redemarrage:
cd /etc/init.d/
sudo nano $USERNAME-rtorrent
Et on y colle:
#!/usr/bin/env bash
# Dépendance : screen, killall et rtorrent
### BEGIN INIT INFO
# Provides: <username>-rtorrent
# Required-Start: $syslog $network
# Required-Stop: $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Start-Stop rtorrent user session
### END INIT INFO
## Début configuration ##
user="$USERNAME"
## Fin configuration ##
rt_start() {
su --command="screen -dmS ${user}-rtorrent rtorrent" "${user}"
}
rt_stop() {
killall --user "${user}" screen
}
case "$1" in
start) echo "Starting rtorrent..."; rt_start
;;
stop) echo "Stopping rtorrent..."; rt_stop
;;
restart) echo "Restart rtorrent..."; rt_stop; sleep 1; rt_start
;;
*) echo "Usage: $0 {start|stop|restart}"; exit 1
;;
esac
exit 0
On le rend executable:
sudo chmod +x /etc/init.d/$USERNAME-rtorrent
sudo update-rc.d $USERNAME-rtorrent defaults
Firewall:
Si vous avez suivi l’article concernant le pare-feu il vous faudra ouvrir les de Rtorrent
sudo nano /etc/init.d/firewall
Et ajoutez:
#Rtorrent
iptables -t filter -A INPUT -p tcp --dport 45000:65000 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 45000:65000 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 45000:65000 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --dport 45000:65000 -j ACCEPT