grav/pages/02.deluge/docs.md

145 lines
3.6 KiB
Markdown
Raw Normal View History

---
title: ''
body_classes: ''
order_by: ''
order_manual: ''
---
2017-03-13 08:04:17 +00:00
# Deluge (Table of Contents)
* [Install Deluge Daemon and Web UI](#install)
* [Verify Installion](#verify)
* [User Management](#user)
* [Autostart deluged with systemd](#auto)
* [Autostart Web UI with systemd](#webui)
* [Enable Logging](#logging)
* [Enable Log Rotation](#rotation)
* [Finally](#finally)
### Install Deluge Daemon and Web UI <a id="install"></a>
```sh
$ sudo add-apt-repository ppa:deluge-team/ppa
$ sudo apt update
$ sudo apt install deluge deluged deluge-web deluge-webui
```
2017-03-13 08:04:17 +00:00
### Verify Deluge Installion <a id="verify"></a>
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 <a id="user"></a>
For security it is best to run a service with a specific user and group.
You can create one using the following command:
Add to the `deluge`
group any users you wish to be able to easily manage or access files
downloaded through Deluge, for example:
2017-03-13 08:04:17 +00:00
```sh
sudo adduser --system --gecos "Deluge Service" --disabled-password --group --home /var/lib/deluge deluge
sudo adduser tanshu deluge
2017-03-13 08:04:17 +00:00
```
2017-03-13 08:04:17 +00:00
### Autostart deluged with systemd <a id="auto"></a>
Create the file `/etc/systemd/system/deluged.service` containing the following:
```sh
sudo nano /etc/systemd/system/deluged.service
```
2017-03-13 08:04:17 +00:00
```
[Unit]
Description=Deluge Bittorrent Client Daemon
After=network-online.target
[Service]
Type=simple
User=deluge
Group=deluge
UMask=007
ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L warning
Restart=on-failure
2017-03-13 08:04:17 +00:00
# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=300
[Install]
WantedBy=multi-user.target
```
2017-03-13 08:04:17 +00:00
Enable the service with:
```sh
systemctl enable /etc/systemd/system/deluged.service
systemctl start deluged
systemctl status deluged
```
2017-03-13 08:04:17 +00:00
### Autostart Web UI with systemd <a id="webui"></a>
Create the file `/etc/systemd/system/deluge-web.service` containing the following:
```sh
sudo nano /etc/systemd/system/deluge-web.service
```
2017-03-13 08:04:17 +00:00
```
[Unit]
Description=Deluge Bittorrent Client Web Interface
After=network-online.target
[Service]
Type=simple
User=deluge
Group=deluge
UMask=027
ExecStart=/usr/bin/deluge-web -l /var/log/deluge/web.log -L warning
Restart=on-failure
[Install]
WantedBy=multi-user.target
```
2017-03-13 08:04:17 +00:00
Enable the service with:
2017-03-13 08:04:17 +00:00
```
systemctl enable /etc/systemd/system/deluge-web.service
systemctl start deluge-web
systemctl status deluge-web
```
2017-03-13 08:04:17 +00:00
### Logging <a id="logging"></a>
Create a log directory for Deluge and give the service user (e.g. `deluge`), full access:
```sh
$ sudo mkdir -p /var/log/deluge
$ sudo chown -R deluge:deluge/var/log/deluge
$ sudo chmod -R 750 /var/log/deluge
```
2017-03-13 08:04:17 +00:00
- 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.
- See Deluge Logging for all available log-levels.
### Log Rotation <a id="rotation"></a>
To enable log rotation create `/etc/logrotate.d/deluge` with the following code:
2017-03-13 08:04:17 +00:00
```
/var/log/deluge/*.log {
rotate 4
weekly
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
systemctl restart deluged >/dev/null 2>&1 || true
systemctl restart deluge-web >/dev/null 2>&1 || true
endscript
}
```
2017-03-13 08:04:17 +00:00
### Open Browser <a id="finally"></a>
`http://localhost:8112`