Aria2
Aria2是一个轻量级的多协议和多源命令行下载实用程序。它支持HTTP / HTTPS,FTP,SFTP, BitTorrent和Metalink。Aria2可以通过内置的 JSON-RPC和XML-RPC接口进行操作。
Aria2安装
使用如下代码下载并运行Aria2一键安装管理脚本,集成Aria2完美配置方案。
wget -N git.io/aria2.sh && chmod +x aria2.sh && ./aria2.sh
出现脚本操作菜单输入 1 开始安装。
Rclone
Rclone 是一个的命令行工具,支持在不同对象存储、网盘间同步、上传、下载数据。并且通过一些设置可以实现离线下载、服务器备份等非常实用的功能。这里以 OneDrive 为例子,进行连接配置,其它网盘的操作类似。由于是交互式配置选项,只要能看懂基本没有任何难度。
Rclone 安装
使用官方一键脚本(可能极慢,14MB文件,几KB/s,这谁顶得住)
curl https://rclone.org/install.sh | sudo bash
Rclone 连接 Onedrive
获取Token
在自己Windows电脑上下载Rclone,Rclone官网:https://rclone.org/downloads/
解压到有环境变量的目录,例如C:\Windows\system32\也可自行配置环境变量,不会添加环境变量的百度……然后Win+R打开资源管理器输入cmd回车打开控制台,接着输入以下命令。
rclone authorize "onedrive"
接下来会弹出浏览器,要求你登录你的Onedrive账号进行授权。授权完后命令提示符窗口会出现以下信息:
注意:复制{"access_token":"xxxxxxxx"}整段内容,保存好,后面要用。
配置Rclone
服务器输入rclone config命令,会出现以下信息,参照下面的###注释进行操作,自行斟酌修改。
2020/07/13 15:20:30 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n ###选择n 新建
name> onedrive #### 输入名称,类似于标签,用于区分不同的网盘,随意就好。
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
1 / 1Fichier
"fichier"
2 / Alias for an existing remote
"alias"
3 / Amazon Drive
"amazon cloud drive"
4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
"s3"
5 / Backblaze B2
"b2"
6 / Box
"box"
7 / Cache a remote
"cache"
8 / Citrix Sharefile
"sharefile"
9 / Dropbox
"dropbox"
10 / Encrypt/Decrypt a remote
"crypt"
11 / FTP Connection
"ftp"
12 / Google Cloud Storage (this is not Google Drive)
"google cloud storage"
13 / Google Drive
"drive"
14 / Google Photos
"google photos"
15 / Hubic
"hubic"
16 / In memory object storage system.
"memory"
17 / Jottacloud
"jottacloud"
18 / Koofr
"koofr"
19 / Local Disk
"local"
20 / Mail.ru Cloud
"mailru"
21 / Mega
"mega"
22 / Microsoft Azure Blob Storage
"azureblob"
23 / Microsoft OneDrive
"onedrive"
24 / OpenDrive
"opendrive"
25 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
"swift"
26 / Pcloud
"pcloud"
27 / Put.io
"putio"
28 / QingCloud Object Storage
"qingstor"
29 / SSH/SFTP Connection
"sftp"
30 / Sugarsync
"sugarsync"
31 / Tardigrade Decentralized Cloud Storage
"tardigrade"
32 / Transparently chunk/split large files
"chunker"
33 / Union merges the contents of several upstream fs
"union"
34 / Webdav
"webdav"
35 / Yandex Disk
"yandex"
36 / http Connection
"http"
37 / premiumize.me
"premiumizeme"
38 / seafile
"seafile"
Storage> 23 ####选择23 Microsoft OneDrive
See help for onedrive backend at: https://rclone.org/onedrive/
Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id> #### 留空,回车
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> #### 留空,回车
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n #### 留空,回车
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> n ####注意这里选择进行手动输入n配置
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
rclone authorize "onedrive"
Then paste the result below:
result> {"access_token":"xxxxxxxx"} ###粘贴之前保存的Token信息
Choose a number from below, or type in an existing value
1 / OneDrive Personal or Business
"onedrive"
2 / Root Sharepoint site
"sharepoint"
3 / Type in driveID
"driveid"
4 / Type in SiteID
"siteid"
5 / Search a Sharepoint site
"search"
Your choice> 1 ###选1,个人版或者商业版
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!gZgSN2Wux0C9L823fflVNq1Bp3h8h3tHvUCXmXNGYYSe7cGCw_HmRI773l1N4l-u
Chose drive to use:> 0 ###选0,这里是Rclone找到的网盘信息
Found drive 'root' of type 'business', URL: https://alpinerescueteam-my.sharepoint.com/personal/vircul_mail_anandaigueschools_org/Documents
Is that okay?
y) Yes (default)
n) No
y/n> y ###选y
--------------------
[Velin Cloud]
type = onedrive
token =
drive_id =
drive_type =
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y ###默认y
Current remotes:
Name Type
==== ====
onedrive onedrive ###出现这一步就配置完成
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q ###q 退出至此,Rclone已成功连接至OneDrive云盘
配置自动上传脚本
Aria2 一键安装管理脚本整合了Aria2 完美配置 ,安装后会附带一些附加功能脚本功能脚本,Rclone 自动上传脚本就是其中之一。由于默认不启用,所以需要手动启用。
打开/root/.aria2c/script.conf配置文件进行修改,有中文注释,按照自己的实际情况进行修改,一般只需要修改下面2个部分。
# 网盘名称(RCLONE 配置时填写的 name,注意区分大小写) drive-name=onedrive # 网盘目录。注释或留空时为网盘根目录,末尾不要有斜杠。 drive-dir=/DRIVEX/Download
打开/root/.aria2c/aria2.conf配置文件进行修改。或使用Aria2 一键安装管理脚本中的手动修改选项打开配置文件进行修改。找到“下载完成后执行的命令”,把clean.sh替换为upload.sh。
on-download-complete=/root/.aria2c/upload.sh
重启Aria2
systemctl restart aria2
当你进行按此教程无误进行到这里,就可以实现下载文件就会自动上传至相应的网盘,本地的文件也会自动删除。
配合Aria2Ng使用
由于Aria2是命令行后端工具,配合前端GUI可视化界面能带来更佳的体验,这里推荐下载Aria2Ng面板配合Aria2使用,下载压缩包到网站根目录解压浏览器访问得到如下界面。
Aria2Ng面板:https://github.com/mayswind/AriaNg/releases
RPC密钥可以执行脚本./aria2.sh找到查看配置对应的数字输入回车,复制RPC密钥后面的字符串粘贴在面板处重新载入,如果没有修改RPC端口的话,默认6800无需修改,Aria2状态显示已连接就可以使用了。
另外,建议可以配合Zdir目录程序使用,这是一个在线文件管理器。

![bt.jpg bt.jpg [下载]Aria2 + Rclone 实现离线下载,可配置自动上传至OneDrive 行走江湖](https://pic.sqyai.com/zb_users/plugin/LazyLoad/usr/loading.gif)
![[源码]用宝塔面板部署Cloudreve网盘,接入OneDrive for Business](https://pic.sqyai.com/upload/1591776429/03e96a2e70d2bd5d3a6a3532b3a842ea.png)


发表评论