2016年4月3日 星期日

如何啟用多個 transmission daemon (on ubuntu server)


如果你現在有跑 transmission-daemon 的服務,請先把它停下來
sudo service transmission-daemon stop
將 transmission-daemon 複製一份出來
cp /usr/bin/transmission-daemon /usr/bin/transmission-daemon2
cp /etc/init.d/transmission-daemon /etc/init.d/transmission-daemon2
建立新的帳號來處理 transmission
sudo adduser --shell /sbin/nologin --home /var/lib/transmission-daemon2 debian-transmission2
複製一份 transmission 的設定檔目錄
sudo cp -r /var/lib/transmission-daemon /var/lib/transmission-daemon2
變更該目錄權限
sudo chown -R debian-transmission2:debian-transmission2 /var/lib/transmission-daemon2
複製 etc 中的設定檔
cp -a /etc/transmission-daemon /etc/transmission-daemon2
變更權限
sudo chown -R debian-transmission2:debian-transmission2 /etc/transmission-daemon2
複製預設的transmission的設定檔
cp /etc/default/transmission-daemon /etc/default/transmission-daemon2
將設定檔 link 到相關的位置
ln -sf /etc/transmission-daemon2/settings.json /var/lib/transmission-daemon2/info/settings.json

修改檔案 /etc/init.d/transmission-daemon2
NAME=transmission-daemon
USER=debian-transmission
to
NAME=transmission-daemon2
USER=debian-transmission2

修改檔案 /etc/transmission-daemon2/settings.json
"download-dir": "/var/lib/transmission-daemon/downloads"
to
"download-dir": "/var/lib/transmission-daemon2/downloads"

"peer-port": 51413,
to
"peer-port": 51414,

"rpc-password": "{74567890732098******6238d58a4510eda06ff7sCZfdZ",
to
"rpc-password": "newpassword",

"rpc-username": "transmission",
to
"rpc-username": "newuser",

"rpc-port": 9091,
to
"rpc-port": 9092,

"rpc-whitelist-enabled": true,
to
"rpc-whitelist-enabled": false,

CONFIG_DIR="/var/lib/transmission-daemon/info"
to
CONFIG_DIR="/var/lib/transmission-daemon2/info"

將服務設定為預設啟動
sudo update-rc.d transmission-daemon2 defaults

手動將服務啟動
sudo /etc/init.d/transmission-daemon start
sudo /etc/init.d/transmission-daemon2 start

服務啟動後 9091與9092 為兩個 transmission 的服務 port
now transmission-daemon is
http://IP-ADDRESS:9091

transmission-daemon2 is
http://IP-ADDRESS:9092

參考來源: