VPS挂载阿里云盘-Aria2下载后自动转存阿里云盘

网上找了好多教程,目前总算实现了,现在把过程记录下,也方便想要这么操作的人。

目录

1、安装宝塔面板
2、挂载阿里云盘
3、安装Aria2
4、配置脚本
5、本地电脑安装浏览器插件进行管理

1、安装宝塔面板

宝塔面板的好处是可视化操作,不需要记住复杂的命令,一切都是鼠标点点,非常方便,我是Debian10,安装命令如下:

wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh

Ubuntu的安装命令如下:

wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh

安装完成后根据提示登录面板控制台,修改用户名密码。

2、挂载阿里云盘

首先将阿里云盘变身为webdav协议的文件服务器,我使用的是go-aliyundrive-webdav项目,下载release包到指定位置解压,如/www/wwwroot/,执行命令:

/www/wwwroot/./webdav -rt="你的refreshToken" -user="你的用户名" -pwd="你的密码" ##注意这里的用户名密码不是阿里云盘的,可以自由设置
此时阿里云盘就变身为webdav协议的文件服务器,可以通过Rclone进行挂载了,安装Rclone:

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

配置Rclone:

rclone config

[root@localhost yum.repos.d]# rclone config
2021/08/12 16:28:35 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
name> aliyunwebdav
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 Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, SeaweedFS, and Tencent COS
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Citrix Sharefile
\ "sharefile"
9 / Compress a remote
\ "compress"
10 / Dropbox
\ "dropbox"
11 / Encrypt/Decrypt a remote
\ "crypt"
12 / Enterprise File Fabric
\ "filefabric"
13 / FTP Connection
\ "ftp"
14 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
15 / Google Drive
\ "drive"
16 / Google Photos
\ "google photos"
17 / Hadoop distributed file system
\ "hdfs"
18 / Hubic
\ "hubic"
19 / In memory object storage system.
\ "memory"
20 / Jottacloud
\ "jottacloud"
21 / Koofr
\ "koofr"
22 / Local Disk
\ "local"
23 / Mail.ru Cloud
\ "mailru"
24 / Mega
\ "mega"
25 / Microsoft Azure Blob Storage
\ "azureblob"
26 / Microsoft OneDrive
\ "onedrive"
27 / OpenDrive
\ "opendrive"
28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
29 / Pcloud
\ "pcloud"
30 / Put.io
\ "putio"
31 / QingCloud Object Storage
\ "qingstor"
32 / SSH/SFTP Connection
\ "sftp"
33 / Sugarsync
\ "sugarsync"
34 / Tardigrade Decentralized Cloud Storage
\ "tardigrade"
35 / Transparently chunk/split large files
\ "chunker"
36 / Union merges the contents of several upstream fs
\ "union"
37 / Uptobox
\ "uptobox"
38 / Webdav
\ "webdav"
39 / Yandex Disk
\ "yandex"
40 / Zoho
\ "zoho"
41 / http Connection
\ "http"
42 / premiumize.me
\ "premiumizeme"
43 / seafile
\ "seafile"
Storage> 38
URL of http host to connect to
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Connect to example.com
\ "https://example.com"
url> http://127.0.0.1:8080
Name of the Webdav site/service/software you are using
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Nextcloud
\ "nextcloud"
2 / Owncloud
\ "owncloud"
3 / Sharepoint Online, authenticated by Microsoft account.
\ "sharepoint"
4 / Sharepoint with NTLM authentication. Usually self-hosted or on-premises.
\ "sharepoint-ntlm"
5 / Other site/service or software
\ "other"
vendor> 5
User name. In case NTLM authentication is used, the username should be in the format 'Domain\User'.
Enter a string value. Press Enter for the default ("").
user> admin
Password.
y) Yes type in my own password
g) Generate random password
n) No leave this optional password blank (default)
y/g/n> y
Enter the password:
password:
Confirm the password:
password:
Bearer token instead of user/pass (e.g. a Macaroon)
Enter a string value. Press Enter for the default ("").
bearer_token>
Edit advanced config?
y) Yes
n) No (default)
y/n>
--------------------
[aliyunwebdav]
type = webdav
url = http://127.0.0.1:8080
vendor = other
user = admin
pass = *** ENCRYPTED ***
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>

Current remotes:

选择顺序为Webdav——其他——设置用户名密码——最后两个默认回车,完成设置后会有提示。

把阿里云盘挂载到本地

#新建本地文件夹,位置可以自己选
mkdir /data/aliyunwebdav
#挂载
rclone mount DriveName:Folder LocalFolder --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty
DriverName是你在配置rclone的时候设置的名字,Folder没有需要求的话填/即可,LocalFolder是你本地挂载的地址,/tmp比较特殊,上传时缓存目录,其他类型挂载一般时不需要这个参数的,默认/tmp地址即可,除非你的系统特殊

设置开机自启

#将后面修改成你上面手动运行命令中,除了rclone的全部参数
command="mount DriveName:Folder LocalFolder --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty"
#以下是一整条命令,一起复制到SSH客户端运行
cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
After=network-online.target

[Service]
Type=simple
ExecStart=$(command -v rclone) ${command}
Restart=on-abort
User=root

[Install]
WantedBy=default.target
EOF

开始启动:

systemctl start rclone

设置开机自启:

systemctl enable rclone

相同的方法,可以设置Webdav开机自启动

这样你的阿里云盘就挂载成功了,可以在宝塔面板里面查看挂载的文件夹是否可以加载出来

3、安装Aria2

我使用的是aria2.sh这个项目的一键脚本,好处是可以完成后自动删除缓存和垃圾,自动上传阿里云盘,避免了本地磁盘被占满的尴尬,可以放心下载。

为了确保能正常使用,请先安装基础组件wget、curl、ca-certificates,以 Debian 为例子:

apt install wget curl ca-certificates
下载脚本

wget -N git.io/aria2.sh && chmod +x aria2.sh
运行脚本

./aria2.sh
选择你要执行的选项

Aria2 一键安装管理脚本 增强版 [v2.7.4] by P3TERX.COM

0. 升级脚本
———————————————————————
1. 安装 Aria2
2. 更新 Aria2
3. 卸载 Aria2
———————————————————————
4. 启动 Aria2
5. 停止 Aria2
6. 重启 Aria2
———————————————————————
7. 修改 配置
8. 查看 配置
9. 查看 日志
10. 清空 日志
———————————————————————
11. 手动更新 BT-Tracker
12. 自动更新 BT-Tracker
———————————————————————

Aria2 状态: 已安装 | 已启动

自动更新 BT-Tracker: 已开启

请输入数字 [0-12]:
安装很简单

4、配置脚本

虽然Aria2安装完成,但是想要实现下载完成后自动上传到网盘,还要做相应设置,宝塔面板里面打开/root/.aria2c/aria2.conf,修改成如下命令

# 下载完成后执行的命令
on-download-complete=/root/.aria2c/upload.sh
/root/.aria2c/script.conf打开附加功能脚本配置文件进行修改,有中文注释,按照自己的实际情况进行修改,第一次使用只建议修改网盘名称。盘目录。

# 网盘名称(RCLONE 配置时填写的 name)
drive-name=aliyunpan
本人实测,上传不一定成功,建议在 /root/.aria2c/aria2.conf 里面增加一条命令

on-download-complete=/root/.aria2c/move.sh
重启 Aria2 。脚本选项重启或者执行以下命令:

service aria2 restart
检查配置是否成功

/root/.aria2c/upload.sh
执行upload.sh脚本,提示success即代上传脚本能正常被调用,否则请检查与 RCLONE 有关的配置。

5、安装浏览器Aria2 GUI插件

以chrome为例,安装aria2-for-chrome,之后便可以在浏览器内打开GUI,进行RPC配置后便能够连上VPS了。

现在你可以欢快的下载了

注意事项
在宝塔面板里面将所有用到的端口进行放行

技术分享

Aria2 下载自动上传阿里云盘

2022-1-5 20:04:34

技术分享

阿里云盘+Emby+KODI打造炫酷的网盘媒体影音中心

2022-1-26 0:29:53

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索

Warning: error_log(/www/wwwroot/www.yuns.top/wp-content/plugins/spider-analyser/#log/log-2904.txt): failed to open stream: Permission denied in /www/wwwroot/www.yuns.top/wp-content/plugins/spider-analyser/spider.class.php on line 2900