Howto: testing 0.6 using deluged + webui (headless *nix)

General support for problems installing or using Deluge
cvig
Member
Member
Posts: 13
Joined: Sun Mar 09, 2008 7:24 am

Howto: testing 0.6 using deluged + webui (headless *nix)

Post by cvig »

I spent some time this evening getting deluged running with the webui client on my headless server. As the information is scarce here I'll post my exact steps. This is a "lets get it running quick to see how it is" so deluged is run as root (typically, an ill-advised method :)).

Installation
1) Install the 0.6 branch from svn:

Code: Select all

cd /usr/src
svn co http://svn.deluge-torrent.org/branches/deluge-0.6 deluge-0.6
cd deluge-0.6
python setup.py build
python setup.py install
2) Setup deluged to run when server is booted. Add these lines to your /etc/inittab file (be very careful when editing this file -- make a backup before editing like so: "cp /etc/inittab /etc/inittab-save"):

Code: Select all

# run deluged (on port 58846) with logging to /var/log/deluged.log
dd:5:respawn:/usr/bin/deluged -d -p 58846 &> /var/log/deluged.log
3) Setup deluge client with webui to run when server is booted. Add these lines to your /etc/inittab file (again, be careful):

Code: Select all

# run deluge webui with logging to /var/log/deluge-webui.log
dw:5:respawn:/usr/bin/deluge -u web &> /var/log/deluge-webui.log
4) Kick off by the server and the client:

Code: Select all

telinit q
To see what is happening with deluged and the client simply run:

Code: Select all

tail -f /var/log/deluged.log
tail-f/var/log/deluge-webui.log
To connect to the web interface in your browser use an URL like this one:

Code: Select all

http://192.168.1.1:8112
Where 192.168.1.1 is replaced with the IP of your server. I'm assuming that deluge w/ webui uses port 8112 by default but I don't know (to find out, do "cat /var/log/deluge-webui.log" and it should say in the output what port it is running on -- at least for the first run). The default password is "deluge".

Bugs
- the client insisted my "Store all downoads in:" directory did not exist. I had to edit ~/.config/deluge/core.conf from this:

Code: Select all

sS'download_location'
p21
S'/root'
p22
to this:

Code: Select all

sS'download_location'
p21
S'/mnt/sdb/torrents'
p22
Of course, replace /mnt/sdb/torrents with wherever you want to store the downloads. Remember such bugs are to be expected as 0.6 is still in development. Reporting bugs is good. Complaining about bugs in development versions is very rude.

Security
Setting up deluge this way is bad because everything runs as root on the server. Lets setup deluge to run under a user account with a name of "dtor". I'm assuming the "dtor" user already exists (if not, consult your documentation on how to add a user and make sure the user is added with a home directory).
1) Create a directory in /var/log for logging that is owned by "dtor" (so the deluge process can write to it):

Code: Select all

mkdir /var/log/deluge
chown -R dtor:users /var/log/deluge
2) Edit /var/inittab to run the deluged and "deluge -u webui" as the "dtor" user from this:

Code: Select all

# run deluged (on port 58846) with logging to /var/log/deluged.log
dd:5:respawn:/usr/bin/deluged -d -p 58846 &> /var/log/deluged.log
# run deluge webui with logging to /var/log/deluge-webui.log
dw:35:respawn:/usr/bin/deluge -u web &> /var/log/deluge-webui.log
To this:

Code: Select all

# run deluged (on port 58846) with logging to /var/log/deluged.log
dd:5:respawn:su - dtor -c "/usr/bin/deluged -d -p 58846 &> /var/log/deluge/deluged.log"
# run deluge webui with logging to /var/log/deluge-webui.log
dw:5:respawn:su - dtor -c "/usr/bin/deluge -u web &> /var/log/deluge/deluge-webui.log"
One last gotcha
In the commands above that we put in /etc/inittab they all have a "5" as the second field. This is because my default runlevel is 5. It says so at the top of my /etc/inittab like so:

Code: Select all

# Default runlevel.
id:5:initdefault:
Yours might be different. You can just replace 5 with "345" and do "telinit -q" to get init to reprocess /etc/inittab.

No need to reboot
When you want to stop deluge, just edit /etc/inittab and put a "#" at the front of each line that starts a deluge process. Then at the shell as root run "telinit -q" and the processes will stop. When you want to launch deluge, simply remove the comment and run "telinit -q" again.

Help?
Got stuck? I'll try to check this thread. A good place to start is to first make sure you can run deluged and the client (using either "deludge -u webui" or "deluge -u null").

Remember you are testing a development branch. Do not complain when bugs are encountered but do check the bugs db to see if they have been reported and if not report the bug so that the developers are aware of it (I'm assuming that is the standard procedure on this project but I'm new so if I got it wrong please post).

Bug reports/tickets are here: http://dev.deluge-torrent.org/report
Last edited by cvig on Sun Mar 09, 2008 9:17 am, edited 1 time in total.
cvig
Member
Member
Posts: 13
Joined: Sun Mar 09, 2008 7:24 am

Re: Howto: testing 0.6 using deluged + webui (headless server)

Post by cvig »

One additional catch is that running the process this way as root from inittab means the "~/.config" is actually in / (so it'll be in "/.config" unless you symlink your .config directory to /). So running it as root is messy beyond just the security issues.
andar
Top Bloke
Top Bloke
Posts: 1050
Joined: Fri Jun 08, 2007 8:38 pm
Location: Victoria, BC
Contact:

Re: Howto: testing 0.6 using deluged + webui (headless server)

Post by andar »

Why are you running deluge as root? This is ill-advised.
cvig
Member
Member
Posts: 13
Joined: Sun Mar 09, 2008 7:24 am

Re: Howto: testing 0.6 using deluged + webui (headless server)

Post by cvig »

andar wrote:Why are you running deluge as root? This is ill-advised.
Adding security adds complexity so I prefer to explain how to do something without it first. The first post has all the details on running as non-root. I don't advise running as root either.

I just made the switch so my deluge processes are running as a "deluge" user :).
andar
Top Bloke
Top Bloke
Posts: 1050
Joined: Fri Jun 08, 2007 8:38 pm
Location: Victoria, BC
Contact:

Re: Howto: testing 0.6 using deluged + webui (headless server)

Post by andar »

cvig wrote:
andar wrote:Why are you running deluge as root? This is ill-advised.
Adding security adds complexity so I prefer to explain how to do something without it first. The first post has all the details on running as non-root. I don't advise running as root either.

I just made the switch so my deluge processes are running as a "deluge" user :).
Thanks for the Howto. I have stickied this topic.
oshiri
Member
Member
Posts: 40
Joined: Thu Nov 29, 2007 10:34 am

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by oshiri »

This is my startup script for Debian which allow you to run as user rather then root. You need start-stop-daemon.
For other distro you probably can use start-stop-daemon from here: http://www.math.ias.edu/doc/SysVinit-2. ... p-daemon.c
I named this script deluge-daemon and placed it in /etc/init.d :

Code: Select all

#!/bin/sh
# created by mambang
# Headless deluge startup script
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DELUGE="/usr/bin/deluge" #replace with actual path if different
#WEBDAEMON="/usr/share/python-support/deluge-torrent/deluge/ui/webui/webui_plugin/run_webserver06" #use this if you are using nightly build
WEBDAEMON="/usr/lib/python2.4/site-packages/deluge-0.6.0.0-py2.4-linux-i686.egg/deluge/ui/webui/run_webserver06"   # use this if you manually compile it yourself against python 2.4
USER="Your User Name"  # please change 

DELUGEDAEMON="/usr/bin/deluged"  #change to actual path if different
DESC1="Deluge Daemon"
DESC2="WebUi"
NAME1="deluged"
NAME2="Deluge webserver"

set -e


case "$1" in
  start)
        echo -n "Starting $DESC1 : "
        start-stop-daemon -c $USER --start --background --quiet --exec $DELUGEDAEMON
        echo "$NAME1"
        sleep 2
        echo -n "Starting $DESC2 : "
        start-stop-daemon -c $USER --start --background --quiet --exec $WEBDAEMON
        echo "$NAME2"
        ;;
  stop)
        echo -n "Stopping $DESC1 : "
        PIDDELUGE=`ps ax |grep deluged |sed -n 1p |awk '{print $1}'`
        kill $PIDDELUGE
        echo "$NAME1."
        echo -n "Stopping $DESC2 : "
        PIDWEB=`ps ax |grep run_webserver06 |sed -n 1p |awk '{print $1}'`
        kill $PIDWEB
        echo "$NAME2."
        ;;
  *)
        N=deluge-daemon
        echo "Usage: $N {start|stop}" >&2

        exit 1
        ;;
esac

exit 0
Don't forget to chmod the script and update your init.

Code: Select all

# chmod +x /etc/init.d/deluge-daemon
# update-rc.d -f deluge-daemon defaults
Example:
# /etc/init.d/deluge-daemon start
Starting Deluge Daemon : deluged
Starting WebUi : Deluge webserver
ps aux |grep deluge
oshiri 29414 4.1 0.9 95168 7316 ? Ssl 18:50 0:01 python /usr/lib/python2.4/site-packages/deluge-0.6.0.0-py2.4-linux-i686.egg/deluge/ui/webui/run_webserver06
oshiri 29429 3.4 2.6 95124 20496 ? Sl 18:50 0:01 /usr/bin/python /usr/bin/deluged -d
root 30042 0.0 0.0 4820 712 pts/2 S+ 18:50 0:00 grep deluge
# /etc/init.d/deluge-daemon stop
Stopping Deluge Daemon : deluged.
Stopping WebUi : Deluge webserver.
cvig
Member
Member
Posts: 13
Joined: Sun Mar 09, 2008 7:24 am

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by cvig »

oshiri wrote:This is my startup script for Debian which allow you to run as user rather then root.
To be 100% clear there is instructions in the first post using the /etc/inittab and running deluge as a non-root user:

Code: Select all

# run deluged (on port 58846) with logging to /var/log/deluged.log
dd:5:respawn:su - dtor -c "/usr/bin/deluged -d -p 58846 &> /var/log/deluge/deluged.log"
# run deluge webui with logging to /var/log/deluge-webui.log
dw:5:respawn:su - dtor -c "/usr/bin/deluge -u web &> /var/log/deluge/deluge-webui.log"
The key is the "su - USERNAME -c "program_to_run &> logfile".

Of course, the /etc/init.d method works well too and is less invasive. I'll give your script a shot here (using Gentoo). Thanks for sharing it!
mvoncken
Developer
Developer
Posts: 225
Joined: Mon Sep 03, 2007 9:38 pm

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by mvoncken »

oshiri,

Don't use "run_webserver06", it contains some debugging stuff for development.
"deluge -u web" should work better.
dev: webui, core, labels | irc:vonck7 |
oshiri
Member
Member
Posts: 40
Joined: Thu Nov 29, 2007 10:34 am

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by oshiri »

mvoncken wrote:oshiri,

Don't use "run_webserver06", it contains some debugging stuff for development.
"deluge -u web" should work better.
At first, I intend to use "deluge -u web" or "deluge --ui=web" but I can't figure out how to do it with start-stop-daemon as it took deluge's option as it's own option.
The only way you can do this is by editing ui.conf and change it to:

Code: Select all

(dp1
S'selected_ui'
p2
S'web'
p3
s.
Then you can use "deluge" without "-u web" or "--ui-web"

So change the script as:

Code: Select all

WEBDAEMON="/usr/bin/deluge"

Code: Select all

  stop)
        echo -n "Stopping $DESC1 : "
        PIDDELUGE=`ps ax |grep deluged |sed -n 1p |awk '{print $1}'`
        kill $PIDDELUGE
        echo "$NAME1."
        echo -n "Stopping $DESC2 : "
        PIDWEB=`ps ax |grep deluge |sed -n 2p |awk '{print $1}'`
        kill $PIDWEB
        echo "$NAME2."
        ;;
cvig
Member
Member
Posts: 13
Joined: Sun Mar 09, 2008 7:24 am

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by cvig »

oshiri wrote:
mvoncken wrote:oshiri,

Don't use "run_webserver06", it contains some debugging stuff for development.
"deluge -u web" should work better.
At first, I intend to use "deluge -u web" or "deluge --ui=web" but I can't figure out how to do it with start-stop-daemon as it took deluge's option as it's own option.
This should work:

Code: Select all

                DELUGE_OPTIONS="-u web &> /var/log/deluge/deluge-webui.log"
                start-stop-daemon --start --quiet --background \
                --exec /usr/bin/deluge -- ${DELUGE_OPTIONS}
The man page for start-stop-daemon mentions this too but it is cryptic (start-stop-daemon -S|--start options [--] arguments).
Post Reply