Version 9 (modified by Cas, 8 years ago) (diff)

add mount info

systemd Scripts

Note: Improvements to propagate from Upstart still: deluge-web starting upon deluged starting and filesystems are mounted e.g. and

Verify Deluge Installion

Ensure Deluge daemon deluged and Web UI deluge-web are installed.

Use which deluged or which deluge-web to check installation path.

If they are not installed in the usual /usr/bin modify the service file ExecStart? lines to point to the correct location (e.g. /usr/local/bin/deluged).

User Management

For security it is best to run a service with a specific user and group. You can create one using the following command:

sudo adduser --system  --gecos "Deluge Service" --disabled-password --group --home /var/lib/deluge deluge
  • This creates a new system user and group named deluge with no login access and home directory: /var/lib/deluge

Add to the deluge group any users you wish to be able to easily manage or access files downloaded through Deluge, for example:

sudo adduser <username> deluge

Migration from init.d or Upstart scripts

Remove any old init.d files named deluge in /etc/init.d/ like this:

sudo /etc/init.d/deluge-daemon stop
sudo rm /etc/init.d/deluge-daemon
sudo update-rc.d deluge-daemon remove

Remove old upstart scripts like this:

sudo stop deluged
sudo stop deluge-web
sudo rm /etc/init/deluge-web.conf
sudo rm /etc/init/deluged.conf

Deluge Daemon (deluged) Service

Create the file /etc/systemd/system/deluged.service containing the following:

Description=Deluge Bittorrent Client Daemon


ExecStart=/usr/bin/deluged -d


# Configures the time to wait before service is stopped forcefully.

  • You may wish to modify the above umask as it applies to any files downloaded by deluged.
    • 007 grants full access to the user and members of the group deluged is running as (in this case deluge) and prevents access from all other accounts.
    • 022 grants full access to the user deluged is running as and only read access to other accounts.
    • 000 grants full access to all accounts.

Refer to Wikipedia for details of possible values and their effects. Deluged must be stopped and started instead of just restarted after changes. If you enable logging, as described later in this page, the umasks specified here also affect the permissions of newly created logs.

Now start the service, verify it is running and enable it to start up on boot:

systemctl start deluged
systemctl status deluged
systemctl enable deluged

Deluge Web UI (deluge-web) Service

Create the file /etc/systemd/system/deluge-web.service containing the following:

Description=Deluge Bittorrent Client Web Interface






Now start the service, verify it is running and enable it to start up on boot:

systemctl start deluge-web
systemctl status deluge-web
systemctl enable deluge-web


Create a log directory for Deluge and give the service user (e.g. deluge), full access:

sudo mkdir -p /var/log/deluge
sudo chown -R deluge:deluge /var/log/deluge
sudo chmod -R 750 /var/log/deluge
  • The deluge log directory is now configured so that user deluge has full access, group deluge read only and everyone else denied access. The umask specified in the services sets the permission of new log files.

Enable logging in the service files by editing the ExecStart line, appending -l and -L options:

ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L warning
ExecStart=/usr/bin/deluge-web -l /var/log/deluge/web.log -L warning

Restart the services:

systemctl restart deluged
systemctl restart deluge-web

Log Rotation

To enable log rotation create /etc/logrotate.d/deluge with the following code:

/var/log/deluge/*.log {
        rotate 4
                systemctl restart deluged >/dev/null 2>&1 || true
                systemctl restart deluge-web >/dev/null 2>&1 || true

Start deluged only if mount exists

If you have a usb disk drive or network drive that may not be immediately available to the deluged. The following additions wait for those mountpoints before starting deluged.

Ensure you have added the correct drive details to fstab or equivalent so they are mounted at boot. List the available drive mounts like so:

systemctl -t mount

Modify the deluged.service script by adding the following lines, changing xyz.mount for the selected mount from above command:

# Unit starts after the following mounts are available.
# Unit is stopped when any of these mounts disappear.