[GUIDE] Install Deluged Torrent Server 1.3.5

YOU USE THIS GUIDE AT YOUR OWN RISK

INSTALLING THIS WILL VOID YOUR WARRANTY

 

You may want to take a look at my guide on how to reinstall a fresh OS if you run into issues

http://community.wdc.com/t5/My-Book-Live/GUIDE-Restore-Downgrade-firmware-via-the-reset-button/m-p/481588#M15044

What is Deluge?

Deluge is a lightweight, Free Software , cross-platform BitTorrent client.

  • Full Encryption
  • WebUI
  • Plugin System
  • Much more…

Issues

Need to get the Block List working (This may be working now)


With that being said let’s get on with the guide

Run this command to remove the claims the MBL puts on some system files

rm -f /var/lib/dpkg/info/wd-nas.*

We are gonna install from the wheezy, experimental and non-free repos so edit your sources.list and comment out all repos except for deb wheezy main, deb experimental main and deb wheezy main contrib non-free by putting a # at the beginning of any other repos

nano /etc/apt/sources.list

 You want it to look like this

#deb http://ftp.us.debian.org/debian/ squeeze maindeb http://ftp.us.debian.org/debian/ wheezy main#deb-src http://ftp.us.debian.org/debian/ wheezy main#deb http://ftp.us.debian.org/debian/ sid maindeb http://ftp.us.debian.org/debian/ experimental maindeb http://ftp.us.debian.org/debian/ wheezy main contrib non-free

Once the sources.list is edited

Hit control and o

Hit enter

Hit control and x

This will save the updated file

Now update your sources and install these packages

apt-get update
apt-get install python2.7 python-libtorrent python-openssl python-twisted-core python-twisted-web deluge-common deluge-web deluged unrar

Now let’s update deluged and the webui from 1.3.3 to 1.3.5

aptitude -t experimental install deluged deluge-web

You will get the following message, just type Yes when prompted

Untrusted packages could compromise your system's security.
You should only proceed with the installation if you are certain that
this is what you want to do.

  deluge-common deluge-web deluged

Do you want to ignore this warning and proceed anyway?
To continue, enter "Yes"; to abort, enter "No": Yes

Now let’s create a deluge daemon file

nano /etc/default/deluge-daemon

 Paste the following info into the empty nano window (right mouse click)

# Configuration for /etc/init.d/deluge-daemon

# The init.d script will only run if this variable non-empty.
DELUGED_USER="root"

# Should we run at startup?
RUN_AT_STARTUP="YES"

Hit control and o

Hit enter

Hit control and x

This will save the updated file

Now let’s create the auto-start script

nano /etc/init.d/deluge-daemon

 Paste the following code into the empty nano windows (right mouse click)

#!/bin/sh
### BEGIN INIT INFO
# Provides: deluge-daemon
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Daemonized version of deluge and webui.
# Description: Starts the deluge daemon with the user specified in
# /etc/default/deluge-daemon.
### END INIT INFO

# Author: Adolfo R. Brandes 

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Deluge Daemon"
NAME1="deluged"
NAME2="deluge"
DAEMON1=/usr/bin/deluged
DAEMON1_ARGS="-d" # Consult `man deluged` for more options
DAEMON2=/usr/bin/deluge-web
DAEMON2_ARGS="" # Consult `man deluge-web` for more options
PIDFILE1=/var/run/$NAME1.pid
PIDFILE2=/var/run/$NAME2.pid
UMASK=022 # Change this to 0 if running deluged as its own user
PKGNAME=deluge-daemon
SCRIPTNAME=/etc/init.d/$PKGNAME

# Exit if the package is not installed
[-x "$DAEMON1" -a -x "$DAEMON2"] || exit 0

# Read configuration variable file if it is present
[-r /etc/default/$PKGNAME] && . /etc/default/$PKGNAME

# Load the VERBOSE setting and other rcS variables
[-f /etc/default/rcS] && . /etc/default/rcS

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

if [-z "$RUN_AT_STARTUP" -o "$RUN_AT_STARTUP" != "YES"]
then
   log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it."
   exit 0
fi

if [-z "$DELUGED_USER"]
then
    log_warning_msg "Not starting $PKGNAME, DELUGED_USER not set in /etc/default/$PKGNAME."
    exit 0
fi

#
# Function that starts the daemon/service
#
do_start()
{
   # Return
   # 0 if daemon has been started
   # 1 if daemon was already running
   # 2 if daemon could not be started
   start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --exec $DAEMON1 \
      --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK --test > /dev/null
   RETVAL1="$?"
   start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --exec $DAEMON2 \
      --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK --test > /dev/null
   RETVAL2="$?"
   ["$RETVAL1" = "0" -a "$RETVAL2" = "0"] || return 1

   start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --make-pidfile --exec $DAEMON1 \
      --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON1_ARGS
   RETVAL1="$?"
        sleep 2
   start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile --exec $DAEMON2 \
      --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON2_ARGS
   RETVAL2="$?"
   ["$RETVAL1" = "0" -a "$RETVAL2" = "0"] || return 2
}

#
# Function that stops the daemon/service
#
do_stop()
{
   # Return
   # 0 if daemon has been stopped
   # 1 if daemon was already stopped
   # 2 if daemon could not be stopped
   # other if a failure occurred

   start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE2
   RETVAL2="$?"
   start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE1
   RETVAL1="$?"
   ["$RETVAL1" = "2" -o "$RETVAL2" = "2"] && return 2

   rm -f $PIDFILE1 $PIDFILE2

   ["$RETVAL1" = "0" -a "$RETVAL2" = "0"] && return 0 || return 1
}

case "$1" in
  start)
   ["$VERBOSE" != no] && log_daemon_msg "Starting $DESC" "$NAME1"
   do_start
   case "$?" in
      0|1) ["$VERBOSE" != no] && log_end_msg 0 ;;
      2) ["$VERBOSE" != no] && log_end_msg 1 ;;
   esac
   ;;
  stop)
   ["$VERBOSE" != no] && log_daemon_msg "Stopping $DESC" "$NAME1"
   do_stop
   case "$?" in
      0|1) ["$VERBOSE" != no] && log_end_msg 0 ;;
      2) ["$VERBOSE" != no] && log_end_msg 1 ;;
   esac
   ;;
  restart|force-reload)
   log_daemon_msg "Restarting $DESC" "$NAME1"
   do_stop
   case "$?" in
     0|1)
      do_start
      case "$?" in
         0) log_end_msg 0 ;;
         1) log_end_msg 1 ;; # Old process is still running
         *) log_end_msg 1 ;; # Failed to start
      esac
      ;;
     *)
        # Failed to stop
      log_end_msg 1
      ;;
   esac
   ;;
  *)
   echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
   exit 3
   ;;
esac

:

Hit control and o

Hit enter

Hit control and x

This will save the updated file

Change the script permissions

chmod 755 /etc/init.d/deluge-daemon

 Run this command so the program auto starts at boot and on reboots

update-rc.d deluge-daemon defaults

 Ok now let’s start Deluge!

/etc/init.d/deluge-daemon start

In your web-browser let’s connect to the web-ui

http://your MBL name or IP:8112
password= deluge

Connection Manager will now pop up
Select the server and hit connect

When asked, change the password and hit the Change button

Go to preferences and make any changes you need starting with download paths

Download to:

/DataVolume/shares/Public/Deluge

Click Plugins and tick the Execute box and click apply and ok

Logout (Top right corner) and then login again with your password

Go back to Preferences and you should now see Execute at the bottom of the list

Click Execute and then Add an event

Change Event to Torrent Complete

In the command box type

/usr/local/sbin/unrar.sh

 Now we have to create a script

nano /usr/local/sbin/unrar.sh

 And paste the following

#!/bin/bash
formats=(zip rar)
commands=([zip]="unzip -u" [rar]="unrar -o- e")
extraction_subdir='extracted'

torrentid=$1
torrentname=$2
torrentpath=$3

log()
{
    logger -t deluge-extractarchives "$@"
}

log "Torrent complete: $@"
cd "${torrentpath}"
for format in "${formats[@]}"; do
    while read file; do 
        log "Extracting \"$file\""
        cd "$(dirname "$file")"
        file=$(basename "$file")
        # if extraction_subdir is not empty, extract to subdirectory
        if [[! -z "$extraction_subdir"]] ; then
            mkdir "$extraction_subdir"
            cd "$extraction_subdir"
            file="../$file"
        fi
        ${commands[$format]} "$file"
    done < <(find "$torrentpath/$torrentname" -iname "*.${format}" )
done

Hit control and o

Hit enter

Hit control and x

This will save the updated file

Now set the permissions

chmod 755 /usr/local/sbin/unrar.sh

Now we can install a blocklist by downloading the emule blocklist from here

http://hostex.de/1316700423

Once you download it, extract the .dat file inside to your hard drive

Now go to the Deluged web-ui and select Preferences/Plugins/Install

Browse to the ipfilter.dat and click install

Restart Deluged (Important or the unrar script won’t work and blocklist might not be active)

/etc/init.d/deluge-daemon restart

Deluge plugins can be found at

http://dev.deluge-torrent.org/wiki/Plugins

2 Likes

UPDATED

I have managed to get everything upgraded to 1.3.5 so that magnet links are working and have modified the guide accordingly

I think I got a emule ipfilter.dat working but I need feedback on whether it’s working or not

Unrar script fixed, it’s very basic though as everything goes into the extracted folder

I need someone who uses torrents to verify the ipfilter.dat is working :slight_smile:

Any user tweaks are welcome and I will update the guide giving you full credit

I think I’m done with this one for now minus any user suggested changes

Hi nfo, thanks for another great guide!

I’ll stay on Transmission though, as Deluge is known for using quite a lot more of resources, while Transmission is as lightweight as possible with good features (i.e. it’s not the command line rTorrent!)

Kudos to you!

EDIT: By the way, how magnet links works? You click a link on your computer browser and it gets added to the remote Deluge, or do you have to copy and paste the link manually in the web interface?

Copy and paste but I think there may be some browser plugins to sent it straight to the server but I’m not positive.

Actually Deluged is VERY light-weight as well as it’s just basically a daemon with the web-ui installed to control the daemon.

This isn’t a full blown Deluge install which I tried as well and it wanted to install a couple hundred megs of data.

Downloads also seem to be alot faster

Have you compared it in memory consumption, CPU usage, etc. to the good-ol’ Transmission?

Check  this comparison (although it’s mostly about UI) and  this one. As they also point out, Deluge is based on python instead of pure C, plus adding another layer of stuff to install and behave as the interpreter for Deluge, instead of running natively in C.

I didn’t check memory and cpu consumption but it ran smooth as silk. I actually prefer Transmission myself. I just put this guide together because I was bored and felt like playing :slight_smile: Once I was done I rolled back to my custom OS again :slight_smile:

You are correct in that deluged is heavily dependent on Python. It has a BUNCH of dependencies and modifies the OS big time.

Any way of that creating/rolling back to a customized firmware that I read many times from your but for the Live Duo?

I imagine you are imaging the disk and restoring back, or something like that?

Yeah you just use dd to image either md0 or md1 whichever is the active raid array and it creates a file the same size as the rootfs.img file found inside a MyBookLive firmware .deb

Then I just use the resetbutton upgrade downgrade restore script to install that custom firmware image back. I’m pretty sure it would work on the MBL DUO but I don’t have a unit to test it on.

If you feel like trying it sometime, here is the link

http://community.wdc.com/t5/My-Book-Live/GUIDE-Build-a-Custom-Firmware/m-p/533729/highlight/true#M18066

nfo, nice guide, Thanks.

I did everything on it, and I ran into two issues.

The first one would be that I cannot access my MBL dashboard anymore… This is not a big trouble for now, cause i can still access my shares on all my devices… Though I think it will be a bit of a deal later.

The second one is torrents wise, when added they just won’t start downloading. I’m smelling a router problem, or a forwarding ports problem.

I wouldn’t know what kind of information would you need to know more about the environment of my problem. please ask me and I will let u guys know more about it.

Well we should start with your dashboard issue as that’s more important than Deluged right now. Use my resetbutton script to get back to a clean OS. Here is the guide…

http://community.wd.com/t5/My-Book-Live/GUIDE-Restore-Downgrade-firmware-via-the-reset-button/m-p/481588

In the meantime I will take another look at the guide and see if I can replicate your issue. What firmware version are you on?

1 Like

I can’t reproduce your issues, I followed the guide and installed it again on a test MyBookLive and Torrents download fine and the dashboard works great. I even restarted apache just to be sure.

Are you sure you ran this command?

rm -f /var/lib/dpkg/info/wd-nas.*

 Otherwise it’s possible that one of the packages bricked your dashboard

As far as ports go, click preferences and network and untick use random ports and set a manual port range and forward those same ports on your router to your MyBookLive IP

Nfo,

Hi I appreciats your swift answer, I’ve been busy a work but I’ll have some 4 days free and I’ll get to this as soon as i finish posting this.
 That been said.

Yes I ran the command above, I followed the guide step by step… But I’ve beign thinkin that it maybe the fact that I’m behind the greatwall of china… do you thnk this might be the issue? or the fact that,

Before runnin into your guide i ran a simple:

apt-get install deluge

 and then it couldn’t do it because there were not enough space for the repositories and I edited a file (don’t remember the name) in which I added a line to expand the repositories available space.

the deluge didn’t work then ran into your guide and followed it.

Hi, I decided to use the guide 3 of the downgrade guide but this step confuses me.

5) Copy rootfs.img to the root of your Public folder on the MyBookLive

 Does this mean?

/shares/Public

or

/DataVolume/shares/Public

or these are the same?

Please bare with me and my noobiness

They are the same. You can actually just open the Public share from Windows network and drag and drop it in the folder that way. You don’t need to use WinSCP or similar to do it.

I think your original apt-get install deluge is what bricked you. If I recall correctly, it bricked my dashboard when I installed it that way before I put this guide together.

1 Like

Ok, downgrade completed. dashboard available now and configured!

All my pc’s are on linux.

So, I’m going to try to install deluge again.

I’ll keep you posted

one more thing before trying the installation

The dashboard wants to upgrade the firmware, should i do it? the one that I used with the downgrade.sh was this               ----> http://download.wdc.com/nas/apnc-023205-046-20120910.deb

Yep I would upgrade. You should have no issues :slight_smile:

1 Like

I don’t use torrents very often but I do keep Transmission installed for the occasional Torrent. Let me know how Deluged works out for you as not many people have really commented on this guide.