B
B
Bobur Bakhritdinov2016-08-27 08:59:56
linux
Bobur Bakhritdinov, 2016-08-27 08:59:56

Rtorrent multiuser?

Hi all! can't find bash script to run multiple users at the same time!
Here is the init itself:

#!/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 ; 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 ; 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 ; 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

How to make it multi user? so that it runs several users at the same time.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vasily Pechersky, 2016-08-27
@bakhritdinov_b

After reading the instructions you provided, I didn't understand anything.
But a glimpse flashed that the config is in /home/$user/.rtorrent.rc
, that is, you need the number of start scripts for the number of users.
Or a script that walks through all the homs and launches the script above with changes from there.
Each has the following changes:
USER="bobur1" #desired username
PIDFILE="/var/run/rtorrent_$USER.pid"
SOCKET="/var/run/rtorrent/rpc_$USER.socket"
See Bash programming. I'm not strong in it.

H
hobbyte, 2016-08-27
@hobbyte

change init script like how to run multiple instances of dnscrypt-proxy ?

A
Armenian Radio, 2016-08-27
@gbg

Set different USER=XXX, rename the script itself several times and run the same number of times.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question