MSS-rTorrent-Configure
下载分类管理简易流程:
1.RTqueue.sh每三分钟运行一次,过程为: 检查watch下.torrent文件数量, 如果小于max_active_dl就从queue目录中寻找文件, 如果有.torrent文件就把它转移到对应的watch(比如!Game)下。 非.torrent文件会被放到unkownfile下。 2.rTorrent的schdule监测watch各目录(设定为每10秒) 只要有.torrent存在时,就将它启动下载任务。 3.下载100%完成后执行on_finished部分(不可以有手动off的文件,必须全部下载) on_finished = move_complete:转移对应的下载文件到设定的目录中去(如\pub\Downloads\!Game) on_finished = remove_fin 任务标志T被去掉,删掉watch下关联的.torrent文件(这步非常重要,否则RTqueue.sh无法添加新任务) on_finished = 4g 判断是否有分割的2G以上文件要合并。 4.进行ratio判读,符合的将任务close掉,不符合的划分到seeding窗口下开始作种。 ----------------------------------------------------------------------------------------------------- 监测watch目录下的种子数,而且支持多级目录,清晰直观。 实现步骤: queue分类->watch分类->下载后分类,已经可以实现rt文件完美管理。 一定要在配置文件中加上:schedule = tied_directory,10,10,start_tied= (1)设定不同的watch目录,并且都有相应的watch_wait目录放等待种子 每个watch目录有自己的ratio分享率,在ratio达到后自动存放到相应分类目录。 (2)自动监测下载任务数(不包含seeding的种子),定义总数为12。 (3)在下载完成后进行一系列动作,包括4G以上文件合并、watch目录下的种子文件自动删除。 ----------------------------------------------------------------------------------------------------- (1) 要将文件夹全面重新规划,按照自己喜欢的方式分类。 (已经下载的所有文件也可以利用相应的命令全部转移,但比较麻烦,建议还是就全部重新设定,感兴趣的可以看下面迁移旧文件部分) 将rtorrent直接迁移到/pub下,分为.session,watch,queue(下设若干分类文件夹,可任意追加) 结构图如下: /pub [rT程序文件夹] /rtorrent /.session [rT下载中任务目录] /watch /!Game /!Video /!seeding /queue /!Game /!Video /!seeding /Downloads /!Game /!Video /!seeding /!working [rT下载中任务目录] 以上的目录结构时需修改配置文件.rtorrent.rc中的设定有: #下载时临时存放目录以及session存放目录 directory = /shares/mss-hdd/Public/Downloads/!working session = /shares/mss-hdd/Public/rtorrent/.session 分别建立三组监视目录,并在下载完成后转移文件到对应文件夹下。 可以任意追加和设定分组,只要修改d.set_custom1=后面的目录位置即可。 schedule = wd_1,10,10,"load_start=/pub/rtorrent/watch/!seeding/*.torrent,d.set_custom1=/pub/Downloads/!seeding" schedule = wd_2,20,10,"load_start=/pub/rtorrent/watch/!Game/*.torrent,d.set_custom1=/pub/Downloads/!Game" schedule = wd_3,30,10,"load_start=/pub/rtorrent/watch/!Video/*.torrent,d.set_custom1=/pub/Downloads/!Video" on_finished = move_complete,"d.set_directory=$d.get_custom1= ;execute=mv,-u,$d.get_base_path=,$d.get_custom1=" ratio可以利用0.8.4版本的新功能进行设定. 默认的分享率设定为下面四句。 是指当上传大于200M且分享率达到50%时自动关闭任务,或者只要达到分享率100%就关闭 ratio.enable= ratio.min.set=50 ratio.max.set=100 ratio.upload.set=200M -- on执行语句部分 -- #下载完成后将文件转移至指定的custom1文件夹 on_finished = move_complete,"d.set_directory=$d.get_custom1= ;execute=mv,-u,$d.get_base_path=,$d.get_custom1=" #下载完成后删除watch下.torrent文件 on_finished = remove_tied,"d.delete_tied=" #下载完成后执行4g合并脚本 on_finished = 4g,"execute=RT4g.sh,$d.get_base_path=,$d.get_custom2=" (注:脚本已更新) #删除任务时也将相关文件一并删除(有时会失效,无法解决,是rTorrent本身的问题) on_erase = rm_complete,"execute=rm,-rf,$d.get_base_path=" -- schedule语句,用于监测各分类脚本 -- #测试用分组,可修改部分用红色标注,分别是 - 名称(wd_test),开始时间(30秒后),时间间隔(10秒),监视分类目录(/pub/rtorrent/watch/test/),完成存放目录(/pub/Downloads/test) schedule =[color=red]wd_test,10,10[/color],"load_start_verbose=[color=red]/pub/rtorrent/watch/test/*.torrent[/color],d.set_custom1=[color=red]/pub/Downloads/test[/color]" ------------------------------------------------------------------------------------------- (2) 自动监测下载任务数(不包含seeding的种子),定义总数为10。 完成度100%,目前实现的是针对watch和queue两个目录的总数量进行管理, 没有涉及分类(实现毫无问题,问题在于按什么规则?似乎没必要或仍想不到每一个分组的任务控制规则) 实现整个下载分类管理步骤:queue分类->watch分类->下载完成分类,已经可以实现rt文件完美管理。 注:在.rtorrent.rc配置文件中加上:schedule = tied_directory,10,10,start_tied= 加入此条后,如果需要暂时关闭任务,必须到screen下ctrl+k(关闭任务),因为ntorrent中的close只能让任务关闭又被启动。 但又需要注意该任务会被自动加上I标志,下次要执行任务时要到screen下按"I"键取消就可以开始下载了。 新脚本的作用是:监测watch目录下的种子数,而且支持多级目录,清晰直观。 下载任务队列管理脚本RTqueue.sh如下(附件中已上传), 把它保存到/opt/bin后,然后crontab -e加入一行*/3 * * * * /opt/bin/RTqueue.sh 这是我根据下面这个国外脚本缩减为为简易实用的(国外那个功能更强大) max_active_dl=设最大任务数(128M内存设12为宜) _dir,是几个相关目录的地址(unknown须建立,用于保存后缀名不是.torrent的文件) logfile保存脚本的纪录(须建立,可任意指定位置) #!/opt/bin/sh # # rTorrent queue manager rtqm.sh # 2009/01/20 # #export LC_ALL=zh_CN.UTF-8 #export TZ=CST-8 max_active_dl=10 # queue_dir="/shares/mss-hdd/Public/rtorrent/queue" watch_dir="/shares/mss-hdd/Public/rtorrent/watch" session_dir="/shares/mss-hdd/Public/rtorrent/.session" unknown_dir="/shares/mss-hdd/Public/rtorrent/unknown_file" logfile="/shares/mss-hdd/Public/log/rtqm.log" no_queue_bt=`find $queue_dir/. -type f | wc -l | awk '{print $1}'`; no_watch_bt=`find $watch_dir/. -type f | wc -l | awk '{print $1}'`; # check if there is torrent for download if [ $no_queue_bt -ge 1 ]; then # make sure active download session is less than maximum download if [ $no_watch_bt -le $max_active_dl ]; then loop=$(($max_active_dl-$no_watch_bt)) if [ $no_queue_bt -lt $loop ]; then loop=$no_queue_bt; fi echo "" >> $logfile date >> $logfile #insert i=0; until [ $i -eq $loop ] do src_bt=`find $queue_dir/. -type f |sort | head -1 | sed 's/\ /\\ /g'`; file_type=${src_bt##*.} if [ $file_type = 'torrent' ]; then dest_bt="${watch_dir}${src_bt#*/queue/.}" dest_dir=$(dirname "$dest_bt") # get the base directory cat=${dest_dir#*/watch/*} cat=${cat%%/*} # move files echo "move $dest_bt" >> $logfile if cp -fr "$src_bt" "$dest_bt" ; then rm -fr "$src_bt" else echo "unstable to copy file $src_bt" >> $logfile fi i=$(( $i + 1 )); else echo "unsupported file $src_bt" >> $logfile mv $src_bt $unknown_dir fi done fi fi ------------------------------------------------------------------------------------------- (3) 在下载完成后进行一系列动作,包括4G以上文件合并、watch目录下的种子文件自动删除。 完成度100%,目前想要的on以后的功能已经都实现了。 on_finished = move_complete,"d.set_directory=$d.get_custom1= ;execute=mv,-u,$d.get_base_path=,$d.get_custom1=" on_finished = remove_fin,"d.delete_tied=" on_finished = 4g,"execute=RT4g.bash,$d.get_base_path=" on_erase = rm_complete,"execute=rm,-rf,$d.get_base_path=" ------------------------------------------------------------------------------------------- (4) 小小Tip - 如果要增加一个分类,要做的就是下面的步骤,反之删掉即可。 1. - .rtorrent.rc增加一行 schedule = wd_1,10,10,"load_start=/pub/rtorrent/watch/!seeding/*.torrent,d.set_custom1=/pub/Downloads/!seeding" 2. - 建立目录 /pub/rtorrent/watch/!seeding/ /pub/rtorrent/queue/!seeding/ 3. - 下面两句话的作用是,watch目录中有种子文件就start,没有就close。 所以如果想暂停某个任务时,可以把它移动到其他目录下就会停止任务 (也可放回queue,等待排队后自动重新放回watch下,任务就自动开始) schedule = tied_directory,10,10,start_tied= schedule = untied_directory,10,10,close_untied= ------------------------------------------------------------------------------------------- 迁移旧文件步骤(注意有可能操作不当会造成rTorrent崩溃, 建议不熟练的话,最好把任务都close并且ctrl+q然后再启动rtorrent进行迁移) 1.如果session目录变更了才需要实施 首先要ctrl+q关闭rtorrent,然后把旧目录下所有文件复制到新目录下 2.启动rtorrent进行文件的转移。 比如说原有某游戏A放在/pub/Downloads下,而且有关联.torrent种子文件放在旧watch目录下。 以下均要求screen -r窗口中,把光标对应到需要转移的A任务进行操作。 1.按U键去掉种子关联(有关联的任务状态为T) 2.把/pub/Downloads下文件移动到/pub/Downloads/!Game下 3.按ctrl+O变更存放位置:删掉给出的目录字符串,把/pub/Downloads/!Game复制或输入后回车 4.按x键,最下面显示command,输入d.set_custom1=/pub/Downloads/!Game 5.按ctrl+S开始这个任务,会hash到100%的进度。 6.hash后任务完成。 servers http://www./server.met overnet - node http://download./contact.dat kad - node http://www./nodes.dat http://renololo1./e/nodes.dat ==Change Directory== Default: ~/.mldonkey/incoming/files Default BT: ~/.mldonkey/incoming/directories & ~/.mldonkey/temp Make Change on ~/.mldonkey/downloads.ini,"SECTION : Paths" $ ln -s ~/Videos/incoming ~/.mldonkey/incoming |
|
来自: Tim You > 《Router.Hack》