Version 6 (modified by kit, 12 years ago) (diff) |
---|
Ubuntu Upstart Job
Ubuntu Upstart Job
Based on the previous Ubuntu init script here.
Notes
- Seems to work for me, please update this guide if you can improve it.
User Management
This guide assumes you have a user and group account specifically for running Deluge as.
If not, you may need to create them using something like the following command:
# sudo adduser --system --group --home /var/lib/deluge deluge
- Assuming the user and group didn't already exist, this creates a new system user and group named deluge with no login access and /var/lib/deluge as the home directory.
Add any users you wish to be able to easily manage or access files downloaded through Deluge to the group deluge will run as, for example:
# sudo adduser <username> deluge
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=007 exec start-stop-daemon -S -c $uid:$gid -k $umask -x /usr/bin/deluged -- -d
- Warning: You may wish to modify the above umask as it affects new files downloaded through deluge after it is started with this upstart job.
- 007 grants full access to the user and members of the group Deluge is running as (in this case deluge) and prevents access from all other accounts.
- 022 grants full access to the user Deluge 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.
If you experiment with different values, Deluge must be stopped and started instead of just restarted after changes, as described later in this page.
If you enable logging, as described later in this page, the umasks specified here also affect the permissions of newly created logs.
Put this 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 env umask=027 exec start-stop-daemon -S -c $uid:$gid -k $umask -x /usr/bin/deluge-web
- Note: The use of a umask with deluge-web is believed to only affect the permissions of plugin scripts installed through the web UI and, if you enable logging, deluge-web logs.
- 027 grants full access to the user deluge is running as, read access to members of the group that deluge is running as and prevents access from all other accounts.
Group permission was restricted to read only in order to prevent the possibility that compromised member accounts could inject malicious code in to plugins or modify the log.
- 027 grants full access to the user deluge is running as, read access to members of the group that deluge is running as and prevents access from all other accounts.
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
Starting (and stopping) Deluge
# sudo start deluge # and stopping: # sudo stop 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 # and stopped with: # sudo stop deluge-web
Logging
Create a structure for Deluge to log to and give the user that Deluge is running as (in this case deluge) full access to that directory:
# sudo mkdir -p /var/log/deluge # sudo chown -R deluge:deluge /var/log/deluge # sudo chmod -R 750 /var/log/deluge
- Note: The previous commands affect the log directory and all files within it.
However, as already mentioned, the umask specified in the upstart jobs at the top of this page affect the permissions new logs are created with.- 750 grants full access to the deluge user, only recurse tree and read access to members of the deluge group and prevents access from all other accounts.
Refer to Wikipedia for details of possible values and their effects.
- 750 grants full access to the deluge user, only recurse tree and read access to members of the deluge group and prevents access from all other accounts.
Edit the upstart job 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 the 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 }