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

Support for any problems installing or running Deluge

Moderators: johnnyg, loki, andar

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

Postby johnnyg on Wed Sep 10, 2008 11:20 am

you should be able to ssh in and run
Code: Select all
deluge -u gtk
to do this
johnnyg
Top Bloke
Top Bloke
 
Posts: 1277
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

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

Postby xternal on Thu Sep 11, 2008 8:50 am

Thanks for the reply, doesnt seem to work though, no -u option :(
Also the script is asking for /usr/bin/deluged but i dont have that
Thanks for all the information so far.
xternal
New User
New User
 
Posts: 2
Joined: Wed Sep 10, 2008 10:04 am

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

Postby johnnyg on Thu Sep 11, 2008 9:31 am

what version are you running?
this howto was for version 0.6 (i.e. the latest RCs).
the latest version has installs deluged (deluge daemon) and definitely supports the -u option.
johnnyg
Top Bloke
Top Bloke
 
Posts: 1277
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

deluge init script ubuntu

Postby mcuerdo on Sun Nov 09, 2008 8:59 am

Hi, I just want to share the init script I'm using. If anyone knows how to improve it, please do!:

Code: Select all
#! /bin/sh
### BEGIN INIT INFO
# Provides:          deluged
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: Start/Stop Deluge Daemon
# Description:       Deluge Bitorrent Daemon
### END INIT INFO

# Author: Nanet <nanet.public-at-gmail.com>
#
# Edit to match your config, test it, and when you're satisfied
# run "sudo update-rc.d deluge-daemon defaults" to install the system script

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="Deluge Bitorrent Daemon"
NAME=deluged
########## Change logfile if needed
LOGFILE=/var/log/deluge/deluged.log
DAEMON=/usr/bin/$NAME
DAEMON_ARGS="--logfile=$LOGFILE"
RUNDIR=/var/run/$NAME
########## For the moment deluge does not support pid file
PIDFILE=$RUNDIR/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
########## Change priority (the lower the higher)
NICE=5
########## Change user to match yours
USER=nas

#mkdir -p $RUNDIR
#chown -R $USER $RUNDIR

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

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

# 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

#
# 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
   
   ####### Once deluge supports pid file we must check the following line and other calls to start-stop-daemon
   #start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER --nicelevel $NICE --exec $DAEMON"
   
   start-stop-daemon --start --quiet --chuid $USER --nicelevel $NICE --exec $DAEMON --test > /dev/null \
      || return 1
   start-stop-daemon --start --quiet --chuid $USER --nicelevel $NICE --exec $DAEMON -- \
      $DAEMON_ARGS \
      || return 2
   # Add code here, if necessary, that waits for the process to be ready
   # to handle requests from services started subsequently which depend
   # on this one.  As a last resort, sleep for some time.
}

#
# 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 --chuid $USER --name $NAME
   RETVAL="$?"
   [ "$RETVAL" = 2 ] && return 2
   # Wait for children to finish too if this is a daemon that forks
   # and if the daemon is only ever run from this initscript.
   # If the above conditions are not satisfied then add some other code
   # that waits for the process to drop all resources that could be
   # needed by services started subsequently.  A last resort is to
   # sleep for some time.
   start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --chuid $USER --exec $DAEMON
   [ "$?" = 2 ] && return 2
   # Many daemons don't delete their pidfiles when they exit.
   rm -f $PIDFILE
   return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
   #
   # If the daemon can reload its configuration without
   # restarting (for example, when it is sent a SIGHUP),
   # then implement that here.
   #
   start-stop-daemon --stop --signal 1 --quiet --chuid $USER --nicelevel $NICE --name $NAME
   return 0
}

case "$1" in
  start)
   [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
   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" "$NAME"
   do_stop
   case "$?" in
      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   esac
   ;;
  #reload|force-reload)
   #
   # If do_reload() is not implemented then leave this commented out
   # and leave 'force-reload' as an alias for 'restart'.
   #
   #log_daemon_msg "Reloading $DESC" "$NAME"
   #do_reload
   #log_end_msg $?
   #;;
  restart|force-reload)
   #
   # If the "reload" option is implemented then remove the
   # 'force-reload' alias
   #
   log_daemon_msg "Restarting $DESC" "$NAME"
   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|reload|force-reload}" >&2
   echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
   exit 3
   ;;
esac

:
mcuerdo
New User
New User
 
Posts: 1
Joined: Sun Nov 09, 2008 8:51 am

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

Postby BuzzD on Wed Nov 12, 2008 5:31 pm

arbrandes wrote:Here's my take on it, using the somewhat standard /etc/init.d/*-daemon, /etc/default/*-daemon combo. I managed to get it so /var/run/*.pid files are generated, so no need for grepping and awking to stop the daemon.

You have to specify the user in /etc/default/deluge-daemon. You can also choose whether or not the daemon will run on startup.

/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 <arbrandes@gmail.com>

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"
DAEMON2=/usr/bin/deluge
DAEMON2_ARGS="-u web"
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

:


Hi. I've managed to start the daemon with your script. But it won't start when the system is booting. What did I miss?
BuzzD
New User
New User
 
Posts: 6
Joined: Wed Nov 12, 2008 10:56 am

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

Postby johnnyg on Thu Nov 13, 2008 2:39 am

BuzzD wrote:Hi. I've managed to start the daemon with your script. But it won't start when the system is booting. What did I miss?

  1. Put the config and the script in /etc/default and /etc/init.d/ respectively
  2. Make the script executable
    Code: Select all
    sudo chmod 755 /etc/init.d/deluge-daemon
  3. Update the rc.d symlinks
    Code: Select all
    sudo update-rc.d deluge-daemon defaults

Once you've done those steps, it should automatically run on startup.
johnnyg
Top Bloke
Top Bloke
 
Posts: 1277
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

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

Postby BuzzD on Thu Nov 13, 2008 5:34 am

Had done this already.

So I will have to take a look at what the bootlog is saying...

Edit: Hm. after rebooting a few more time its seems to work now. lets hope it stays that way.

Thank you all for helping me!
BuzzD
New User
New User
 
Posts: 6
Joined: Wed Nov 12, 2008 10:56 am

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

Postby tstack77 on Fri Dec 19, 2008 12:01 am

I've tried running the script but have run into a few problems. Do I need my server to be running x for deluge to start/run?
tstack77
New User
New User
 
Posts: 9
Joined: Thu Dec 18, 2008 11:58 pm

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

Postby johnnyg on Fri Dec 19, 2008 6:54 am

tstack77 wrote:I've tried running the script but have run into a few problems. Do I need my server to be running x for deluge to start/run?

for deluge - yes,
for deluged - no.
johnnyg
Top Bloke
Top Bloke
 
Posts: 1277
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

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

Postby tstack77 on Fri Dec 19, 2008 4:52 pm

Thanks, that's what I thought too. The only reason I was asking is because after the webui didn't start with the scripts, I tried it manually from the command line. When I start 'deluged' and 'deluge -u web', I still cannot access the webui. I am asked for the password but then it displays that it is 'Not connected to a Daemon'. When I try to connect I get the Connection refused error.

Any ideas where I went wrong?
tstack77
New User
New User
 
Posts: 9
Joined: Thu Dec 18, 2008 11:58 pm

PreviousNext

Return to Support

Who is online

Users browsing this forum: Alexa [Bot], Google [Bot] and 1 guest