Created
August 14, 2018 03:46
-
-
Save rcguy/f1de27259a8a6a0751d7716ac42f6ffa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Installs deluge daemon + webui and systemd start scripts | |
# Tested on: Ubuntu Server 16.04.1 x64 / 4 Cores / 4GB RAM / 20 GB SSD | |
USER="rcguy" | |
# update the system first | |
sudo apt update && sudo apt upgrade -y | |
# add the deluge ppa so we get the most recent version | |
sudo add-apt-repository ppa:deluge-team/ppa | |
sudo apt update | |
sudo apt install deluged deluge-webui -y | |
# add a user to run deluge | |
sudo adduser --system --gecos "Deluge Service" --disabled-password --group --home /opt/deluge deluge | |
sudo adduser $USER deluge | |
# 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 755 /var/log/deluge | |
# create the systemd service file for the daemon | |
cat >> /etc/systemd/system/deluged.service <<EOF | |
[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 | |
# Configures the time to wait before service is stopped forcefully. | |
TimeoutStopSec=300 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
# create the systemd service file for the webui | |
cat >> /etc/systemd/system/deluge-web.service <<EOF | |
[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 | |
EOF | |
# enable log rotation | |
cat >> /etc/logrotate.d/deluge <<EOF | |
/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 | |
} | |
EOF | |
# enable both systemd scripts | |
systemctl enable /etc/systemd/system/deluged.service | |
systemctl enable /etc/systemd/system/deluge-web.service | |
# start both the daemon and webui | |
systemctl start deluged | |
systemctl start deluge-web | |
# check that status of our scripts | |
systemctl status deluged | |
systemctl status deluge-web | |
# end script | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, worked Great 👍