@bakhritdinov_b

Rtorrent multi user?

Привет всем! не могу найти bash скрипт для запуска несколько пользователей одновременно!
Вот сам init:

#!/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="bobur"

## 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


Как сделать это multi user? чтоб он запускал одновременно несколько пользователей.
  • Вопрос задан
  • 369 просмотров
Решения вопроса 1
@Vasily_Pechersky
Системщик с опытом
Я прочитав инструкцию, приведенную вами, так ничего и не понял.
Но мелькнул проблеск, что конфиг в /home/$user/.rtorrent.rc

то есть вам надо кол-во старт скриптов по кол-ву пользователей.
Или скрипт, который ходит по всем хомам и запускает от туда приведённый выше скрипт с изменениями.

В каждом следующие изменения:
USER="bobur1" #нужное имя ползователя
PIDFILE="/var/run/rtorrent_$USER.pid"
SOCKET="/var/run/rtorrent/rpc_$USER.socket"

См программирование на Баше. Я в нём не силён.
Ответ написан
Пригласить эксперта
Ответы на вопрос 2
hobbyte
@hobbyte
изменить init-скрипт подобно how to run multiple instances of dnscrypt-proxy?
Ответ написан
gbg
@gbg Куратор тега Linux
Любые ответы на любые вопросы
Задать разный USER=XXX, сам скрипт переименовать несколько раз и столько же раз запустить.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы