rtorrent and screen helps

Soldato
Joined
7 Jan 2007
Posts
10,608
Location
Sussex, UK
Hiya,

So my home server project goes on :p

ok, settled on using rtorrent, must say it is totally awesome!! Just have a couple of easy to fix issues.

#No. 1

How do I stop uploads between 8am to midnight everyday?

Currently I have it all set to download at 1kb and upload at 1kb between 8am and midnight.

I understand 0 is not stop but means unlimited upload/download. is that right?

#No. 2

How do I use screen to leave rtorrent running when i close ssh?

#No 3

How do i make a script to autostart rtorrent with screen at bootup in ubuntu server? I know its summit to do with init.d :p
 
Good choice its the best torrent client :) I can help with #2

No.2: "screen rtorrent" press ctrl+a+d to suspend the screen once its running, this will make it run in the background when you terminate the SSH session. run "screen -r" to resume the session later.
 
Code:
#
#!/bin/bash
#
 
#
# A simple RTorrent initscript for debian-based distros
#
# Distributed as-is, no warranties
#
# Comments, ideas etc - mail me - ivan4groznij [at] gmail [dot] com
#
# Based upon http://mehulved.wordpress.com/2008/07/16/start-rtorrent-using-init-scripts/
#
# Requires GNU Screen
#
# This script does not perform any checks, i.e. wether the user exists, is screen installed etc
#
 
#
# The user to run rtorrent as
#
RTUSER=enter your username here
#
 
#
# Paths to different binaries
#
RTORRENT=/usr/local/bin/rtorrent
#
KILL=/bin/kill
#
SCREEN=/usr/bin/screen
#
 
#
# PIDfile path
#
PIDFILE=/var/run/rtorrent.pid
#
 
#
start_rt()
#
{
#
    echo -n "Starting rtorrent... "
#
    start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --chuid $RTUSER --exec $SCREEN -- -DmUS torrent $RTORRENT
#
    if [ $? -eq 0 ]; then
#
        echo "success!"
#
        echo "To interact with the torrent client, you will need to reattach the screen session with following command:"
#
        echo "    screen -r torrent"
#
    else
#
        echo "fail!"
#
    fi
#
}
#
 
#
stop_rt()
#
{
#
    echo -n "Stopping rtorrent... "
#
    start-stop-daemon --stop --pidfile $PIDFILE
#
    if [ $? -eq 0 ]; then
#
        echo "The process stopped successfully"
#
    else
#
        echo "The process failed to stop"
#
    fi
#
}
#
 
#
status_rt()
#
{
#
    echo -n "Status: "
#
    PID=`cat $PIDFILE`
#
 
#
    # Check if the process with the specified PID exists
#
    # kill -0 will return 0 if the process exists
#
    $KILL -0 $PID
#
    if [ $? -eq 0 ]; then
#
        echo "started"
#
        return 0
#
    else
#
        echo "stopped"
#
        return 1
#
    fi
#
 
#
}
#
 
#
restart_rt_if_needeed()
#
{
#
    # Seems like Rtorrent sometimes crashes. This function
#
    # restarts rtorrent if it's not running
#
    status_rt
#
    if [ $? -ne 0 ]; then
#
        echo "Rtorrent is not running. Restart needed"
#
        stop_rt
#
        start_rt
#
    else
#
        echo "Restart is not needed"
#
    fi
#
}
#
 
#
case "$1" in
#
    start)
#
        start_rt
#
    ;;
#
    stop)
#
        stop_rt
#
    ;;
#
    restart)
#
        stop_rt
#
        start_rt
#
    ;;
#
    restart_if_needed)
#
        restart_rt_if_needeed
#
    ;;
#
    status)
#
        status_rt
#
    ;;
#
    *)
#
        echo "Usage: {start|stop|restart|status|restart_if_needed}"
#
    ;;
#
esac

proper bo
 
Back
Top Bottom