deluge-daemon script not working in karmic

General support for problems installing or using Deluge
Tenkian
New User
New User
Posts: 9
Joined: Wed Mar 11, 2009 11:08 am

deluge-daemon script not working in karmic

Post by Tenkian »

Hi. I upgraded last week to Ubuntu Server 9.10 from 9.04 and now the deluge-daemon script in /etc/init.d/ no longer works!

It was working perfectly before on 9.04 for months. I get no feedback when running "sudo /etc/init.d/deluge-daemon start" no deluged process when running "ps -A" and no error messages in the console. I also get no entries in the deluge log file.

This along with the proxying through apache2 no longer working are my main issues.

Any ideas?
markp1989
Member
Member
Posts: 21
Joined: Thu Sep 10, 2009 9:32 pm

Re: deluge-daemon script not working in karmic

Post by markp1989 »

it mite be because the new version of deluge in the ubuntu repos is the one with the new package names.

eg: the new deluge has deluge-web as a command rather then deluge -I web , so the script needs to be updated to suit the newest deluge way.

that all i can think of right now, im sure someone with more brains then me will be able to answer soon .
Tenkian
New User
New User
Posts: 9
Joined: Wed Mar 11, 2009 11:08 am

Re: deluge-daemon script not working in karmic

Post by Tenkian »

I managed to fix the script. The issue was the fact the script looks for 2 packages "deluged" and "deluge". As I am running a headless server I do not have "deluge" anymore as the webui has been separated.

I had to edit the script to remove all references to the "deluge" package and process. I am using the webui plugin for the daemon so that starts the webui.

Now the only issue I have is proxying through apache2 not working with ajax.
olmari
New User
New User
Posts: 6
Joined: Fri Nov 06, 2009 5:47 am

Re: deluge-daemon script not working in karmic

Post by olmari »

I have improved that debian/ubuntu script also so that deluged and deluge-webui runs as user "deluge" instead of an "real" user, this way deluge runs in it's own enviroment rather than with regular user credentials... Here is short instructions and needed files, I should update the wiki page too when I get the time to think it bulletproof...

BTW: This initscript runs webui at port 9092, you can ofcourse change that to suit your needs...

First I created an system-user for the deluge + created and chown the logfiles in /var/log:

Code: Select all

sudo adduser --disabled-password --system --home /var/lib/deluge --gecos "SamRo Deluge server" --group deluge
sudo touch /var/log/deluged.log
sudo touch /var/log/deluge-web.log
sudo chown deluge:deluge /var/log/deluge*
Then added Deluge PPA and installed needed programs:

Code: Select all

sudo echo 'deb http://ppa.launchpad.net/deluge-team/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/deluge-team/ppa/ubuntu karmic main' > /etc/apt/sources.list.d/deluge.list

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 249AD24C
sudo apt-get update && sudo apt-get install deluged deluge-webui
Then I prepared these initscript files:

/etc/default/deluge-daemon

Code: Select all

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

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

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

/etc/init.d/deluge-daemon

Code: Select all

#!/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 
# Modified: Sami Olmari

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Deluge Daemon"
NAME1="deluged"
NAME2="deluge-web"
DAEMON1=/usr/bin/deluged
DAEMON1_ARGS="-d -c /var/lib/deluge -l /var/log/deluged.log -L warning"
DAEMON2=/usr/bin/deluge-web
DAEMON2_ARGS="-p 9092 -c /var/lib/deluge -l /var/log/deluge-web.log -L warning"
PIDFILE1=/var/run/$NAME1.pid
PIDFILE2=/var/run/$NAME2.pid
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 --test > /dev/null
   RETVAL1="$?"
   start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --exec $DAEMON2 \
      --chuid $DELUGED_USER --user $DELUGED_USER --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 -- $DAEMON1_ARGS
   RETVAL1="$?"
        sleep 2
   start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile --exec $DAEMON2 \
      --chuid $DELUGED_USER --user $DELUGED_USER -- $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

:
And then chmodded the script to be executable and made the usual initscript preparations:

Code: Select all

sudo chmod 755 /etc/init.d/deluge-daemon
sudo update-rc.d deluge-daemon defaults
And that's it if I remember everything correctly... Now deluged+webui starts automatically on boot, and ofcourse you can start it manually with "sudo /etc/init.d/deluge-daemon start"...

I also made the download folder as world writable for easier maintaining... But one can do whatever he likes for setting up folders etc :)

ADD: I did modify the initscript "wikithread", please comment on me if there is something not matching up: http://dev.deluge-torrent.info/wiki/Use ... InitScript
agnaramasi
New User
New User
Posts: 4
Joined: Sun Dec 06, 2009 7:38 am

Re: deluge-daemon script not working in karmic

Post by agnaramasi »

When I use this init script to run the daemon as system user "deluge", all my downloads in the /var/lib/deluge folder appear as read-only for my normal user accounts and nfs clients. I'm wondering how to manage file permissions with this script. Any help you could give would be appreciated.
djbon2112
New User
New User
Posts: 3
Joined: Tue Dec 08, 2009 3:30 pm

Re: deluge-daemon script not working in karmic

Post by djbon2112 »

Hey guys. I'm trying to use olmari's script with the latest deluge in the Debian Sid repos (1.2_rc4), and it isn't working properly.

deuged starts, but not deluge-web. I can start it manually by starting the command with nohup, sudo and &, but the init script won't start it at all. Any ideas?
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: deluge-daemon script not working in karmic

Post by johnnyg »

This is probably due to the move to upstart: http://www.ubuntu.com/testing/karmic/beta#Upstart

Best solution would be to write an upstart script for deluge daemon and web ui.
djbon2112
New User
New User
Posts: 3
Joined: Tue Dec 08, 2009 3:30 pm

Re: deluge-daemon script not working in karmic

Post by djbon2112 »

Sorry, I didn't even realize I wasn't being replied to >.< I'm just not on a roll here!
Last edited by djbon2112 on Wed Dec 09, 2009 7:44 pm, edited 3 times in total.
djbon2112
New User
New User
Posts: 3
Joined: Tue Dec 08, 2009 3:30 pm

Re: deluge-daemon script not working in karmic

Post by djbon2112 »

Fail double post
olmari
New User
New User
Posts: 6
Joined: Fri Nov 06, 2009 5:47 am

Re: deluge-daemon script not working in karmic

Post by olmari »

djbon2112 wrote:Hey guys. I'm trying to use olmari's script with the latest deluge in the Debian Sid repos (1.2_rc4), and it isn't working properly.

deuged starts, but not deluge-web. I can start it manually by starting the command with nohup, sudo and &, but the init script won't start it at all. Any ideas?
Hmm... Have you realised that mine script starts deluge-web at port 9092 instead of default? Other than that I don't know, Mine script is made on 9.10 Ubuntu Karmic server with new deluge 1.2.0 and it works... :-/
agnaramasi wrote:When I use this init script to run the daemon as system user "deluge", all my downloads in the /var/lib/deluge folder appear as read-only for my normal user accounts and nfs clients. I'm wondering how to manage file permissions with this script. Any help you could give would be appreciated.
That's why I said what I said at very end at mine post ;) Personally I'd put downloads anyways into whole another folder than the "deluge user home" (/var/lib/deluge), but as also said, file permissions aren't mine best area of expertise... Simple umask rule could be enough but I have no idea about those... Someone more knowledgeable should instruct on this...

Anyways, Mine instructions at the wiki is not strictly only about initscript, it includes installing new deluge and setting up user for it, but afaik it's all worth it.. No daemon should be run at user priviledges nor any other priviledges than on it's own little sandbox...

ADD: Upstart could definately do that too I think, again some area that I have been missed alltogether :)
Post Reply