BDMV.INFO

Title: [2015.05.01] How to Install the BT Client - Deluge Into Linux (update) [Print this page]

author: 夢    time: 2012-10-27 14:25     Title: [2015.05.01] How to Install the BT Client - Deluge Into Linux (update)

Test OS:ubunt server 12.04 LTS 64bits


The most important documents are  in the officical homepage.

1. We download the source code,then compile and install deluge (search 'Download release ​tarballs' )

  1. wget http://download.deluge-torrent.org/source/deluge-1.3.11.tar.gz
  2. tar xzvf deluge-1.3.11.tar.gz
Copy the Code
  1. sudo apt-get update
  2. sudo apt-get install python python-twisted python-twisted-web python-openssl python-simplejson python-setuptools intltool python-xdg python-chardet geoip-database python-libtorrent python-notify python-pygame python-glade2 librsvg2-common xdg-utils python-mako
Copy the Code
  1. cd deluge-1.3.11.tar.gz
  2. python setup.py clean -a
  3. python setup.py build
  4. sudo python setup.py install
  5. sudo python setup.py install_data
Copy the Code

2.Add the initial script
http://dev.deluge-torrent.org/wiki/UserGuide/InitScript/Ubuntu

First,
  1. sudo vi /etc/default/deluge-daemon
Copy the Code
  1. # Configuration for /etc/init.d/deluge-daemon


  2. # The init.d script will only run if this variable non-empty.

  3. DELUGED_USER="add the user name" # !!!CHANGE THIS!!!!


  4. # Should we run at startup?

  5. RUN_AT_STARTUP="YES"
Copy the Code
Attention!! Guys need to add the user name of the DELUGED_USER parameter .

Then,
  1. sudo vi /etc/init.d/deluge-daemon
Copy the Code
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          deluge-daemon
  4. # Required-Start:    $local_fs $remote_fs
  5. # Required-Stop:     $local_fs $remote_fs
  6. # Should-Start:      $network
  7. # Should-Stop:       $network
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:      0 1 6
  10. # Short-Description: Daemonized version of deluge and webui.
  11. # Description:       Starts the deluge daemon with the user specified in
  12. #                    /etc/default/deluge-daemon.
  13. ### END INIT INFO

  14. # Author: Adolfo R. Brandes

  15. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  16. DESC="Deluge Daemon"
  17. NAME1="deluged"
  18. NAME2="deluge"
  19. DAEMON1=/usr/bin/deluged             #may need to be changed
  20. DAEMON1_ARGS="-d"                       # Consult `man deluged` for more options
  21. DAEMON2=/usr/bin/deluge-web       #may need to be changed
  22. DAEMON2_ARGS=""                          # Consult `man deluge-web` for more options
  23. PIDFILE1=/var/run/$NAME1.pid
  24. PIDFILE2=/var/run/$NAME2.pid
  25. UMASK=022                     # Change this to 0 if running deluged as its own user
  26. PKGNAME=deluge-daemon
  27. SCRIPTNAME=/etc/init.d/$PKGNAME

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

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

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

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

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

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

  47. #
  48. # Function that starts the daemon/service
  49. #
  50. do_start()
  51. {
  52.    # Return
  53.    #   0 if daemon has been started
  54.    #   1 if daemon was already running
  55.    #   2 if daemon could not be started
  56.    start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --exec $DAEMON1 \
  57.       --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK --test > /dev/null
  58.    RETVAL1="$?"
  59.    start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --exec $DAEMON2 \
  60.       --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK --test > /dev/null
  61.    RETVAL2="$?"
  62.    [ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 1

  63.    start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --make-pidfile --exec $DAEMON1 \
  64.       --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON1_ARGS
  65.    RETVAL1="$?"
  66.         sleep 2
  67.    start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile --exec $DAEMON2 \
  68.       --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON2_ARGS
  69.    RETVAL2="$?"
  70.    [ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 2
  71. }

  72. #
  73. # Function that stops the daemon/service
  74. #
  75. do_stop()
  76. {
  77.    # Return
  78.    #   0 if daemon has been stopped
  79.    #   1 if daemon was already stopped
  80.    #   2 if daemon could not be stopped
  81.    #   other if a failure occurred

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

  87.    rm -f $PIDFILE1 $PIDFILE2

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

  90. case "$1" in
  91.   start)
  92.    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME1"
  93.    do_start
  94.    case "$?" in
  95.       0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  96.       2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  97.    esac
  98.    ;;
  99.   stop)
  100.    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME1"
  101.    do_stop
  102.    case "$?" in
  103.       0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  104.       2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  105.    esac
  106.    ;;
  107.   restart|force-reload)
  108.    log_daemon_msg "Restarting $DESC" "$NAME1"
  109.    do_stop
  110.    case "$?" in
  111.      0|1)
  112.       do_start
  113.       case "$?" in
  114.          0) log_end_msg 0 ;;
  115.          1) log_end_msg 1 ;; # Old process is still running
  116.          *) log_end_msg 1 ;; # Failed to start
  117.       esac
  118.       ;;
  119.      *)
  120.         # Failed to stop
  121.       log_end_msg 1
  122.       ;;
  123.    esac
  124.    ;;
  125.   *)
  126.    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  127.    exit 3
  128.    ;;
  129. esac

  130. :
Copy the Code
Attention!! The path pf the official script parameter DAEMON1 and DAEMON2 may need to be fix the location /usr/bin/ to /usr/local/bin/
You can search the comment "may need to be changed"



Then, change the premission of the initial script and restart the script.
  1. sudo chmod 755 /etc/init.d/deluge-daemon
  2. sudo update-rc.d deluge-daemon defaults
  3. sudo invoke-rc.d deluge-daemon start
Copy the Code

[hide=7777]
3.Add the log file(People can select to ignore this step).
  1. sudo mkdir -p /var/log/deluge/daemon
  2. sudo mkdir /var/log/deluge/web
  3. sudo chmod -R 755 /var/log/deluge
  4. sudo chown -R deluge /var/log/deluge
Copy the Code

Change the parameter DAEMON1_ARGS and DAEMON2_ARGS of the above initial script.
  1. DAEMON1_ARGS="-d -L warning -l /var/log/deluge/daemon/warning.log"             # Consult `man deluged` for more options
  2. DAEMON2_ARGS="-L warning -l /var/log/deluge/web/warning.log"
Copy the Code

restart the daemon and tell logrotate to rotate the logs
  1. sudo invoke-rc.d deluge-daemon restart
  2. sudo cat > /etc/logrotate.d/deluge << EOF
  3. /var/log/deluge/*/*.log {
  4.         weekly
  5.         missingok
  6.         rotate 7
  7.         compress
  8.         notifempty
  9.         copytruncate
  10.         create 600
  11. }
  12. EOF
Copy the Code
[/hide]

4.People can run the deluge by webui and the default password is deluge.
http://dev.deluge-torrent.org/wiki/Faq#Howtostartthevarioususer-interfaces

  1. http://localhost:8112/
Copy the Code
Pay attention!! Remember to change the password when you first login the deluge-webui.








Welcome to BDMV.INFO (http://bdmv.info/snow/) Powered by Discuz! X2