在Ubuntu 16.04 LTS上安装deluged
在用apt install deluged
装好后,一直没有办法实现作为服务启动,原因是包内附带的启动脚本是基于SysV的,而其中使用到的/lib/lsb/init-functions
在Ubuntu 16.04 LTS下默认没有x权限。
解决方法
主体思路是重写一份systemd版本的service。
安装deluge
apt install deluged
清理余毒
rm /etc/init.d/deluged
update-rc.d deluged remove
编写service文件
/etc/systemd/system/deluged.service
[Unit]
Description=Deluge Bittorrent Client Daemon
After=network-online.target
[Service]
Type=forking
PIDFile=/run/deluged/deluged.pid
User=debian-deluged
Group=debian-deluged
UMask=0027
# Make directory for PID file
PermissionsStartOnly=true
ExecStartPre=-/bin/rm -rf /run/deluged
ExecStartPre=/bin/mkdir /run/deluged
ExecStartPre=/bin/chown debian-deluged:debian-deluged /run/deluged
ExecStart=/usr/bin/deluged -c /var/lib/deluged/config -P /run/deluged/deluged.pid -l /var/log/deluged/daemon.log -L info
Restart=on-failure
# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=300
KillMode=mixed
[Install]
WantedBy=multi-user.target
启用service
systemctl enable /etc/systemd/system/deluged.service
systemctl start deluged
systemctl status deluged
其他
实际上WebUI(deluge-web)也需要类似的配置。
/etc/systemd/system/deluge-web.service
[Unit]
Description=Deluge Bittorrent WebUI Daemon
After=network-online.target
[Service]
Type=simple
User=debian-deluged
Group=debian-deluged
UMask=0027
ExecStart=/usr/bin/deluge-web -c /var/lib/deluged/config
Restart=on-failure
# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
另外,通过对/usr/lib/python2.7/dist-packages/deluge/ui/web/server.py
做如下修改可以使WebUI仅可从本地访问(利用反向代理等方式来远程访问):
674c674
< self.socket = reactor.listenTCP(self.port, self.site)
---
> self.socket = reactor.listenTCP(self.port, self.site, interface='127.0.0.1')