{"id":21719,"date":"2020-02-03T09:51:52","date_gmt":"2020-02-03T01:51:52","guid":{"rendered":"http:\/\/4563.org\/?p=21719"},"modified":"2020-02-03T09:51:52","modified_gmt":"2020-02-03T01:51:52","slug":"%e5%8f%91%e4%b8%aaaria2rclone%e8%87%aa%e5%8a%a8%e4%b8%8a%e4%bc%a0%e7%9a%84%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=21719","title":{"rendered":"\u53d1\u4e2aaria2+rclone\u81ea\u52a8\u4e0a\u4f20\u7684\u4ee3\u7801"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>\u5343\u725b<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-16 16:35:27\t<\/p>\n<h3>\u53d1\u4e2aaria2+rclone\u81ea\u52a8\u4e0a\u4f20\u7684\u4ee3\u7801<\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 \u5343\u725b \u4e8e 2020-1-16 16:47 \u7f16\u8f91 <\/p>\n<p> \u7ffb\u4e86\u597d\u591a\u7684\u5e16\u5b50\uff0c\u90fd\u6ca1\u6709\u81ea\u5df1\u60f3\u8981\u7684aria2+rclone\u4e0a\u4f20\u7684\u4ee3\u7801\uff0c\u4e8e\u662f\u81ea\u5df1\u6839\u636e\u4e4b\u524d\u7684qbittorrent+rclone\u7136\u540e\u6539\u4e86\u4e00\u4e2a\u51fa\u6765<br \/>  \u4e3a\u4ec0\u4e48\u65b0\u589e\u4e86\u8fd9\u6837\u4e00\u4e2a\uff1a\u5f88\u591a\u7684aria2\u7684\u4e0a\u4f20\u4ee3\u7801\u4e2d\uff0c\u4e0a\u4f20\u7ed3\u675f\u540e\u6ca1\u6709\u5220\u9664\uff0c\u5bf9\u4e8e\u6211\u4eec\u8fd9\u79cd\u5c0fj\u592a\u96be\u53d7\u4e86<br \/>  \u4f7f\u7528\u4e4b\u524d\u9700\u8981\u5148\u4fee\u6539\u4f7f\u7528\u53c2\u6570<br \/>  #!\/bin\/sh<br \/>  content_dir=$3<br \/>  files_num=$2<br \/>  task_id=$1<br \/>  downloadpath=&#8217;\/usr\/local\/caddy\/www\/aria2\/Download&#8217; # \u4e0b\u8f7d\u76ee\u5f55-\u9700\u8981\u548caria2\u4e00\u81f4<br \/>  log_dir=&quot;\/root\/.aria2&quot;# \u8fd9\u91cc\u662f\u5b58\u653elog\u7684\u5730\u65b9-\u9ed8\u8ba4\u548caria\u653e\u5728\u4e00\u8d77<br \/>  rclone_dest=&quot;AC&quot;&nbsp; &nbsp;&nbsp; &nbsp;# rclone\u7684disk\u540d\u79f0-\u9700\u8981\u4fee\u6539<br \/>  rpc_pwd=&quot;pwd&quot;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;# aria2\u7684rpc\u7684\u5bc6\u7801-\u9700\u8981\u4fee\u6539<br \/>  rpc_url=&quot;http:\/\/xxx.xxx.xxx:6800\/jsonrpc&quot; # aria2\u7684rpc\u5730\u5740&#8211;\u9700\u8981\u4fee\u6539<\/p>\n<p>  rclone_parallel=&quot;32&quot;<\/p>\n<p>  if [ ! -d ${log_dir} ]<br \/>  then<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; mkdir -p ${log_dir}<br \/>  fi<\/p>\n<p>  tmp_dir=$content_dir<br \/>  echo &quot;\u539f\u59cb\u76ee\u5f55\uff1a${content_dir}&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  while true; do#\u63d0\u53d6\u4e0b\u8f7d\u6587\u4ef6\u6839\u8def\u5f84\uff0c\u5982\u628a\/data\/a\/b\/c\/d.jpg\u53d8\u6210\/data\/a<br \/>  &nbsp; &nbsp; content_dir=&quot;${tmp_dir}&quot;<br \/>  &nbsp; &nbsp; tmp_dir=${tmp_dir%\/*};<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; if test -z &quot;${tmp_dir}&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;then<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;break<br \/>  &nbsp; &nbsp; elif [ &quot;${tmp_dir}&quot; = &quot;${downloadpath}&quot; ] &amp;&amp; [ $2 -eq 1 ]<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;then<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;break<br \/>  &nbsp; &nbsp; elif [ &quot;${tmp_dir}&quot; = &quot;${downloadpath}&quot; ]&nbsp; &nbsp;#\u6587\u4ef6\u5939<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;then<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;break<br \/>  &nbsp; &nbsp; fi<br \/>  done<\/p>\n<p>  if [ &quot;${files_num}&quot; = &quot;0&quot; ]<br \/>  &nbsp; &nbsp;then<br \/>  &nbsp; &nbsp;echo -e &quot;t\u6587\u4ef6\u6570\u91cf\u4e3a0 \u76f4\u63a5\u8df3\u8fc7n&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  &nbsp; &nbsp;exit <br \/>  fi<\/p>\n<p>  if [ &quot;${content_dir}&quot; = &quot;\/&quot; ] || [ &quot;${tmp_dir}&quot; != &quot;${downloadpath}&quot; ]<br \/>  &nbsp; &nbsp; then<br \/>  &nbsp; &nbsp; echo -e &quot;t\u8def\u5f84\u5f02\u5e38${tmp_dir} \u76f4\u63a5\u8df3\u8fc7n&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  &nbsp; &nbsp; exit<br \/>  fi<\/p>\n<p>  # \u63d0\u53d6\u5176\u4e2d\u7684\u76f8\u5bf9\u8def\u5f84-\u8fd9\u4e2a\u8def\u5f84\u5c31\u6bd4\u8f83\u7edd\u5bf9\u4e86<br \/>  relative_dir=&quot;${content_dir\/${downloadpath}\/}&quot; # \u79fb\u9664downloadpath\u5185\u5bb9\u540e\u7684content_dir<br \/>  relative_dir=&quot;${relative_dir:1}&quot; # \u79fb\u9664\u6389\u5750\u8d77\u659c\u6760<br \/>  echo &quot;\u76f8\u5bf9\u8def\u5f84\uff1a${relative_dir}&quot; &gt;&gt; ${log_dir}\/ariaUP.log<\/p>\n<p>  function rclone_copy(){<br \/>  &nbsp; &nbsp; if [ ${type} == &quot;file&quot; ]<br \/>  &nbsp; &nbsp; then<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;rclone_copy_cmd=$(rclone -v copy &#8211;transfers ${rclone_parallel} &#8211;log-file${log_dir}\/ariaUP.log &quot;${content_dir}&quot; ${rclone_dest}:)<br \/>  &nbsp; &nbsp; elif [ ${type} == &quot;dir&quot; ]<br \/>  &nbsp; &nbsp; then<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;rclone_copy_cmd=$(rclone -v copy &#8211;transfers ${rclone_parallel} &#8211;log-file${log_dir}\/rloneUP.log &quot;${content_dir}&quot; ${rclone_dest}:&quot;${relative_dir}&quot;)<br \/>  &nbsp; &nbsp; fi<br \/>  &nbsp; &nbsp; # echo &#8221;;<br \/>  }<br \/>  function rclone_del(){<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; rm -rf &quot;${content_dir}&quot;;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; rm -rf &quot;${content_dir}.aria2&quot;;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; curl -X POST -d &quot;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;method&quot;:&quot;aria2.removeDownloadResult&quot;,&quot;id&quot;:&quot;mjj&quot;,&quot;params&quot;:[&quot;token:${rpc_pwd}&quot;,&quot;${task_id}&quot;]}&quot; &quot;${rpc_url}&quot;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; # echo &#8221;;<br \/>  }<\/p>\n<p>  if [ -f &quot;${content_dir}&quot; ]<br \/>  then<br \/>  &nbsp; &nbsp;echo &quot;[$(date &#8216;+%Y-%m-%d %H:%M:%S&#8217;)] \u7c7b\u578b\uff1a\u6587\u4ef6 ${content_dir}&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  &nbsp; &nbsp;type=&quot;file&quot;<br \/>  &nbsp; &nbsp;rclone_copy<br \/>  &nbsp; &nbsp;rclone_del<br \/>  elif [ -d &quot;${content_dir}&quot; ]<br \/>  then <br \/>  &nbsp; &nbsp;echo &quot;[$(date &#8216;+%Y-%m-%d %H:%M:%S&#8217;)] \u7c7b\u578b\uff1a\u76ee\u5f55 ${content_dir}&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  &nbsp; &nbsp;type=&quot;dir&quot;<br \/>  &nbsp; &nbsp;rclone_copy<br \/>  &nbsp; &nbsp;rclone_del<br \/>  else<br \/>  &nbsp; &nbsp;echo &quot;[$(date &#8216;+%Y-%m-%d %H:%M:%S&#8217;)] \u672a\u77e5\u7c7b\u578b\uff0c\u53d6\u6d88\u4e0a\u4f20&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  fi<\/p>\n<p>  echo &quot;\u5185\u5bb9\u8def\u5f84\uff1a${content_dir}&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  echo &quot;\u4e0a\u4f20\u8def\u5f84\uff1a${rclone_dest}:${relative_dir}&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  echo &quot;\u6587\u4ef6\u6570\uff1a${files_num}&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  echo -e &quot;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-n&quot; &gt;&gt; ${log_dir}\/ariaUP.log<br \/>  \u4f7f\u7528\u65b9\u6cd5\u5f88\u7b80\u5355\uff1a<br \/>  1. \u786e\u8ba4\u4f60\u7684\u4e0b\u8f7d\u8def\u5f84\uff1a\/root\/.aria2\/.aria2.conf <br \/>  # \u6587\u4ef6\u7684\u4fdd\u5b58\u8def\u5f84(\u53ef\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\u6216\u76f8\u5bf9\u8def\u5f84), \u9ed8\u8ba4: \u5f53\u524d\u542f\u52a8\u4f4d\u7f6e<br \/>  dir=\/usr\/local\/caddy\/www\/aria2\/Download<br \/>  2. \u65b0\u589earia2\u7684\u4e0b\u8f7d\u7ed3\u675f\u4efb\u52a1\u4e8b\u4ef6<br \/>  on-download-complete=\/root\/.aria2\/ariaup.sh<br \/>  3. \u65b0\u5efa\/root\/.aria2\/ariaup.sh\u5e76\u586b\u5165\u4e0a\u9762\u4f60\u4fee\u6539\u597d\u7684\u7684\u4ee3\u7801 \u4e0d\u8981\u5fd8\u4e86\u7ed9\u8fd0\u884c\u6743\u9650<br \/>  chmod +x \/root\/.aria2\/ariaup.sh<br \/>  \u4e4b\u540e\u91cd\u542faria2\u5373\u53ef<br \/>  &#8212;&#8212;&#8212;<br \/>  \u672c\u4eba\u6d4b\u8bd5\u5df2\u7ecf\u6ca1\u6709\u95ee\u9898\u3002\u53ef\u4ee5\u4e0b\u8f7d\u540e\u81ea\u52a8\u4e0a\u4f20\u5e76\u5220\u9664\u6587\u4ef6\u8bb0\u5f55<br \/>  ps:\u4fee\u6539\u81ea\uff1axcy1020 AT: https:\/\/www.hostloc.com\/thread-612238-1-1.html\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u5927\u7c73<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-16 16:38:27\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u524d\u6392Mark\u4e00\u4e0b\u3002\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>etc<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-16 16:40:13\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u8c22\u8c22\u5927\u4f6c\u5206\u4eab\uff0c\u5df2\u7ecf\u6536\u85cf\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>C51<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-16 16:40:35\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u9a6c\u514b\uff0c\u611f\u8c22\u5927\u4f6c\uff01\uff01\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>riwsh<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-16 16:42:12\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u9a6c\u514b \u6b63\u597d\u9700\u8981 \u611f\u8c22\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>TvT<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-16 16:42:53\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u597d\u4e1c\u897f\uff0c\u611f\u8c22\u5927\u4f6c\u5206\u4eab\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>ansheng<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-16 16:47:39\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u53d1\u4e2adocker\u4e00\u952e\u8fd0\u884c+ AriaNg + aria2 + h5ai <br \/>  https:\/\/github.com\/anshengme\/docker-bt\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5343\u725b \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/21719"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21719"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/21719\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21719"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}