宝塔+aria2+rclone+onedrive+webui-aria2实现网盘离线下载

转自http://pcdone.com

一、安装宝塔

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

自动安装完成后会生成一个http://IP地址:8888 的链接,打开这个链接,输入用户名和密码登陆。然后进入软件商店安装 Nginx 、PHP、pure-ftpd环境。

点左边的“网站”,添加站点,输入域名(域名解析指向VPS的IP地址),创建ftp,确定。

进入网站的根目录,创建一个文件夹,比如叫做downlod,这个文件夹就是我们存储下载和上传文件的文件夹,记录下这个文件夹的路径,一般是“/www/wwwroot/你的域名/download”

二、安装aria2

SSH进入VPS,输入一键脚本命令:

wget -N https://git.io/aria2.sh && chmod +x aria2.sh && bash aria2.sh

选择1,安装,期间会询问最新版本,直接回车。安装好以后会生成IP地址和密码,记下密码,会发现要用到端口6800,这时要进入宝塔页面,选择左边的安全,放行6800端口。

注:aria2其他操作
启动:/etc/init.d/aria2 start
停止:/etc/init.d/aria2 stop
重启:/etc/init.d/aria2 restart
查看状态:/etc/init.d/aria2 status
配置文件:/root/.aria2/aria2.conf

下面修改配置:

用宝塔的文件管理功能,进入:root/.aria2,找到aria2.conf文件,编辑

找到dir=,后面改成 /www/wwwroot/你的域名/download (就是网站根目录下创建的下载目录路径)

拉到最后,把下面语句前面加上#

on-download-complete=/root/.aria2/delete.aria2.sh

再把下面的语句前的#删掉

#on-download-complete=/root/.aria2/autoupload.sh

保存关闭。再找到autoupload.sh文件,编辑

第一行的downloadpath=引号里面还是改成前面记录的下载路径 /www/wwwroot/你的域名/download

第二行改成name=’onedrive’

第三行“folder=”后面是你网盘里创建的目录名,上传后的文件就保存到该目录。

保存关闭。

SSH进入VPS,重启aria2。

三、安装rclone

1、获取onedrive授权码

打开网址:https://rclone.org/downloads/点击下图红框的下载点

下载下来以后是一个压缩包,解压到电脑里。运行–CMD进入命令行模式,CD进入到rclone的根目录,运行以下命令:

rclone authorize "onedrive"

会自动打开浏览器,登陆office页面,登陆成功以后,命令行会获取到如下界面:

复制从“{”到“}”的全部内容,这就是onedrive授权码token,后面要用。

2、VPS安装rclone

使用一键脚本:

curl https://rclone.org/install.sh | sudo bash

安装完以后运行:

rclone config

按照如下注释进行配置

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> n  # 选择n,新建
name> Onedrive   # 输入名称,建议用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 / A stackable unification remote, which can appear to merge the contents of several remotes
   \ "union"
2 / Alias for a existing remote
   \ "alias"
3 / Amazon Drive
   \ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
   \ "s3"
5 / Backblaze B2
   \ "b2"
6 / Box
   \ "box"
7 / Cache a remote
   \ "cache"
8 / Dropbox
   \ "dropbox"
9 / Encrypt/Decrypt a remote
   \ "crypt"
10 / FTP Connection
   \ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
12 / Google Drive
   \ "drive"
13 / Hubic
   \ "hubic"
14 / JottaCloud
   \ "jottacloud"
15 / Local Disk
   \ "local"
16 / Mega
   \ "mega"
17 / Microsoft Azure Blob Storage
   \ "azureblob"
18 / Microsoft OneDrive
   \ "onedrive"
19 / OpenDrive
   \ "opendrive"
20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
21 / Pcloud
   \ "pcloud"
22 / QingCloud Object Storage
   \ "qingstor"
23 / SSH/SFTP Connection
   \ "sftp"
24 / Webdav
   \ "webdav"
25 / Yandex Disk
   \ "yandex"
26 / http Connection
   \ "http"
Storage> 18  # 选择18,Microsoft OneDrive,数值可能会变,反正选择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
y/n> 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
n) No
y/n> n  # 选n
For 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"}  # 上面保存的token复制到这里
2018/10/31 19:54:06 ERROR : Failed to save new token in config file: section 'P3TERX' not found
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) 
Chose drive to use:> 0  # 程序找到网盘,这里编号是0,就选择0
Found drive 'root' of type 'business', URL: https://xxxxxx-my.sharepoint.com/personal/xxxxxxx/Documents
Is that okay?
y) Yes
n) No
y/n> y  # 选y
--------------------
[P3TERX]
type = onedrive
token = {"XXXXXXXX"}
drive_id = XXXXXXXXX
drive_type = business
--------------------
y) Yes this is OK
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连接。

四、安装webui-aria2

就是为aria2添加一个管理界面

打开网址:https://github.com/ziahamza/webui-aria2

下载源码,上传到宝塔搭建的网站根目录。

打开:http://你的域名/docs,进入后台管理页面

点击上面的设置–连接设置,主机填写IP地址,端口6800, 密码令牌填写安装aria2时生成的密码,保存。

到这里全部都弄刚好了,可以愉快地下载了。

THE END
分享
二维码
< <上一篇
下一篇>>