Total Pageviews

Saturday, 2 July 2016

编译安装deluge





Deluge 是一个通过PyGTK建立图形界面的BitTorrent客户端,后端使用libtorrent。Deluge可以在多个平台上使用,如Linux,*BSD,Mac OS和其他类UNIX操作系统。该项目的目标是要在GTK框架上建立一个原生和全功能的BitTorrent客户端。

Deluge由ubuntuforum的两位成员建立,Zach Tibbitts 和 Alan Zakai。在过去,它曾是Google Code的项目。

在过去的开发,Deluge曾经被命名为gTorrent,意思是 GNOME 下的BitTorrent客户端。当第一个版本在2006年9月25日释出的时候,被重新命名为Deluge,以避免别人误会gTorrent只能用于GNOME。

利用0.4.x代码重写的0.5穏定版在2007年3月18日释出。重写代码的目的是要令代码更加优良。而0.5.1.1版支持数据加密,peer exchange,Si prefixes和upnp。


安装过程


1.安装更新源.

rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

wget -c -O /etc/yum.repos.d/linuxtech.repo http://pkgrepo.linuxtech.net/el6/release/linuxtech.repo


2.安装依赖库

yum install GeoIP PyXML SOAPpy boost-filesystem boost-python boost-system boost-thread pyOpenSSL python-chardet python-fpconst python-setuptools python-simplejson python-twisted-core python-twisted-web python-zope-filesystem python-zope-interface pyxdg rb_libtorrent rb_libtorrent-python python-beaker python-mako python-markupsafe python-twisted python-twisted-web


3.编译安装deluge:

wget http://download.deluge-torrent.org/source/deluge-1.3.6.tar.gz

tar zxvf deluge-1.3.6.tar.gz

cd deluge-1.3.6

#开始编译

python setup.py build

python setup.py install

#建立账户

/usr/sbin/groupadd deluge

useradd deluge -g deluge -s /bin/false


4.配置启动文件,把以下文件保存为/etc/init.d/deluge-daemon


#!/bin/bash

#

# Startup script for deluged

#

# chkconfig: - 86 14

# description: deluged is the Deluge bit torrent daemon. It manages torrents

# processname: deluged

# pidfile: /var/run/deluged.pid

# config:

 

# Source function library.

. /etc/init.d/functions

 

# Get network config

. /etc/sysconfig/network

 

[ "${NETWORKING}" = "no" ] && exit 0

 

prog=deluged

prog2=deluge

lockfile=/var/lock/subsys/deluged

lockfile2=/var/lock/subsys/deluge

 

LANG="zh_CN.UTF-8" 

LANGUAGE="zh_CN.UTF-8:zh_CN.UTF-8:zh_CN" 

SUPPORTED="zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en" 

SYSFONT="lat0-sun16"

ulimit -HSn 65535

 

start() {

  echo -n $"Starting deluged service: "

  daemon --user deluge "$prog $OPTIONS"

  RETVAL=$?

  echo

  [ $RETVAL -eq 0 ] && touch $lockfile

 

  echo -n $"Starting deluge web ui: "

  daemon --user deluge "$prog2 --ui web >/dev/null 2>&1 &"

  RETVAL=$(($RETVAL|$?))

  echo

  [ $RETVAL -eq 0 ] && touch $lockfile2

 

  return $RETVAL

}

 

stop() {

  echo -n $"Shutting down deluged service: "

  killproc $prog

  RETVAL=$?

  echo

  [ $RETVAL -eq 0 ] && rm -f $lockfile

 

  echo -n $"Shutting down deluge web ui: "

  killproc $prog2

  RETVAL2=$?

  echo

  [ $RETVAL2 -eq 0 ] && rm -f $lockfile2

 

  return $(($RETVAL|$RETVAL2))

}

 

# See how we were called.

case "$1" in

  start)

        start

        ;;

  stop)

        stop

        ;;

  status)

        status $prog

        status $prog2

        ;;

  restart)

        stop

        start

        ;;

  reload)

        exit 3

        ;;

  *)

        echo $"Usage: $prog {start|stop|status|restart|reload}"

        exit 1

esac


5.给启动脚本权限&启动deluge:

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

service deluge-daemon start

----------------------------------------------------------

Centos 6.X 下安装Deluge的方法


1.执行以下代码来增加linuxtech的源:
1
wget -c -O /etc/yum.repos.d/linuxtech.repo http://pkgrepo.linuxtech.net/el6/release/linuxtech.repo
2.安装deluge
1
yum install deluge

--------------------------------------


Deluge BitTorrent Client - Official github mirror (PR's only) 


Deluge BitTorrent Client

Authors:
Andrew Resch Damien Churchill
For contributors and past developers see:
AUTHORS

Installation Instructions:

Ensure build dependencies are installed, see DEPENDS for a full listing.
Build and install by running:
$ python setup.py build
$ sudo python setup.py install

Contact/Support:

Forum:http://forum.deluge-torrent.org
IRC Channel:#deluge on irc.freenode.net

FAQ


How to start the various user-interfaces:
Gtk:
deluge or deluge-gtk
Console:
deluge-console
Web:
deluge-web
Go to http://localhost:8112/ default-password = "deluge"
How do I start the daemon?:
deluged
I can't connect to the daemon from another machine:
See: http://dev.deluge-torrent.org/wiki/UserGuide/ThinClient
from github.com/deluge-torrent/deluge
============
deluge_webui.sh脚本的内容:
#!/bin/bash
#####################################################
## Deluge BitTorrent Daemon & Web-UI Installer     ##
## v.1.3.13  -  09/06/2016                         ##
## nunim at sonicboxes.com                         ##
#####################################################
## setup variables ##
latest="http://download.deluge-torrent.org/source/deluge-1.3.13.tar.gz"
geoip="http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
packages="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"
ip=$(hostname -I | awk -F ' ' '{print $2}')
# Check if we're root
if [ $(whoami) != "root" ]; then
        echo "You need to run this script as root."
        echo "Use 'sudo ./deluge_web.sh' then enter your password when prompted."
        exit 1
fi
clear
## get packages required to build deluge ##
echo "Installing Dependencies..... This will take a few moments.."
echo ""
        apt-get -qq update
        apt-get -qqy upgrade
        apt-get -qqy install $packages

## setup install dir ##
        mkdir deluge_install
        cd deluge_install
## get deluge
        wget $latest
        tar -xf deluge-*
        cd deluge-*

## install deluge ##
        echo " Installing Deluge...."
        python setup.py clean -a
        python setup.py build
        python setup.py install  --install-layout=deb

## cleanup install directory ##
        cd ../..
        rm -rf deluge_install
        clear
## install geoip database to resolve ips ##
        echo " Installing GeoIP Database...."
        wget $geoip
        gzip -d GeoIP.dat.gz
        mkdir -p /usr/share/geoip
        mv GeoIP.dat /usr/share/geoip/

## setup deluge user
        echo "Now we will setup a user for Deluge"
        read -p "What would you like the username to be?   " USERNAME
             adduser --gecos "" $USERNAME

####################### BEGIN INIT SETUP ###############################
## setup defaults ##

cat > /etc/default/deluge-daemon << EOF
# Configuration for /etc/init.d/deluge-daemon

# The init.d script will only run if this variable non-empty.
DELUGED_USER="$USERNAME"             # !!!CHANGE THIS!!!!

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

## setup init script ##
## original script from http://apocryph.org/archives/601 ##
cat > /etc/init.d/deluge-daemon << "EOF"
#!/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
# Updated by: Jean-Philippe "Orax" Roemer

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 to verify if a pid is alive
#
is_alive()
{
   pid=`cat $1` > /dev/null 2>&1
   kill -0 $pid > /dev/null 2>&1
   return $?
}

#
# 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

   is_alive $PIDFILE1
   RETVAL1="$?"

   if [ $RETVAL1 != 0 ]; then
       rm -f $PIDFILE1
       start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --make-pidfile \
       --exec $DAEMON1 --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON1_ARGS
       RETVAL1="$?"
   else
       is_alive $PIDFILE2
       RETVAL2="$?"
       [ "$RETVAL2" = "0" -a "$RETVAL1" = "0" ] && return 1
   fi

   is_alive $PIDFILE2
   RETVAL2="$?"

   if [ $RETVAL2 != 0 ]; then
        sleep 2
        rm -f $PIDFILE2
        start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile \
        --exec $DAEMON2 --chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $DAEMON2_ARGS
        RETVAL2="$?"
   fi
   [ "$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

:
EOF
########################## END INIT SETUP ##################################

## setup daemon ##
chmod 755 /etc/init.d/deluge-daemon
update-rc.d deluge-daemon defaults
## start deluge ##
invoke-rc.d deluge-daemon start

## Finish ##
clear
echo "#####################################################"
echo "##########        Install Complete         ##########"
echo "#####################################################"
echo "If all went as planned you should be able to access"
echo "the deluge web-ui at http://$ip:8112/ "
echo "         Default password = deluge"
echo "#####################################################"
echo "##########   Installer by SonicBoxes.com   ##########"
echo "#####################################################"
echo "For FAQ and configuration options please see:"
echo "http://sonicboxes.com/bittorrent-deluge-webui-install-script/"
---------

BitTorrent – Deluge WebUI Install Script

Deluge is a BitTorrent client written in python based on libtorrent. Deluge is my favorite  BitTorrent client because it’s got some great features like:
09/08/16 – Updated for Deluge 1.3.13 – Tested on  Debian 8/Ubuntu 16.04
  • It’s Fast!
  • Full Encryption Support
  • Cross-Platform Support
  • Thin Client Mode
  • Great Web-UI
  • Plugin System
Not only have I found Deluge to be faster than many of the other BitTorrent clients that I have tried but, it’s also simple to setup and reasonably lightweight in terms of resources. Packaged versions of Deluge can be a bit old and not up to snuff, so I’ve written a  simple bash script that will automatically install the latest version of Deluge from it’s source.  The entire process, on a freshly installed VPS, takes approximately 5 minutes.
Script Usage: This script is designed to be run on a freshly installed VPS, it has been tested on Debian 6/7/8 and Ubuntu 12.04/13.10/14.x/15.x  – All other distributions are unsupported at this time.
wget www.sonicboxes.com/scripts/deluge_webui.sh
chmod 755 deluge_webui.sh
./deluge_webui.sh

You will be asked to create a user for Deluge to run as.

When the script is finished, you may access Deluge at http://<Your IP>:8112
Deluge WebUI
Deluge Configuration:
Now that we’ve got Deluge installed, we should perform some the basic configuration tasks.  Select Preferences on the top bar to bring up the menu, the first thing I always do is enable Encryption.
EncryptionDeluge Encryption Settings
The basic Encryption settings are:
  • Forced – Only encrypted connections are allowed. Incoming connections that are not encrypted are closed if the encrypted outgoing connection fails, a non-encrypted retry will not be made.
  • Enabled – Encrypted connections are enabled, but non-encrypted connections are allowed. An incoming non-encrypted connection will be accepted, if an outgoing encrypted connection fails, a non- encrypted connection will be tried.
  • Disabled – Only non-encrypted connections are allowed.
I typically go with Forced  encryption  on both Incoming & Outgoing connections, the downside to this is that it places more load on the processor and there are technically less available Peers.  For the best possible incoming connection, you should select Enabled, not Forced.
See this link for more information on the possible Encryption settings:
BandwidthDeluge - Bandwidth Settings
The next step is to adjust the various connection settings to meet your needs.  By default Deluge will limit you to 200 connections, unless you’re only downloading one well seeded torrent at a time this is far from adequate, I typically set Maximum Connections to between 500 and 1000, depending on the server specs. If you plan to do some seeding, you’ll want to raise the Maximum Upload Slots from the default 4 to a more respectable number, say 25 or 50.  It would also be advisable to limit your Maximum Upload Speed so you do not burn through a month’s bandwidth in a few days, I typically set this to between 2048KB/s and 4096KB/s, this is 16 and 32 Mb/s, a respectable number for uploading while ensuring you’re not hogging the port. I do not place any per torrent based limitations, however if you’re seeding many torrents, i.e. more than 100, at any one time you may way to limit the Maximum Upload Slots or Speed per torrent to ensure your bandwidth is being spread out evenly.
Queue
Deluge - Queue SettingsThis section is rather self explanatory, set Total Active torrent to the maximum number of torrents you’d like to Seed or Leech at once, I typically set this between 25 and 50, but I am not a heavy seeder.  If you do a lot of seeding you should probably set your Total Active between 100-200 along with your Total Active Seeding. Keep your resources in mind when you make these settings, a 128MB VPS will not be happy with over 100 active torrents.  If you plan on using Deluge’s auto-managed seeding, you should enable Stop Seeding When Ratio Reaches: <desired ratio>.
NetworkDeluge - Network Settings
This section can be quite important, I typically go with Random ports as there are no firewall limitations in place, however if you plan to run a firewall on your VPS, such as CSF, you’ll want to use a fixed port for incoming and outgoing. If you only seed on a private tracker, make sure you disable Peer Exchange, LSD and DHT, these will get you banned on a private tracker as you may be sharing with others outside the site, and alter your tracker ratio. Almost all private trackers will direct you to disable any kind of peer sharing. If you don’t use private trackers you should leave these enabled to ensure the maximum number of possible seeds.
ThinClient/Daemon ConfigurationDeluge - Daemon/ThinClient Settings
This is one of the neatest features about Deluge, you can use a local GUI client instead of the WebUI to  download torrents remotely onto your VPS.  There are two ways to go about this, one way is to use a VPN or SSH tunnel to connect to your VPS and then connect to the Deluge daemon locally.  The easier method is to check Allow Remote Connections as shown above. Now you’ll need to install Deluge on your PC.  Once installed, go to Edit >>  Preferences >> Interface  –  You need to uncheck Classic Mode Enable.  Deluge will restart after you have applied this change. Now you need to add an authenticated user, you’ll do this by going to your Deluge user’s home directory.  If the user you created was deluge-torrent, it would be: cd /home/deluge-torrent/ Add your new user to the auth file like so:
echo "username:strongpassword:10" >> ./.config/deluge/auth
## Restart Deluge ##
/etc/init.d/deluge-daemon restart
Now go back to your desktop Deluge and setup the connection to your server,Deluge - Desktop Connection Manager
If you’ve done everything correctly, you should see a green dot next to your hostname and you’ll be able to hit Connect.Deluge - Thin Client
That’s it, you should now be staring at your Deluge ThinClient.  You can add torrents, start, stop, remove, everything you would normally do except that it will be on your remote server. Using this method you can also use one Web-UI to manage multiple Deluge daemons, simply add them using the Connection Manager.
FAQ / User Guide: For further information about Deluge, including the official FAQ and User Guide, see the official Deluge website located here: http://dev.deluge-torrent.org/wiki/UserGuide
from https://www.sonicboxes.com/bittorrent-deluge-webui-install-script/