Добавить новость на сайт
RSS
Читать нас в RSS
Статистика сайта
Наши правила
Поиск по сайту
Добро пожаловать на Информационный портал Vectormm.net! У нас вы можете найти инструкции по настройке популярных беспроводных роутеров, а так же тонкости и хитрости по работе с операционными системами Windows и Linux. Так же, вы можете общаться на нашем форуме.

Вы не авторизованы. Пожалуйста войдите на сайт, или зарегистрируйтесь!
Навигация
 
Сегодня
Панель управления
 

Установка rtorrent
Раздел: Роутеры / Роутеры ASUS

1. Устанавливаем rtorrent:

 

ipkg install rtorrent

ipkg install lighttpd

ipkg install php

ipkg install php-fcgi

ipkg install coreutils

ipkg install adduser
ipkg install procps
ipkg install grep
ipkg install screen
ipkg install gawk
ipkg install which
ipkg install tar

 

2. Настраиваем:

nano /opt/etc/rtorrent.conf

(удалил все комментарии для сокращения размера, оставил только действующие параметры)


min_peers = 5
max_peers = 15
min_peers_seed = 10
max_peers_seed = 20
max_uploads_global = 6
max_downloads_global = 10
enable_trackers = yes
max_uploads = 10
download_rate = 0
upload_rate = 0
directory=/tmp/mnt/disc0_3/torrent/work/
schedule = watch_directory,5,5,load_start=/tmp/mnt/disc0_3/torrent/dl/*.torrent
schedule = untied_directory,5,5,stop_untied=

#может кому понадобится расписание работы:
#schedule = throttle_1,01:00:00,24:00:00,upload_rate=0
#schedule = throttle_2,05:00:00,24:00:00,upload_rate=80
schedule = low_diskspace,5,60,close_low_diskspace=100M
session = /tmp/mnt/disc0_3/torrent/session
port_range = 51777-51780
port_random = no
check_hash = yes
use_udp_trackers = no
hash_interval = 100
hash_max_tries = 10
max_open_files = 128
#schedule = ratio,60,60,"stop_on_ratio=200,200M,2000"
#schedule = ratio,30,60,stop_on_ratio=200
encryption = allow_incoming,enable_retry,prefer_plaintext
dht = auto
dht_port = 51780
peer_exchange = yes
scgi_port = 127.0.0.1:5000
safe_sync = yes
encoding_list = UTF-8


3. Создаем нужные каталоги:


mkdir -p /tmp/mnt/disc0_3/torrent/dl
mkdir /tmp/mnt/disc0_3/torrent/work
mkdir /tmp/mnt/disc0_3/torrent/session


4. Создаем пользователя p2p:

#создать домашнюю директорию пользователя

mkdir -p /opt/home/p2p

#добавить пользователя с любым паролем, он больше не нужен нигде:
/opt/bin/adduser -D --home /opt/home/p2p p2p

#назначить p2p хозяином нужных директорий:

/bin/chown p2p /opt/home/p2p
/bin/chown p2p /tmp/mnt/disc0_3/torrent/dl
/bin/chown p2p /tmp/mnt/disc0_3/torrent/work
/bin/chown p2p /tmp/mnt/disc0_3/torrent/session
/bin/chmod a+r /opt/etc/rtorrent.conf
/bin/chmod a+x /opt/bin/rtorrent

 

5. Модернизируем файл автозапуска rtorrent:

nano /opt/etc/init.d/S99rtorrent

#!/bin/sh

user="p2p"
config="/opt/etc/rtorrent.conf"
options="-n -o import=/opt/etc/rtorrent.conf"
base="/opt/share/torrent"
srnname="rtorrent"
logfile="/opt/var/log/rtorrentInit.log"

PATH=/opt/bin:/opt/sbin:/usr/bin:/sbin:/bin:/usr/sbin
DESC="rtorrent"
NAME=rtorrent
DAEMON=$NAME
SCRIPTNAME=/etc/init.d/$NAME

# Do not proceed unless some apps are available.
test -x /opt/bin/screen || ( echo "screen not found." | tee -a "$logfile" >&2 ; exit 2 )
test -x /opt/bin/su -o -x /bin/su || ( echo "su not found." | tee -a "$logfile" >&2 ; exit 2 )

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=`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

Для тех, кто любит все файлы создавать в Винде, прикладываю запакованный оригинал файла - с правильными переносами строк.

Брать здесь.

После скачивания распаковать и положить в /opt/etc/init.d/

6. Исправляем файл профиля пользователя:

nano /tmp/local/root/.profile

export TERMINFO="/opt/share/terminfo"
export TERM="xterm"
alias rt='su -c "screen -r" p2p'
chmod a+rw `tty`
stty start undef
stty stop undef

 

7. Делаем стандартные:

flashfs save && flashfs commit && flashfs enable

 

8. Копируем данный файл пользователю p2p:


cp /tmp/local/root/.profile /opt/home/p2p/.profile
chown p2p /opt/home/p2p/.profile


9. Проверяем, что пользователь существует и rtorrent под ним фунциклирует:

su p2p
/opt/bin/rtorrent -n -o import=/opt/etc/rtorrent.conf


Если виден rtorrent - выйти - ^Q.
Выйти из telnet или ssh - exit. Для того, чтобы профиль пользователя сохранился.

 

10. Заходим снова и запускаем:

/opt/etc/init.d/S99rtorrent start

rt


Если все хорошо, т.е. rtorrent запустился - выйти -  ^A ^D.
Из консоли rtorrent вышли, но он продолжает работать в screen.


11. Проверяем содержимое /usr/tmp/local/.files:

cat /usr/tmp/local/.files

Там должно быть следующее:

/etc/passwd
/etc/group

Если нет - добавляем и делаем flashfs save && flashfs commit && flashfs enable

 

12. Ребутимся и проверяем, запустилось ли все автоматом:

rt

Выход -  ^A ^D.

 

13. Качаем веб морду:

cd /opt/share/www/lighttpd

wget http://rutorrent.googlecode.com/files/rtorrent-2.8.tar.gz

tar xvsf rtorrent-2.8.tar.gz

 

14. Добавляем в конфиг lighttpd:

В разделе server.modules добавляем, либо раскомментируем строчку

mod_scgi

Раздел scgi.server изменяем на:

scgi.server = (                                                           
        "/RPC2" =>                                                        
                ( "127.0.0.1" =>
                        (                                                   
                                "host" => "127.0.0.1",
                                "port" => 5000,
                                "check-local" => "disable"
                        )                                                   
                )                                                           
        )

 

15. Правим /opt/etc/lighttpd/conf.d/10-php-fcgi.conf:

nano /opt/etc/lighttpd/conf.d/10-php-fcgi.conf

Раскомментируем строку mod_fastcgi в разделе server.modules и раздел fastcgi.server целиком.

 

16. Делаем flashfs save && flashfs commit && flashfs enable && reboot

 

17. Заменяем бинарники rtorrent и libcurl на исправленные Novik:

(для последних сборок пункт не требуется!!!)

wget http://vif2ne.ru/nvk/stuff/novik/rtorrent/rtorrent.gz

gzip -d ./rtorrent.gz

cp ./rtorrent /opt/bin/

chmod +x /opt/bin/rtorrent

wget http://vif2ne.ru/nvk/stuff/novik/rtorrent/libtorrent.tar.gz

tar xvzf libtorrent.tar.gz

Все 3 файла кладем в /opt/lib и делаем chmod +x на них.

 

18. Делаем flashfs save && flashfs commit && flashfs enable


19. Открываем порты в файерволле:

nano /usr/local/sbin/post-firewall

Добавляем строчку:

iptables -I INPUT -p tcp -m tcp --dport 51777:51780 -j ACCEPT

 

20. Делаем flashfs save && flashfs commit && flashfs enable && reboot

 

21. Заходим:

http://my.router:port_number/rtorrent

где "port_number" - номер порта, прописанный в конфиге lighttpd.


Вопросы по работе веб морды задавайте автору тут.

 
 
 
Уважаемый посетитель, Вы зашли на сайт как незарегистрированный пользователь. Мы рекомендуем Вам зарегистрироваться либо зайти на сайт под своим именем.

НаверхНаверх
 
Наверх