Version 2 (modified by Cas, 9 years ago) (diff) |
---|
systemd Scripts
Firstly ensure Deluge daemon deluged and Web UI deluge-web are installed.
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 script
Get rid of any old init 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:
[Unit] Description=Deluge Bittorrent Client Daemon After=network.target [Service] User=deluge Type=simple ExecStart=/usr/bin/deluged -d [Install] WantedBy=multi-user.target
Now start the service and verify it is running:
systemctl start deluged systemctl status deluged
Deluge Web UI (deluge-web) Service
Create the file /etc/systemd/system/deluge-web.service:
[Unit] Description=Deluge Bittorrent Client Web Interface After=network.target [Service] User=deluge Type=simple ExecStart=/usr/bin/deluge-web [Install] WantedBy=multi-user.target
Now start the service and verify it is running:
systemctl start deluge-web systemctl status deluge-web
Note: Both these service scripts should be updated so that deluge-web starts on deluged service and both respawn, the same as upstart scripts.
Enable the service on boot
Enable the services to start up on boot:
systemctl enable deluged systemctl enable 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 above commands affect the log directory and all files within it, combined with the umask specified in the upstart jobs these 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. Chmod
Edit the service files like so:
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
- Refer to the FAQ for possible log-levels.
Restart the daemon:
sudo restart deluged
Create /etc/logrotate.d/deluge with the following code to rotate the logs:
/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 }