Форум русскоязычного сообщества Ubuntu


Автор Тема: поделитесь скриптом автостарта rtorrent.  (Прочитано 6036 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн KRayn

  • Автор темы
  • Забанен
  • Любитель
  • *
  • Сообщений: 68
    • Просмотр профиля
раньше разработчик сам предлагал такой скрипт.
достаточно было скачать его в /etc/init.d/
сейчас этот скрипт с сайта исчез.
может у кого-то завалялся?

Оффлайн Simplehuman

  • Заслуженный пользователь
  • Старожил
  • *
  • Сообщений: 2473
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #1 : 31 Августа 2014, 13:29:45 »
KRayn,
#!/bin/bash
#############
###<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 whatever 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 (can only use one)
user="jeff"

# system user 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
# must keep parentheses around the entire statement, quotations around each config file
#config=("$(su -c 'echo $HOME' $user)/.rtorrent.rc")
# Examples:
config=("/home/jeff/.rtorrent.rc")
# config=("/home/user/.rtorrent.rc" "/mnt/some/drive/.rtorrent2.rc")
# config=("/home/user/.rtorrent.rc"
# "/mnt/some/drive/.rtorrent2.rc"
# "/mnt/another/drive/.rtorrent3.rc")

# set of options to run with each instance, separated by a new line
# must keep parentheses around the entire statement
#if no special options, specify with: ""
options=("")
# Examples:
# starts one instance, sourcing both .rtorrent.rc and .rtorrent2.rc
# options=("-o import=~/.rtorrent2.rc")
# starts two instances, ignoring .rtorrent.rc for both, and using
# .rtorrent2.rc for the first, and .rtorrent3.rc for the second
# we do not check for valid options
# options=("-n -o import=~/.rtorrent2.rc" "-n -o import=~/rtorrent3.rc")

# default directory for screen, needs to be an absolute path
base=$(su -c 'echo $HOME' $user)

# 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/$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 $NAME binary in PATH: $PATH" | tee -a "$logfile" >&2
    exit 3
  fi
  for (( i=0 ; i < ${#config[@]} ;  i++ )) ; do
    if ! [ -r "${config[i]}" ] ; then
        echo "cannot find readable config ${config[i]}. check that it is there and permissions are appropriate"  | tee -a "$logfile" >&2
        exit 3
    fi
    session=$(getsession "${config[i]}")
    if ! [ -d "${session}" ] ; then
        echo "cannot find readable session directory ${session} from config ${config[i]}. check permissions" | tee -a "$logfile" >&2
        exit 3
    fi
  done
}

d_start() {
  [ -d "${base}" ] && cd "${base}"
  stty stop undef && stty start undef
  #su -c "screen -S "${srnname}" -X screen rtorrent ${options} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
  su -c "screen -S "${srnname}" -X screen rtorrent ${options} " ${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
  for (( i=0 ; i < ${#options[@]} ; i++ )) ;  do
    sleep 3
    #su -c "screen -S "${srnname}" -X screen rtorrent ${options[i]} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
    su -c "screen -S "${srnname}" -X screen rtorrent ${options[i]} " ${user} | tee -a "$logfile" >&2
  done
}

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

getsession() {
    session=$(cat "$1" | grep "^[[:space:]]*session[[:space:]]*=" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//" )
    #session=${session/#~/`getent passwd ${user}|cut -d: -f6`}
    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

10 секунд в Google

Оффлайн KRayn

  • Автор темы
  • Забанен
  • Любитель
  • *
  • Сообщений: 68
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #2 : 31 Августа 2014, 13:45:11 »
10 секунд в Google
гуглить-то я и сам могу.
ваш скрипт не умеет запускать screen сессию, что делает его абсолютно непригодным к использованию.

потому я попросил поделится аутентичным скриптом.

Оффлайн victor00000

  • Старожил
  • *
  • Сообщений: 15568
  • Глухонемой (Deaf)
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #3 : 31 Августа 2014, 13:49:16 »
web-rtorrent - ubuntu 14.04
wget -q http://paste.ubuntu.com/8177653/ -O- | sed -n -e '/+===/,/-====/{/+====/d;/-====/d;p;}' | base64 -d

мои скрипт и устновка скрипт, будет торрент в браузер.
Wars ~.o

Оффлайн Simplehuman

  • Заслуженный пользователь
  • Старожил
  • *
  • Сообщений: 2473
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #4 : 31 Августа 2014, 13:51:38 »
KRayn,
в источнике указанно что это скрипт с сайта разработчика
#!/bin/bash
### BEGIN INIT INFO
# Provides:          rtorrent
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop rtorrent daemon
### END INIT INFO

# ------------------------------------------------------------------------------
# /etc/init.d/rtorrent
#
# This script is an init script to run rtorrent in the background, using a
# screen. The script was designed and tested for Debian systems, but may work on
# other systems. On Debian, enable it by moving the script to
# "/etc/init.d/rtorrent" and issuing the command
# "update-rc.d rtorrent defaults 99"
#    ____                _ _
#   / ___|  ___  ___  __| | |__   _____  __
#   \___ \ / _ \/ _ \/ _` | '_ \ / _ \ \/ /
#    ___) |  __/  __/ (_| | |_) | (_) >  <
#   |____/ \___|\___|\__,_|_.__/ \___/_/\_\
#
# @see http://methvin.net/scripts/rtorrent
# @see http://tldp.org/LDP/abs/html/
# ------------------------------------------------------------------------------

## Username to run rtorrent under, make sure you have a .rtorrent.rc in the
## home directory of this user!
USER="killjoy"

## Absolute path to the rtorrent binary.
RTORRENT="/usr/bin/rtorrent"

## Absolute path to the screen binary.
SCREEN="/usr/bin/screen"

## Name of the screen session, you can then "screen -r rtorrent" to get it back
## to the forground and work with it on your shell.
SCREEN_NAME="rtorrent"

## Absolute path to rtorrent's PID file.
PIDFILE="/var/run/rtorrent.pid"

## Absolute path to rtorrent's XMLRPC socket.
SOCKET="/var/run/rtorrent/rpc.socket"

## Check if the socket exists and if it exists delete it.
delete_socket() {
    if [[ -e $SOCKET ]]; then
        rm -f $SOCKET
    fi
}

case "$1" in
    ## Start rtorrent in the background.
    start)
        echo "Starting rtorrent."
        delete_socket
        start-stop-daemon --start --background --oknodo \
            --pidfile "$PIDFILE" --make-pidfile \
            --chuid $USER \
            --exec $SCREEN -- -DmUS $SCREEN_NAME $RTORRENT
        if [[ $? -ne 0 ]]; then
            echo "Error: rtorrent failed to start."
            exit 1
        fi
        echo "rtorrent started successfully."
        ;;

    ## Stop rtorrent.
    stop)
        echo "Stopping rtorrent."
        start-stop-daemon --stop --oknodo --pidfile "$PIDFILE"
        if [[ $? -ne 0 ]]; then
            echo "Error: failed to stop rtorrent process."
            exit 1
        fi
        delete_socket
        echo "rtorrent stopped successfully."
        ;;

    ## Restart rtorrent.
    restart)
        "$0" stop
        sleep 1
        "$0" start || exit 1
        ;;

    ## Print usage information if the user gives an invalid option.
    *)
        echo "Usage: $0 [start|stop|restart]"
        exit 1
        ;;

esac
?

Оффлайн KRayn

  • Автор темы
  • Забанен
  • Любитель
  • *
  • Сообщений: 68
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #5 : 31 Августа 2014, 13:56:55 »
на заборе тоже написано.
но скрипт разработчика, в отличии от предложенного вами скрипта, умеет запускать rtorrent в screen.
пожалуйста, если у вас нет оригинального скрипта - не пишите больше, не засоряйте тему, ок?

Оффлайн Simplehuman

  • Заслуженный пользователь
  • Старожил
  • *
  • Сообщений: 2473
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #6 : 31 Августа 2014, 14:35:11 »
KRayn,
с таким отношением к желающим помочь, думаю Вам никто помогать не будет
http://libtorrent.rakshasa.no/ (или http://rakshasa.github.io/rtorrent/) сайт разработчика? Скрипт на нем я нашел, но выкладывать не буду и другим не советую
« Последнее редактирование: 31 Августа 2014, 15:07:52 от Simplehuman »

Оффлайн KRayn

  • Автор темы
  • Забанен
  • Любитель
  • *
  • Сообщений: 68
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #7 : 31 Августа 2014, 14:45:48 »
Simplehuman, жалоба на ваш флуд модератору отправлена.
p.s.  особенно хорош скрипт по второй ссылке.

Оффлайн Haron Prime

  • Почётный модератор
  • Старожил
  • *
  • Сообщений: 11313
  • Нетолерантный социопат
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #8 : 31 Августа 2014, 14:48:04 »
KRayn,
Вам сделали правильное замечание!
Хотите, чтоб Вам помогали - сдерживайте свои эмоции!

Оффлайн KRayn

  • Автор темы
  • Забанен
  • Любитель
  • *
  • Сообщений: 68
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #9 : 31 Августа 2014, 14:54:59 »
KRayn,
Вам сделали правильное замечание!
Хотите, чтоб Вам помогали - сдерживайте свои эмоции!

что правильно?
я попросил конкретную вещь.
прибежало помогатель без этой вещи, но с неработающим скриптом из гугла.
пруфскрин нужен?
помогателя попросили больше не мусорить в этой теме.
помогатель обиделось, дал две ссылки, одна из которых мне была известна, другая - мертвая.

а рвз вы модератор, то, пожалуйста, сделайте свою модераторскую работу - удалите помогательские письмена, чтобы другие пользователи, нагуглив эту тему не стали тратить время на бесполезные советы.
сейчас я залью на сервер свой бэкап, и сам выложу нужный скрипт.

Оффлайн Haron Prime

  • Почётный модератор
  • Старожил
  • *
  • Сообщений: 11313
  • Нетолерантный социопат
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #10 : 31 Августа 2014, 14:57:05 »
Цитировать
Правила форума

2. На форуме ЗАПРЕЩЕНО
2.12.
Обсуждать действия модераторов и администрации в темах, не относящихся к этому напрямую. Для разрешения спорных ситуаций пользуйтесь личными сообщениями или разделом «Обсуждение форума».

+30%
следующее замечание - месяц read only!
--HP

Оффлайн numminorih

  • Новичок
  • *
  • Сообщений: 6
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #11 : 17 Февраля 2015, 17:49:52 »
Добрый день!

Столкнулся с той-же проблемой что и автор топика.
Грякнулся винт, пришлось ставить с 0-я систему (14.04 бунта), поднял старые мануалы, и вот не могу найти скриптик для запуска рторента в скрине при перезагрузке (до логина), который ранее был:

wget http://libtorrent.rakshasa.no/raw-attachment/wiki/RTorrentCommonTasks/rtorrentInit.sh

Гуглил, искал, лазил, не смогу найти, если у кого есть - просьба поделиться.

Спасибо.

Оффлайн sneres

  • Участник
  • *
  • Сообщений: 163
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #12 : 17 Февраля 2015, 18:24:51 »
https://code.google.com/p/wtorrent/downloads/detail?name=rtorrentInit.sh
На 14.04 не заработал почему то
пришлось ещё и в rclocal прописывать
« Последнее редактирование: 17 Февраля 2015, 22:50:33 от sneres »

Оффлайн numminorih

  • Новичок
  • *
  • Сообщений: 6
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #13 : 17 Февраля 2015, 18:56:08 »
http://libtorrent.rakshasa.no/downloads/rtorrent_init_script.sh

найти - нашёл, от того же разработчика, но при попытке запуска выдает:

deimos@chip % sudo /etc/init.d/rtorrent start                       (chip)17:53
cat: /home/chip/.rtorre: Нет такого файла или каталога
cannot find readable config /home/chip/.rtorre. check that it is there and permissions are appropriate


Пользователь решил продолжить мысль 17 Февраля 2015, 19:02:29:
code.google.com/p/wtorrent/downloads/detail?name=rtorrentInit.sh
На 14.04 не заработал почему то
пришлось ещё и в rclocal прописывать

а детальнее шаги можно?
« Последнее редактирование: 17 Февраля 2015, 19:02:29 от numminorih »

Оффлайн sneres

  • Участник
  • *
  • Сообщений: 163
    • Просмотр профиля
Re: поделитесь скриптом автостарта rtorrent.
« Ответ #14 : 17 Февраля 2015, 19:04:10 »
По идее .rtorrent.rc он должен найти и прочитать в home
Откройте скрипт редактором почитайте.может там криво что
сейчас на работе тяжело с телефона.если только вечером поздно
« Последнее редактирование: 17 Февраля 2015, 19:05:50 от sneres »

 

Страница сгенерирована за 0.084 секунд. Запросов: 26.