Installing Deluge BitTorrent on Ubuntu Server. Deluge - learning and trying Deluge remote control

Actually, why is the file server idle with us? Yes, and where should the file be taken from? In kubuntu, I used kTorrent at one time. But in this case, we are interested in clients that can work without a GUI and who have a web interface. Options:

  1. rTorrent + wTorrent bundle. There are quite a few descriptions of the setup on the network, but the process scares me =)
  2. TorrentFlux and along the way its fork Torrentflux-b4rt. Designed as a web interface and nothing else. You might want to think about the setting.
  3. Deluge. It was originally planned as a torrent client for gtk. But starting from some version, it can work as a demon, to which you can already connect the desired interface - either a graphic face, or a web face, or control it through the console.

While I'm thinking of trying to get confused with the third option. I'll google further. It would just be quite convenient as usual - you sit in the browser, click on the download of the torrent file and open it with the help of the Windows muzzle. And that one is already transferring the download to the daemon on the server. Install deluge (in general, it is advised to install the version from the site, but I installed it from the repositories) sudo aptitude install deluge-coresudo aptitude install deluge-webuisudo aptitude install deluge-console If we install the packages downloaded from the site, then most likely there will be a problem of unmet dependencies. We get out of the situation as follows: sudo apt-get -f install We launch deluged Launching the web muzzle deluge --ui web By the way, we execute this command on behalf of our user, not as root. For in this case, the web interface will not work. Why, I haven’t figured it out yet. But after running this, one console will disappear, because this command is executed there. In order for the command to be executed and remain hanging in the background, we write deluge --ui web& If you want the web interface to be always available, push this command somewhere into autorun, but so that it is executed with the rights of a regular user. By the way, I recommend pushing the launch into autorun deluge demon d.Web interface works on port 8112. We go through the browser to the desired server on this port. The default password is deluge. Customizable. Several design options are offered. Ajax option is the most beautiful. But it doesn't have all the possibilities. For example, you cannot specify for a particular torrent where to download the file. You can only specify shared folder for all torrents. In other skins, this feature is present. There are GUI shells for both Linux and Windows. But before using the GUI face, you need to allow the daemon to do this. We do this in any of two ways:

  1. Through the web interface. in the settings - Deluge - Service - Allow remote connection (tick)
  2. Through the console interface. We write deluge --ui console. Then config allow_remote True.

The web interface is often inconvenient to use. But this is purely IMHO. Since I have Windows on the desktop ( Windows Web Server 2008), put the client under Windows. We go to the official website of the project, download the version for Windows. It is recommended to download the same version as that of the daemon installed on the server. Download, install. The installer will also offer to install the GTK+ Runtime. We agree. After the client has been installed, we climb into its settings:

  1. Launching the client
  2. Go to "Preferences -> Interface" and uncheck "Classic Mode".
  3. Restart client. The Connection manager window should appear.
  4. Remove line from localhost. By clicking the "Add" button, enter the IP of the server (in our case, boxes). Leave the port the same.

Here I hung up for a while. In addition to the IP address, I had to enter a username and password. Suppose I could set the password through the web interface. And which user should I write? I wrote my own and the password set via the web interface. Nifiga. I wrote my own and his password in the system. Nifiga .. Rummaged. So, we do this:

  1. We go on the server to the home directory of our user (from which we run deluge)
  2. Next, go to the /.config/deluge directory
  3. Opening the auth file
  4. In the second line we write the username and password in the format user:password (moreover, I note that we write this information from the bulldozer)
  5. Restart deluge - deluged restart
  6. On a computer with Windows, go to the Connection Manager, in the connection settings we hammer in this user and his password.
  7. Click "Connect"
  8. Voila, the client is connected.

Thus, we got the usual way of processing torrent files - we open them with a torrent client (GUI-muzzle) and choose what to do. But it can be done differently. I also tried this method:

  1. Create a folder on the server, say /home/user/torrents
  2. We share it in samba.
  3. In the deluge settings, through the same web face, we set it to automatically take torrents from this daddy.
  4. And then, we just save the torrent files in this folder.

All subsequent steps are described using Fedora as an example, but can be adapted to any other distribution.

Installation

Installation is the easiest thing ever.

$ sudo dnf install deluge-daemon deluge-console

We put the console client, as well as the cli for it.

While all. The client is ready to go. You can already turn it on and use it.

$ sudo systemctl enable deluge-daemon $ sudo systemctl start deluge-daemon

But there are many problems with this configuration:

  • no logs
  • incorrect server port allocation

Do you need it? 🙂

Logs

Once installed, the daemon is ready to run. But the configuration that the distribution vendors offer is not entirely successful. There is no logging of what is happening in it.

To do this, we need to install logrotate.

$ sudo dnf install logrotate

Configure it to support the new rotation rules. To do this, let's create a file /etc/logrotate.d/deluge about the following content

/var/log/deluge/*.log ( rotate 4 weekly missingok notifempty compress delaycompress sharedscripts postrotate initctl restart deluged >/dev/null 2>&1 || true initctl restart deluge-web >/dev/null 2>&1 || true endscript)

As well as a folder for storing logs. And give her the right permissions.

$ sudo mkdir /var/log/deluge/ $ sudo chown deluge:deluge /var/log/deluge

Now it remains to enable logging support for the daemon.

Create a new daemon description for systemd in /etc/systemd/system/deluged.service

Description=Deluge Bittorrent Client Daemon After=network.target Type=simple User=deluge Group=deluge UMask=007 ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L warning Restart= always TimeoutStopSec=300 WantedBy=multi-user.target

Excellent. It remains to configure iptables and deluge itself.

Setting up iptables

In some cases, it is enough just to open the necessary ports

$ sudo iptables -A INPUT -p tcp --dport 56881:56889 -j ACCEPT $ sudo iptables -A INPUT -p udp --dport 56881:56889 -j ACCEPT

But in some configurations, there may be problems with the conntrack mechanism, which marks a number of packets as invalid (this is especially true for dht traffic).

Therefore, it is worth disabling conntrack for all deluge connections.

$ sudo iptables -t raw -I PREROUTING -p udp --dport 56881:57200 -j NOTRACK $ sudo iptables -t raw -I OUTPUT -p udp --sport 56881:57200 -j NOTRACK $ sudo iptables -t raw -I PREROUTING -p tcp --dport 56881:57200 -j NOTRACK $ sudo iptables -t raw -I OUTPUT -p tcp --sport 56881:57200 -j NOTRACK $ sudo iptables -I INPUT -p icmp --icmp-type 3 - j ACCEPT $ sudo iptables -I INPUT -p icmp --icmp-type 4 -j ACCEPT $ sudo iptables -I INPUT -p icmp --icmp-type 11 -j ACCEPT $ sudo iptables -I INPUT -p icmp --icmp -type 12 -j ACCEPT

$ sudo /usr/libexec/iptables/iptables.init save

Local Authorization

In order for us to successfully use deluge-console, local authorization must be enabled for our user.

Those. there should be a ~/.config/deluge/auth file containing a login-password string

Localclient:here_long_hash:10

You can copy this file from the /var/lib/deluge/.config/deluge directory

$ sudo cat /var/lib/deluge/.config/deluge/auth >> ~/.config/deluge/auth

Starting and configuring the daemon

$ sudo systemctl enable deluged $ sudo systemctl start deluged

Thus, we launched the daemon, the config of which was described earlier.

I upgraded to 12.04 and Flood broke. I want to remove it and then add it again. How to uninstall Deluge?

  1. Tried: Search in Ubuntu Software Center
    Error: Button reads "Install" (but it's already installed!)
  2. Tried: sudo apt-get remove --purge deluge
    Failed: Output read Removing deluge... but I can still find it when I search for my dash

If sudo apt-get remove --purge deluge succeeded, then the deluge package was successfully removed.

If menu items still appear in dashes, it doesn't necessarily mean the program is still installed, just links to it remain somewhere. It's possible that the dash keeps its own cache of what's in your menu and it takes some time to realize a change has been made.

Feel free to go ahead and reinstall flood to see if it works.

For future reference, you should look for dotfiles in ~/ or ~/config which are specific to Deluge. This is the most likely place to store data for your account. Try clearing or renaming it. This may fix your original problem (rather than re-installing it).

Have you tried complete removal using the synaptic package manager?

Install synaptic synaptic sudo apt-get install synaptic

I had the same problem removing the flood. I figured out that I had the GTK version installed, so just uninstalling deluge didn't work. I used sudo apt-get remove --purge deluge-gtk

According to the OP using sudo apt-get remove --purge deluge is the correct way

If you installed from source files or you need to find the remaining Deluge files, the Deluge Widgets manual has details: RemovingFromSystem

The most likely reason it's still showing up in Dash is due to a leftover deluge.desktop file.

You can use locate deluge which will quickly list each file/folder named the flood, and you will be able to determine if the app has actually been removed.

If you installed Deluge from source code, you will have to manually delete the files. The main folder of the flood application is usually installed in the folder site python or in a folder dist packages, which should be visible in the output of the above command. You also need to remove the Flood binaries from /usr/local/bin/ or /usr/bin/ .

As neon_overload mentions, if you are having problems with Deluge, backup and deleting the old config can help fix upgrade issues. Default Location: ~/.config/deluge

sudo apt-get remove --purge deluge

Obviously, you understand that when you search for "The Flood", you will still get it on the screen.

These are the leftover files of the Flood - to completely remove them from your system,

sudo apt autoremove deluge

Seeking and no flood will appear….. Magic

Tell me how to make apf-firewall closed for most ports, but work samba in LAN, and a torrent client like Deluge.
Distribution: Debian Jessie
Kernel: 3.14-2-amd64
The mode in which the firewall turns off after 5 minutes is disabled. I set it up as it is written here: https://www.debian.org/releases/slink/i386/ch-init-config.ru.html Vuurmuur is not to be suggested - it is a crooked utility, and even a bearded one.

Well, as an option, you can argue why a firewall is not needed on a home PC.

Deluge disables internet (WiFi)

Hi all. I'm trying to download via Deluge - a torrent tracker in xubuntu 14.04.1, and my Internet connection turns off after 15 seconds, or rather, it's just stupidly unavailable, deluge also stops downloading. You have to restart WiFi and then again wait 10-15 seconds. Something shorter is not good. Maybe someone knows how to solve the problem after all.

deluge and root tracker

service autostart in opensuse 13.1

I don't understand anything. I installed Deluge, downloaded the script, uploaded it to init.d, created a symlink in rc5.d in YAST - service management (service manager) the service appeared, I set it to Enabled, I save it, I go again, and it is again Disabled. What the? It starts normally without glitches, but does not want to start with the system.

UPnP works in Transmission, but not in Deluge and qBittorrent.

On the router (fedoro19-router) for UPnP is linux-igd, default.

On the client I run Transmission, on the router in iptables -L forwarded ports are visible, the linux-igd logs are eloquent. Good.

I run qBittorrent or Deluge on the client (I enabled upnp, of course) - ports are not forwarded, there are no incoming connections, iptables on the router is silent, linux-igd logs are silent. Bad.

Before that, I noticed that with box routers (such as asus, tp-link) - transmission, on the contrary, does not work with UPnP, but qBittorrent works.

What to twist? Or say at least: "UMVR, linux-igd and qBittorrent (or Deluge)."

Deleted (28.02.14 13:25:31)

Torrent client for high load

I want to ask hardcore players with 1000+ active hands what kind of client is now optimal for such a scenario. I consider only server and daemonic clients with adequate system requirements.

Particularly interested in memory and processor consumption, resistance to non-trivial torrents ( long names files), resistance to errors and their consequences when downloading, grouping distributions instead of a whole list.

While under the supervision of Transmission, Deluge, qBittorent. But everyone has bugs. qBittorent does not have a normal face for client-server interaction (maybe it has already been finished, I haven’t found it), it doesn’t understand long names (more than the FS allows). definitely were). Transmission sculpts all distributions into a linear list without any grouping, which will “inspire” on the specified scale, does not understand long names.

Deluge is stupid with speakers

Columns uploaded, given away and some others are not displayed, do not mark them. Those that are by default (for example #, name, size, state) are quietly turned on and off. What to do? Can this be fixed in the configs? But I don't know what file to look for.
If suddenly this is an eternal deluge bug that is not fixed, then tell me the alternatives. I am partially familiar with them. Of those that I know and visually liked - kTorrent for example. But I have a third gnome, and they say it's bad to hold heavy sneakers.

Deluge how to make it automatically run as a torrent user in arch-linux

Autostart Deluged daemon as user "deluge"

There is a server with debian 7.2. systemd init system.

Required: runable, at system startup, deluged as user "deluge", access to daemon via windows GUI on standard port 58846.

Access to the folder with torrents is allowed to the deluge user, mounted using the sambaclient in / mnt.

Installed deluged, deluge-console. Allowed remote access. I created a deluged.service, put the script from the official wiki into it:

Description=Deluge Bittorrent Client Daemon After=network.target User=deluge Type=simple ExecStart=/usr/bin/deluged -d WantedBy=multi-user.target

adduser --disabled-password --system --home /home/deluge --group deluge

echo "deluge:pass:10" >> ~/.config/deluge/auth

I turn on deluged.service:

systemctl daemon-reload systemctl enable deluged.service systemctl start deluged.service

The daemon starts, works, the port occupies. But he does not want to start up through the Windows GUI. I change the user to root in the deluged.service - it lets me.

What am I doing wrong? Does the deluge user need any rights?

deluged daemon not unloading

In deluge, I specify to exit & stop the daemon, or first I stop from the menu. I'm waiting for some time. And still he is active in the top. Does not react to the usual kill, only with a strapon. Your ideas? Package: Deluge

Deluge and mysticism

Something strange has just happened. I listen to internet radio. And suddenly it starts to lag. I look at the speed chart. I see that something has eaten up almost the entire band. I start watching ports, turning off various demons. I watch the speed that deluge eats through deluge-console. The reported speed does not come close to the fattened one. Iftop says there are many connections and not with the deluge daemon port. I turn off deluge. The speed dropped sharply. For the sake of experiment, I turned the demon on and off a couple of times. The traffic was clearly correlated with turning the daemon on/off. What was it?!

How to delete .torrent in Deluge after adding?

Looking for a new torrent downloader

Responsibilities:
- work around the clock as a demon;
- have a visual interface for adding/removing torrents that would connect to the daemon;
- the ability to configure the reception of connections from clients through a Unix socket and / or a specific range of network interfaces or IP addresses of these interfaces;
- multi-user authentication, preferably with access restriction;
- not have problems with the GUI;
- clients should be able to receive and display information in a classic full tabular form;
- the client-server should not be implemented on the http(s) protocol;
- Be native to Linux.

Brief history of what I used before:
A long time ago I used vuze aka azureus - I didn't like the interface.

Then there was deluge, which I used successfully until, after the next reassembly of the world, fir problems came out. The deluge interface is close to ideal, keep that in mind.

Then I decided to try rtorrent, which I mastered, although I was tired of dragging all open downloads from sharing to it. rtorrent is cool, but only I can work with it, and there is also the rest of the family.

So after rtorrent I tried deluge again, but there were fir problems again. Then I created a thread similar to this one and moved to transmission-daemon and transmission-remote-gtk. The latter got the fact that in the menu for adding a torrent, it does not allow you to select a folder normally, forcing you to hammer each path with your hands. Latest versions crawled to gtk+3 than finally
confirmed my desire to get off it. No, I'm not against gtk3 as such, I just think that gtk is a fucking glucodrome, and I don't even have a theme for the third version.

Today I put a deluge. This time both the server and the client started working, I was pleasantly surprised by the simplification of the organization of authentication (previously it was necessary to generate passwords through the console, now the plaintext is in a file), but I was disappointed by the lack of a sane interface setting on which the deluge listens for connections. Delyuzh can go to two extremes - either he listens to the localhost, or to 0.0.0.0. However, one surprise awaited me - when I tried to add a file, I found that the file selection dialog almost never works correctly, except when the path is in the position of the last selected one. // Isn't it for this reason that the similar element of the transmission is made in the form of a poor beater?

Deleted (23.01.13 20:31:28)

Sort by addition.

Deluge does not transfer completed download files

Used Deluge 1.3.5 from the repository. Distribution - archlinux x86_64. I set in the settings a directory for downloading and a directory for completed distributions. Does not work. I also connected the AutoAdd plugin, which also has a similar setting - it does not transfer and that's it. Torrents start downloading as soon as the .torrent file appears in the correct directory.

Tried using both daemon and "classic interface" - no difference. I even tried to remove deluge, all its settings, and reinstall it - it doesn’t work, I also collected it from AUR, to no avail. I already set the rights to the directory for completed downloads to 777, it doesn’t help, that’s not the problem. Once upon a time everything worked , and then somehow, I didn't even notice when it stopped.

Has anyone encountered a similar problem? And how to overcome it? Do not offer to use transmission.

Deluge in PC-Ubuntu + Server-NAS4Free (FreeBSD) bundle

I will try to express myself correctly and intelligibly. Due to the fact that transmission Remote GUI clumsily works on Ubuntu 12.10 (personally for me) I decided to create a semblance of this with other software. The choice fell on Deluge. Found the instruction http://dev.deluge-torrent.org/wiki/UserGuide/ThinClient Made Installing Deluge On FreeBSD

In step Private IP: entered IP local server(NAS) for example, it is 192.168.68.68

ifconfig | grep -e "inet addr" | grep -v "192.168.68.68" | cut -f2 -d":" | cut -f1 -d" "

Deluge adding extension for unfinished files

file priorities in torrent, download

There is a torrent file, it has a directory structure, files are named by their hash. I already have some files on my computer. It is necessary to set priority "0" to the files in the torrent that are present. Python language, torrent library - libtorrent from rasterbar. I dug into the sources of deluge (it is written in python and uses the same library). I will receive a torrent file or a magnet link, but that's not the point.

Why switch to KTorrent?
KTorrent is devoid of the above disadvantages of Deluge, while it is not inferior in terms of functionality and responsiveness. It consumes about the same amount of memory, despite kde's libraries. As for other torrent clients, they do not reach the functionality of Deluge and KTorrent. Only qBittorrent could become an alternative, but it is banned on pornolab and still creates empty directories (with "empty" files the problem is solved).

So, studying regular expressions and console Unix utilities, wrote a script for transferring Delugov's downloads and distributions. I would like to point out three things:

  • The status of files not marked for download in multifile distributions will not be transferred (ie, by default, all will be marked).
  • When you start KTorrent, then all transferred distributions / downloads will be stopped and you will need to rehash them by highlighting each distribution and pressing SHIFT + C (more fast way not found. In some torrent clients, it is enough to click "start all", but KTorrent in this case will redownload, not rehash).
  • Performance tested on Ubuntu 12.04, Deluge 1.3.5, KTorrent 4.1.3

#!/bin/bash #Deluge2KTorrent script #written by takiz aka dadd printf "%s\n" "...wait..."; #eliminate file paths from torrents.state and fix Russian encoding egrep "^S.\/" ~/.config/deluge/state/torrents.state | sed -e "s/^..//;s/.$/\//;s/\//#/g" > paths; t=`cat paths`; printf "%b\n" $t > paths; #weed out torrent names and remove duplicates one from each pair egrep "(22,99)" ~/.config/deluge/state/torrents.state | sed -e "s/^..//;s/.$//" | perl -ne "print unless $U($_);$U($_)=1;" > torrents; #create a temporary script file to create directories and run printf "%b\n" "#!/bin/bash\nmkdir ~/.kde/share/apps/ktorrent/tor(1..100500)" > temp1.sh; chmod 774 temp1.sh; strok=`sed -n "$=" torrents`; sed -i -e "s/100500/"$strok"/" temp1.sh; ./temp1.sh; #create copy script and run printf "%s\n" "#!/bin/bash" > temp2.sh; chmod 774 temp2.sh; cat torrents | awk "(print $0".torrent ~/.kde/share/apps/ktorrent/tor"NR"/torrent")" | sed "s/^/cp ~\/\.config\/deluge\/state\//" >> temp2.sh; ./temp2.sh; sleep10; #create a stats template printf "%b\n" "AUTOSTART=0\nOUTPUTDIR=" > stats; #create stats files with paths a=2; while read f2; do sed -e "1,/.*/(n;s/\(.*\)/\1$f2/)" stats >stats$a; a=$(($a + 1)); done< paths; sed -i -e "s/#/\//g" stats*; #добавляем в скрипт копирования пути stats и запускаем cat temp2.sh | awk "{sub(/\~\/[^ ]*\.torrent/, "stats"NR)}1" | sed "s/\/torrent/\/stats/;s/cp st/mv st/" >tmpfile; mv tmpfile temp2.sh chmod 774 temp2.sh; ./temp2.sh; sleep5; #delete temporary files rm paths torrents stats temp1.sh temp2.sh; printf "%s\n" "ok";

Check the bug in Deluge

Most likely, concerns only Fedora.

1. Download.torrent
2. Specify any folder to download.
3. We are waiting for the end of the download.
4. Whatever you specify in step 2, we see our files in /home/username/

I'll file a bug report, if at least someone else has it, if not, I'm looking for a problem with myself.
P.S. the problem appeared, it seems to me, after the long-awaited update to 1.3.5.

Installation

To obtain latest version add PPA repository:

Sudo apt-get update
sudo apt-get install python-software-properties sudo add-apt-repository ppa:deluge-team/ppa

Update the package list:

Sudo apt-get update

Install client, console and daemon:

sudo apt-get install deluge-common deluge-console deluged

If we want a web interface, we also install it:

sudo apt-get install deluge-webui

Everybody! Let's start the daemon:


Setting

To enable remote access, run the console:

deluge-console

And we execute the commands:

Config -s allow_remote True
config allow_remote

Exiting the console:

Add a user for remote access(this data is not related to your linux user in any way) and specify the access rights:

echo "username:password:level" >> ~/.config/deluge/auth

More on access rights.

And restart the daemon:

pkill deluged
deluged

If we want deluge to run along with the system, we need to create scripts that will do it.

We create a config:

sudo vim /etc/default/deluge-daemon

Paste this code in there necessarily DELUGED_USER must contain the user on behalf of which the daemon will run:

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

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

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

Create a startup script:

sudo vim /etc/init.d/deluge-daemon

And we write to it:

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

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 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 --umask $UMASK --test > /dev/null
REVAL1="$?"
start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --exec $DAEMON2 \
--chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK --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 --umask $UMASK -- $DAEMON1_ARGS
REVAL1="$?"
sleep 2
start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile --exec $DAEMON2 \
--chuid $DELUGED_USER --user $DELUGED_USER --umask $UMASK -- $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
REVAL1="$?"
[ "$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

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

Set execute permissions for root:

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

Add a script to autoload and unload:

sudo update-rc.d deluge-daemon defaults

Well, we check the work done.

Share