Version 5 (modified by kit, 12 years ago) (diff)

Specifying umask should only be necessary (and effective) for the daemon (deluged)

Ubuntu Upstart Job

Based on the previous Ubuntu scripts here.

Notes

  • This seems to work for me.
  • I can't remember if I manually created the deluge user first, you may need to.
  • Please update this guide if you can improve it.

Upstart Jobs

Put this in /etc/init/deluge.conf and set uid and gid to the user and group you wish to run deluge as:

start on (filesystem and networking) or runlevel [2345]
stop on runlevel [016]

env uid=deluge
env gid=deluge
env umask=000

exec start-stop-daemon -S -c $uid:$gid -k $umask -x /usr/bin/deluged -- -d

This should be placed in /etc/init/deluge-web.conf, remember to set uid and gid to your preference:

start on started deluge
stop on stopping deluge

env uid=deluge
env gid=deluge

exec start-stop-daemon -S -c $uid:$gid -x /usr/bin/deluge-web
  • Note: The above umasks grants all users of your system full access to your downloads.
  • Refer to Wikipedia for a primer on possible values and their effects.

Migration

If you followed the old guide to make an init script, remove it:

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

Start deluge

sudo start deluge

Web UI

  • To prevent the web-ui starting automatically after deluge, just remove the 'start on' line from deluge-web.conf or comment it out by adding a # before it.
    The web-ui can then be started (and stopped) manually with:
    sudo start deluge-web # sudo stop deluge-web
    

Logging

Create a structure for deluge to log to:

sudo mkdir -p /var/log/deluge

Give the user that deluge is running as (in this case deluge) write-access to the logs:

sudo chmod -R 755 /var/log/deluge
sudo chown -R deluge /var/log/deluge

Edit the init confs like so:

exec start-stop-daemon -S -c $uid:$gid -k $umask -x /usr/bin/deluged -- -d -l /var/log/deluge/daemon.log -L warning
exec start-stop-daemon -S -c $uid:$gid -x /usr/bin/deluge-web -- -l /var/log/deluge/web.log -L warning
  • Refer to FAQ for possible log-levels.

Restart the daemon:

sudo restart deluge

Tell logrotate to rotate the logs by putting this in /etc/logrotate.d/deluge:

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