document.writeln('');
Aria2 完美配置是一套 Aria2 配置方案,包含了配置文件、附加功能腳本等文件,用于實現 Aria2 功能的增強和擴展,提升 Aria2 的下載速度與使用體驗,解決 Aria2 在使用中遇到的 BT 下載無速度、文件殘留占用磁盤空間、任務丟失、重復下載等問題。
為了確保能正常使用,請先安裝基礎組件wget、curl、ca-certificates,以 Debian/centos為例子:
<span class="hljs-attribute">apt</span> install wget curl ca-certificates <span class="hljs-comment">#debian</span>yum install wget curl ca-certificates <span class="hljs-comment">#centos</span><span class="hljs-attribute">apt</span> install wget curl ca-certificates <span class="hljs-comment">#debian</span> yum install wget curl ca-certificates <span class="hljs-comment">#centos</span>apt install wget curl ca-certificates#debianyum install wget curl ca-certificates #centos
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.shwget -N git.io/aria2.sh && chmod +x aria2.sh
Aria2項目GITHUB:
./aria2.sh./aria2.sh./aria2.sh
Aria2 一鍵安裝管理腳本 增強版 [v2<span class="hljs-number">.7</span><span class="hljs-number">.4</span>] <span class="hljs-keyword">by</span> P3TERX.COM<span class="hljs-number">0.</span> 升級腳本———————————————————————<span class="hljs-number">1.</span> 安裝 Aria2<span class="hljs-number">2.</span> 更新 Aria2<span class="hljs-number">3.</span> 卸載 Aria2———————————————————————<span class="hljs-number">4.</span> 啟動 Aria2<span class="hljs-number">5.</span> 停止 Aria2<span class="hljs-number">6.</span> 重啟 Aria2———————————————————————<span class="hljs-number">7.</span> 修改 配置<span class="hljs-number">8.</span> 查看 配置<span class="hljs-number">9.</span> 查看 日志<span class="hljs-number">10.</span> 清空 日志———————————————————————<span class="hljs-number">11.</span> 手動更新 BT-Tracker<span class="hljs-number">12.</span> 自動更新 BT-Tracker———————————————————————Aria2 狀態: 已安裝 | 已啟動自動更新 BT-Tracker: 已開啟請輸入數字 [<span class="hljs-number">0</span><span class="hljs-number">-12</span>]:Aria2 一鍵安裝管理腳本 增強版 [v2<span class="hljs-number">.7</span><span class="hljs-number">.4</span>] <span class="hljs-keyword">by</span> P3TERX.COM <span class="hljs-number">0.</span> 升級腳本 ——————————————————————— <span class="hljs-number">1.</span> 安裝 Aria2 <span class="hljs-number">2.</span> 更新 Aria2 <span class="hljs-number">3.</span> 卸載 Aria2 ——————————————————————— <span class="hljs-number">4.</span> 啟動 Aria2 <span class="hljs-number">5.</span> 停止 Aria2 <span class="hljs-number">6.</span> 重啟 Aria2 ——————————————————————— <span class="hljs-number">7.</span> 修改 配置 <span class="hljs-number">8.</span> 查看 配置 <span class="hljs-number">9.</span> 查看 日志 <span class="hljs-number">10.</span> 清空 日志 ——————————————————————— <span class="hljs-number">11.</span> 手動更新 BT-Tracker <span class="hljs-number">12.</span> 自動更新 BT-Tracker ——————————————————————— Aria2 狀態: 已安裝 | 已啟動 自動更新 BT-Tracker: 已開啟 請輸入數字 [<span class="hljs-number">0</span><span class="hljs-number">-12</span>]:Aria2 一鍵安裝管理腳本 增強版 [v2.7.4] by P3TERX.COM0. 升級腳本 ———————————————————————1. 安裝 Aria22. 更新 Aria23. 卸載 Aria2 ———————————————————————4. 啟動 Aria25. 停止 Aria26. 重啟 Aria2 ———————————————————————7. 修改 配置8. 查看 配置9. 查看 日志 10. 清空 日志 ——————————————————————— 11. 手動更新 BT-Tracker 12. 自動更新 BT-Tracker ———————————————————————Aria2 狀態: 已安裝 | 已啟動自動更新 BT-Tracker: 已開啟請輸入數字 [0-12]:
Aria2 簡單配置信息:IPv4 地址 : <span class="hljs-emphasis">*.*</span>.<span class="hljs-emphasis">*.*</span>IPv6 地址 : IPv6 地址檢測失敗RPC 端口 : 6800RPC 密鑰 : 122sd1111123456df42下載目錄 : /root/downloadsAriaNg 鏈接 : http://ariang.js.org/#!/settings/rpc/set/ws/<span class="hljs-emphasis">*.*</span>.<span class="hljs-emphasis">*.*</span>/6800/jsonrpc/ZjFdfkdikDAmNDI=Aria2 簡單配置信息: IPv4 地址 : <span class="hljs-emphasis">*.*</span>.<span class="hljs-emphasis">*.*</span> IPv6 地址 : IPv6 地址檢測失敗 RPC 端口 : 6800 RPC 密鑰 : 122sd1111123456df42 下載目錄 : /root/downloads AriaNg 鏈接 : http://ariang.js.org/#!/settings/rpc/set/ws/<span class="hljs-emphasis">*.*</span>.<span class="hljs-emphasis">*.*</span>/6800/jsonrpc/ZjFdfkdikDAmNDI=Aria2 簡單配置信息: IPv4 地址: *.*.*.* IPv6 地址: IPv6 地址檢測失敗 RPC 端口: 6800 RPC 密鑰: 122sd1111123456df42 下載目錄: /root/downloads AriaNg 鏈接: http://ariang.js.org/#!/settings/rpc/set/ws/*.*.*.*/6800/jsonrpc/ZjFdfkdikDAmNDI=
Aria2 默認已經自帶了Aria2NG了,打開:http://ariang.js.org/#xxxx那一串地址,就可以進入Aria2 離線下載界面了。
| 文件 | 說明 |
| aria2.conf | Aria2 配置文件。僅適用于 Aria2 1.35.0 及以上版本,在不了解的情況下修改可能導致本方案的特性失效。 |
| delete.sh | 文件刪除腳本。在下載停止后執行(on-download-stop),自動刪除文件及 .aria2 后綴名文件,防止不必要的磁盤空間占用。(默認啟用) |
| clean.sh | 清理腳本。在下載完成后執行(on-download-complete),自動清除 .aria2 后綴名文件。(默認啟用) |
| upload.sh | 上傳腳本。在下載完成后執行(on-download-complete),自動調用 RCLONE 上傳(move)下載的文件到網盤,并自動清除 .aria2 后綴名文件與空目錄。(默認不啟用) |
| move.sh | 文件移動腳本。在下載完成后執行(on-download-complete),自動將下載完成的文件移動到指定目錄,并自動清除 .aria2 后綴名文件與空目錄。(默認不啟用) |
| tracker.sh | BT tracker 列表更新腳本。在 Aria2 配置文件(aria2.conf)所在目錄執行即可獲取最新 tracker 列表并添加到配置文件中。此腳本還有更強大的功能,具體使用方法詳見 tracker.md |
| dht.dat dht6.dat | DHT 文件。提升 BT 下載率和下載速度的關鍵之一。相關科普:《解決 Aria2 無法下載磁力鏈接、BT種子和速度慢的問題》 |
Aria2 一鍵安裝管理腳本 增強版 整合了 Aria2 完美配置 ,安裝后會附帶一些附加功能腳本功能腳本,RCLONE 自動上傳腳本就是其中之一。由于默認不啟用,所以需要手動啟用。
TIPS: 本項目的上傳腳本使用更穩定快速的原生命令上傳方式,而非處在測試階段的掛載方式,這點和一般的腳本不同。
輸入以下命令打開 Aria2 配置文件進行修改
nano <span class="hljs-regexp">/root/</span>.aria2c/aria2.confnano <span class="hljs-regexp">/root/</span>.aria2c/aria2.confnano /root/.aria2c/aria2.conf
或使用Aria2 一鍵安裝管理腳本 增強版中的手動修改選項打開配置文件進行修改。找到“下載完成后執行的命令”,把clean.sh替換為upload.sh。
<span class="hljs-literal">on</span>-download-complete=<span class="hljs-regexp">/root/</span>.aria2c/upload.sh<span class="hljs-literal">on</span>-download-complete=<span class="hljs-regexp">/root/</span>.aria2c/upload.shon-download-complete=/root/.aria2c/upload.sh
nano 編輯器的操作方法參見《Linux 下適合新手的文本編輯器 nano 使用教程》
輸入以下命令打開附加功能腳本配置文件進行修改
nano <span class="hljs-regexp">/root/</span>.aria2c/script.confnano <span class="hljs-regexp">/root/</span>.aria2c/script.confnano /root/.aria2c/script.conf
有中文注釋,按照自己的實際情況進行修改,第一次使用只建議修改網盤名稱。
<span class="hljs-attr">drive-name</span>=remote<span class="hljs-attr">drive-name</span>=remotedrive-name=remote
重啟 Aria2 。腳本選項重啟或者執行以下命令:
<span class="hljs-attribute">service</span> aria2 restart<span class="hljs-attribute">service</span> aria2 restartservice aria2 restart
執行upload.sh腳本,提示success即代上傳腳本能正常被調用,否則請檢查與 RCLONE 有關的配置。
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh0/root/.aria2c/upload.sh
打開實時日志并下載任意文件,出現上傳成功信息即代表配置成功,否則請認真閱讀教程并重新開始。
檢查網盤是否存在相關文件,若不存在說明你搞錯網盤了。
Rclone是一個的命令行工具,支持在不同對象存儲、網盤間同步、上傳、下載數據。并且通過一些設置可以實現離線下載、服務器備份等非常實用的功能。這里以 OneDrive 和 Google Drive 為例子,進行連接配置,其它網盤的操作類似。由于是交互式配置選項,只要能看懂基本沒有任何難度。
RCLONE 官方提供了一鍵安裝腳本:
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh1curl https://rclone.org/install.sh | sudo bash
在本地Win-dows電腦上下載rclone win版,然后解壓出來,解壓后進入文件夾,在資源管理器地址欄輸入cmd,回車就會在當前路徑打開命令提示符。輸入以下命令:
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh2rclone authorize "onedrive"
接下來會彈出瀏覽器,要求你登錄賬號進行授權。授權完后命令提示符窗口會出現以下信息:
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh3If your browser doesnt open automatically go to the following link: http://127.0.0.1:53682/authLog in and authorize rclone for accessWaiting for code...Got codePaste the following into your remote machine --->{"access_token":"xxxxxxxx"}# 注意!復制{xxxxxxxx}整個內容,并保存好,后面需要用到<---End paste
輸入以下命令
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh4rclone config
會出現以下信息,參照下面的注釋進行操作。
TIPS: 因為 RCLONE 會時不時進行更新,當你看到這篇教程時菜單選項可能已經發生了略微的改動,但大致思路不會變,不要無腦照搬操作。
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh5e) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> n# 選擇n,新建name> remote# 輸入名稱,類似于標簽,用于區分不同的網盤。Type of storage to configure.Enter a string value. Press Enter for the default ("").Choose a number from below, or type in your own value[snip]XX / Microsoft OneDrive"onedrive"[snip]Storage>XX# 選擇Microsoft OneDrive對應的數字Microsoft App Client IdLeave blank normally.Enter a string value. Press Enter for the default ("").client_id># 留空,回車Microsoft App Client SecretLeave blank normally.Enter a string value. Press Enter for the default ("").client_secret># 留空,回車Edit advanced config? (y/n)y) Yesn) Noy/n> n# 選nRemote configUse auto config? * Say Y if not sure * Say N if you are working on a remote or headless machiney) Yesn) Noy/n> n# 選nFor this to work, you will need rclone available on a machine that has a web browser available.Execute the following on your machine:rclone authorize "onedrive"Then paste the result below:result> {"XXXXXXXX"}# 復制上面Win下獲取的token值到這里Choose a number from below, or type in an existing value 1 / OneDrive Personal or Business"onedrive" 2 / Sharepoint site"sharepoint" 3 / Type in driveID"driveid" 4 / Type in SiteID"siteid" 5 / Search a Sharepoint site"search"Your choice> 1# 這里問你要選擇的類型,選1Found 1 drives, please select the one you want to use:0: OneDrive (business) id=b!Eqwertyuiopasdfghjklzxcvbnm-7mnbvcxzlkjhgfdsapoiuytrewqkChose drive to use:> 0# 程序找到網盤,編號是什么數字就填什么數字,一般是0Found drive root of type business, URL: https://org-my.sharepoint.com/personal/you/DocumentsIs that okay?y) Yesn) Noy/n> y--------------------[remote]type = onedrivetoken = {"access_token":"youraccesstoken","token_type":"Bearer","refresh_token":"yourrefreshtoken","expiry":"2021-12-07T09:39:52.486512262+08:00"}drive_id = b!Eqwertyuiopasdfghjklzxcvbnm-7mnbvcxzlkjhgfdsapoiuytrewqkdrive_type = business--------------------y) Yes this is OKe) Edit this remoted) Delete this remotey/e/d> y# 選yCurrent remotes:NameType========remoteonedrivee) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> q# 選q,退出
至此,Rclone 已成功連接到了 OneDrive 網盤。
與 OneDrive 不同的是,Google Drive 不需要本地 Win-dows 客戶端預先進行授權獲取 to-ken,而是在配置過程中進行授權。
輸入以下命令
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh4rclone config
會出現以下信息,參照下面的注釋進行操作。
TIPS: 因為 RCLONE 會時不時進行更新,當你看到這篇教程時菜單選項可能已經發生了略微的改動,但大致思路不會變,不要無腦照搬操作。
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh7No remotes found - make a new onen) New remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confign/r/c/s/q>n# 選擇n,新建name> Google# 輸入名稱,類似于標簽,用于區分不同的網盤。Type of storage to configure.Choose a number from below, or type in your own value[snip]XX / Google Drive"drive"[snip]Storage>XX# 選擇Google Drive對應的數字Google Application Client Id - leave blank normally.client_id># 留空,回車Google Application Client Secret - leave blank normally.client_secret># 留空,回車Scope that rclone should use when requesting access from drive.Choose a number from below, or type in your own value 1 / Full access all files, excluding Application Data Folder."drive" 2 / Read-only access to file metadata and file contents."drive.readonly"/ Access to files created by rclone only. 3 | These are visible in the drive website.| File authorization is revoked when the user deauthorizes the app."drive.file"/ Allows read and write access to the Application Data folder. 4 | This is not visible in the drive website."drive.appfolder"/ Allows read-only access to file metadata but 5 | does not allow any access to read or download file content."drive.metadata.readonly"scope> 1# 選擇1ID of the root folder - leave blank normally.Fill in to access "Computers" folders. (see docs).root_folder_id># 留空,回車Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login.service_account_file># 留空,回車Remote configUse auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine or Y didnt worky) Yesn) Noy/n>n# 選nIf your browser doesnt open automatically go to the following link: http://127.0.0.1:53682/authLog in and authorize rclone for accessWaiting for code...Got codeConfigure this as a Shared Drive (Team Drive)?y) Yesn) Noy/n> y# 選n--------------------[remote]client_id = client_secret = scope = driveroot_folder_id = service_account_file =token = {"access_token":"XXX","token_type":"Bearer","refresh_token":"XXX","expiry":"2014-03-16T13:57:58.955387075Z"}--------------------y) Yes this is OKe) Edit this remoted) Delete this remotey/e/d> yCurrent remotes:NameType========Googledriveremoteonedrivee) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> q
至此,Rclone 已成功連接到了 Google Drive 網盤。
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh8rclone [功能選項] <本地路徑> <網盤名稱:路徑> [參數] [參數] ...
<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh<span class="hljs-attribute">wget</span> -N git.io/aria2.sh && chmod +x aria2.sh9rclone [功能選項] <網盤名稱:路徑> <本地路徑> [參數] [參數] ...
./aria2.sh./aria2.sh0rclone [功能選項] <網盤名稱:路徑> <網盤名稱:路徑> [參數] [參數] ...
示例:
./aria2.sh./aria2.sh1rclone move -v /files ftp:/files --transfers=1
rclone 有 4 個級別的日志記錄,ERROR,NOTICE,INFO 和 DEBUG。默認情況下,rclone 將生成 ERROR 和 NOTICE 級別消息。
使用 --log-file=FILE 選項,rclone 會將 Error,Info 和 Debug 消息以及標準錯誤重定向到 FILE,這里的 FILE 是你指定的日志文件路徑。
另一種方法是使用系統的指向命令,比如:
./aria2.sh./aria2.sh2rclone sync -v Onedrive:/DRIVEX Gdrive:/DRIVEX > "~/DRIVEX.log" 2>&1
比如 --exclude "*.bak"、--filter "- *.bak",排除所有 bak 文件。也可以寫作。
比如 --include "*.{png,jpg}"、--filter "+ *.{png,jpg}",包含所有 png 和 jpg 文件,排除其他文件。
--delete-excluded 刪除排除的文件。需配合過濾參數使用,否則無效。
目錄過濾需要在目錄名稱后面加上 /,否則會被當做文件進行匹配。以 / 開頭只會匹配根目錄(指定目錄下),否則匹配所目錄。這同樣適用于文件。
默認大小單位為 kBytes ,但可以使用 k ,M 或 G 后綴。
rclone 中的每個選項都可以通過環境變量設置。環境變量的名稱可以通過長選項名稱進行轉換,刪除 -- 前綴,更改 - 為 _,大寫并添加前綴 RCLONE_。環境變量的優先級會低于命令行選項,即通過命令行追加相應的選項時會覆蓋環境變量設定的值。
比如設置最小上傳大小 --min-size 50,使用環境變量是 RCLONE_MIN_SIZE=50。當環境變量設置后,在命令行中使用 --min-size 100,那么此時環境變量的值就會被覆蓋。
給Aria2服務器所用的SSL證書往往不支持Aria2所使用的6800端口,而80/443端口還要提供HTTP服務,為此就需要用Nginx來實現同時提供HTTP和Aria2 JSONRPC服務了。
修改Aria2配置文件
./aria2.sh./aria2.sh3#允許所有來源, web界面跨域權限需要rpc-allow-origin-all=false#允許非外部訪問rpc-listen-all=false#RPC端口, 僅當默認端口被占用時修改rpc-listen-port=6800
./aria2.sh./aria2.sh4#ARIA2location /jsonrpc {proxy_pass http://localhost:6800/jsonrpc;proxy_redirect off;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Host $host;#以下代碼使支持WebSocketproxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}
其中 location /jsonrpc 表示設置好后RPC地址為 //example.com/jsonrpc
這樣做還有一個好處,那就是不需要單獨為Aria2 RPC服務器設置密碼驗證了。認證直接靠nginx完成,能見到webui就能連上ARIA2 RPC