wget http://github.itzmx.com/1265578519/transmission/master/2.84/transmissionbt.sh -O transmissionbt.sh
sh transmissionbt.sh
访问地址为http://IP:9091,默认用户名和密码均为itzmx.com,文件下载位置:/home/transmission/Downloads/
如需修改配置,需要先暂停服务,否则修改无效。
service transmissiond stop
vi /home/transmission/.config/transmission/settings.json
rpc-username 帐号
rpc-password 密码
rpc-port 端口
rpc-authentication-required 是否开启使用账号密码加密访问
preallocation 需要设置为0,这是这个办法中不会爆盘的关键。
启动Transmission服务:
service transmissiond start
如需卸载Transmission:
service transmissiond stop
rm -rf /home/transmission
rm -rf /usr/share/transmission
这是一个扩展工具,可以令Transmission具备RSS下载的功能,其实也能自动删除种子(但是我的情况比较特殊,VPS硬盘比较小,用FlexGet的clean_transmission和free_space插件会有问题)。
安装编译环境:
yum install -y gcc make zlib zlib-devel readline-devel sqlite sqlite-devel openssl-devel mysql-devel gd-devel
安装 Python(一般的VPS系统都自带,有能力自行修改后面代码的可以不安装):
wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
tar zxf Python-2.7.13.tgz
pushd Python-2.7.13
./configure–prefix=/root/python&&
make&&
make install&&
ln -s /root/python/bin/python2.7 /usr/local/bin/python
source ~/.bash_profile
popd
安装 pip:
wget https://bootstrap.pypa.io/get-pip.py –no-check-certificate
/usr/local/bin/python get-pip.py
安装 virtualenv:
/usr/local/bin/pip install virtualenv
ln -s /root/python/bin/virtualenv /usr/local/bin/virtualenv
安装 FlexGet:
cd /root/
virtualenv /root/flexget/
/root/flexget/bin/pip install flexget
/root/flexget/bin/pip install transmission-rpc
添加FlexGet配置文件:
vi /root/flexget/config.yml
配置文件示例:
tasks:
mt:
rss: https://tp.m-team.cc/torrentrss.php?https=1&rows=10&cat410=1&cat429=1&cat424=1&cat430=1&icat=1&isize=1&iuplder=1&linktype=dl&passkey=*****
accept_all: yes
content_size:
min: 256
max: 3072
download: /home/transmission/torrent
transmission:
host: 127.0.0.1
port: 9091
username: user
password: password
先创建torrent下载的目录:
mkdir /home/transmission/torrent
执行FlexGet:
/root/flexget/bin/flexget -c /root/flexget/config.yml execute
在其中加入:
意思是,每5分钟执行一次。
crontab -e
*/5 * * * * /root/flexget/bin/flexget -c /root/flexget/config.yml execute
自动清理种子脚本
自动清理种子的任务我交给了另外一个脚本来执行。
新建脚本文件:
vi /root/trans_cleanup.sh
#! /bin/bash
#====================================================================
# trans_cleanup.sh
#
# Copyright (c) 2011, WangYan <webmaster@wangyan.org>
# All rights reserved.
# Distributed under the GNU General Public License, version 3.0.
#
# Monitor disk space, If the Over, delete some files.
#
# See: http://wangyan.org/blog/trans_cleanup.html
#
# V0.2, since 2012-10-29
#====================================================================
# The transmission remote login username
USERNAME=”username”
# The transmission remote login password
PASSWORD=”password”
# The transmission download dir
DLDIR=”/home/transmission/Downloads”
# The maximum allowed disk (%)
DISK_USED_MAX=”90″
# Enable auto shutdown support (Disable=0, Enable=1)
ENABLE_AUTO_SHUTDOWN=”0″
# Log path settings
LOG_PATH=”/var/log/trans_cleanup.log”
# Date time format setting
DATA_TIME=$(date +”%y-%m-%d %H:%M:%S”)
#====================================================================
dist_check()
{
DISK_USED=`df -h $DLDIR | grep -v Mounted | awk ‘{print $5}’ | cut -d ‘%’ -f 1`
DISK_OVER=`awk ‘BEGIN{print(‘$DISK_USED‘>’$DISK_USED_MAX‘)}’`
}
dist_check
if [ “$DISK_OVER” = “1” ];then
for i in `transmission-remote –auth $USERNAME:$PASSWORD -l | grep 100% | grep Done | awk ‘{print $1}’ | grep -v ID`
do
[ “$i” -gt “0” ] && echo -n “$DATA_TIME [Done] ” >> $LOG_PATH
transmission-remote –auth $USERNAME:$PASSWORD -t $i –remove-and-delete >> $LOG_PATH 2>&1
[ “$i” -gt “0” ] && sleep 10 && dist_check
[ “$DISK_OVER” = “0” ] && break
done
fi
if [ “$DISK_OVER” = “1” ];then
for ii in `transmission-remote –auth $USERNAME:$PASSWORD -l | grep Stopped | awk ‘{print $1}’ | grep -v ID`
do
[ “$ii” -gt “0” ] && echo -n “$DATA_TIME [Stopped] ” >> $LOG_PATH
transmission-remote –auth $USERNAME:$PASSWORD -t $ii –remove-and-delete >> $LOG_PATH 2>&1
[ “$ii” -gt “0” ] && sleep 10 && dist_check
[ “$DISK_OVER” = “0” ] && break
done
fi
if [ “$DISK_OVER” = “1” ];then
for iii in `transmission-remote –auth $USERNAME:$PASSWORD -l | grep -v Sum | awk ‘{print $1}’ | grep -v ID`
do
[ “$iii” -gt “0” ] && echo -n “$DATA_TIME [Up or Down] ” >> $LOG_PATH
transmission-remote –auth $USERNAME:$PASSWORD -t $iii –remove-and-delete >> $LOG_PATH 2>&1
[ “$iii” -gt “0” ] && sleep 10 && dist_check
[ “$DISK_OVER” = “0” ] && break
done
fi
if [ “$DISK_OVER” = “1” ];then
rm -rf $DLDIR/*
fi
if [ “$ENABLE_AUTO_SHUTDOWN” = “1” ];then
SHUTDOWN=1
for STATUS in `transmission-remote –auth $USERNAME:$PASSWORD -l | awk ‘{print $9}’`
do
if [[ “$STATUS” = “Up” || “$STATUS” = “Uploading” ]];then
SHUTDOWN=0
fi
done
TASK_TOTAL=`transmission-remote –auth $USERNAME:$PASSWORD -l | grep -Ev ‘(ID|Sum)’ | wc -l`
if [ “$TASK_TOTAL” -gt “0” ] && [ “$SHUTDOWN” -eq “1” ];then
echo -n “$DATA_TIME ” >> $LOG_PATH
shutdown now >> $LOG_PATH 2>&1
fi
fi
修改好其中的用户名、密码、Transmission下载目录和硬盘最大使用的百分比(DISK_USED_MAX=”90″)。
定时任务(crontab -e)中添加:
*/1 * * * * /bin/bash /root/trans_cleanup.sh