挂载googleDrive,配合aria2,文件操作可道云

rclone+kodexplorer+aria2+ariaNG+aria2_perfect_config整合

来自:Pixiv 画师(とりくら )

开始准备

说明:最近服务器磁盘不太够用(20GB),考虑到服务器硬盘升级的成本,在原本几个小伙伴共用kodexplorer网盘的基础上,考虑着手软扩容–rclone。发现rconle与aria2,kodexplorer之间不太磨合,就这些问题做个笔记。

无限空间的google Drive(谷歌云盘),可以去某宝买

服务器是必需的

安装顺序aria2>ariaNG>kodexplorer> Rclone> aria2_perfect_config

aria部分:前后端分离安装(静态页面直接使用宝塔)

先安装后端aria2:

安装命令:

wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/aria2.sh && chmod +x aria2.sh && bash aria2.sh

细节如下

信息] 开始下载/安装 主程序...
[信息] 请输入 Aria2 版本号,格式如:[ 1.34.0 ],获取地址:[ https://github.com/q3aql/aria2-static-builds/releases ]
默认回车自动获取最新版本号:                #此处直接回车
#生成一个简易的配置↓

修改aria下载位置:

sh aria.sh
Aria2 一键安装管理脚本 [v1.1.10]
  -- Toyo | doub.io/shell-jc4 --
  
  0. 升级脚本
————————————
  1. 安装 Aria2
  2. 更新 Aria2
  3. 卸载 Aria2
————————————
  4. 启动 Aria2
  5. 停止 Aria2
  6. 重启 Aria2
————————————
  7. 修改 配置文件
  8. 查看 配置信息
  9. 查看 日志信息
 10. 配置 自动更新 BT-Tracker服务器
————————————

 当前状态: 已安装 并 已启动

 请输入数字 [0-10]:7                     #选择7
 1.  修改 Aria2 RPC密码
 2.  修改 Aria2 RPC端口
 3.  修改 Aria2 文件下载位置
 4.  修改 Aria2 密码+端口+文件下载位置
 5.  手动 打开配置文件修改
(默认: 取消):

此处密码和端口可以不改,下载位置改成容易找到的位置,如

mkdir /root/Download               #创建下载目录
请输入要设置的 Aria2 文件下载位置(旧位置为:/usr/local/caddy/www/aria2/Download)
(默认位置: /usr/local/caddy/www/aria2/Download):/root/Download/            #输入创建的位置

修改配置文件:

vim /root/.aria2/aria2.conf

主要修改最大连接数(最高16个)和线程数,其它的看着改

# 同一服务器连接数, 添加时可指定, 默认:1
max-connection-per-server=16
# 单个任务最大线程数, 添加时可指定, 默认:5,路由建议值: 5
split=50

安装前端AriaNG:

运行环境:安装 Nginx 和 PHP,没有的话可以用宝塔安装一下

创建网页站点:

没有域名的请修改网站域名

 

删除无效的域名

远程下载ariaNG的静态文件

URL地址为:https://github.com/mayswind/AriaNg/releases/download/1.1.3/AriaNg-1.1.3.zip

解压下载的文件,然后浏览器访问网站,即ip/域名:端口

进入这样的页面

认证身份:

完成记得点击重新加载页面

验证:状态变为已连接并下载文件测试

>>至此aria2前后端安装完成

kodexplorer

kodexplorer安装:使用宝塔面板的一键部署源码即可

运行环境: PHP(52-56,70-72),没有的话可以用宝塔安装一个,这里使用的是72版本

简略步骤:进入宝塔web面板—软件管理—宝塔插件—一键部署源码—搜索kod

没有域名的创建成功后,先不要急着访问。设置域名:

添加【ip:端口】并删除无效域名

验证是否安装完成:

访问:【 域名/ip:端口 】,如图

设置你的管理员密码
登陆后提示更新,更就是了

>>至此kodexplorer安装完成

Rclone

rclone的依赖和环境安装:

#Debian/Ubuntu系统
apt-get install fuse -y
#CentOS系统
yum install fuse -y

rclone安装:

#Debian/Ubuntu系统
curl https://rclone.org/install.sh | sudo bash
#CentOS系统
curl https://rclone.org/install.sh | sudo bash

rclone配置:

rclone config

详细如下:

Current remotes:
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> gdrive                    #输入一个名字,方便区分(不可为空)
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 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 / 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 / Koofr
   \ "koofr"
16 / Local Disk
   \ "local"
17 / Mega
   \ "mega"
18 / Microsoft Azure Blob Storage
   \ "azureblob"
19 / Microsoft OneDrive
   \ "onedrive"
20 / OpenDrive
   \ "opendrive"
21 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
22 / Pcloud
   \ "pcloud"
23 / QingCloud Object Storage
   \ "qingstor"
24 / SSH/SFTP Connection
   \ "sftp"
25 / Webdav
   \ "webdav"
26 / Yandex Disk
   \ "yandex"
27 / http Connection
   \ "http"
Storage> 12                #选择云盘的类型,这里选用Google Drive
Google Application Client Id - leave blank normally.
client_id>                 #留空,填写google api账号id
Google Application Client Secret - leave blank normally.
client_secret>             #留空,填写googl api账号密钥

这里说一下,这个api并不怎么好用,也有人提出它可以解决使用高峰期CPU高占用和出错的问题。这里我们不配置,可以之后再配置。继续:

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                #权限赋予,这里给完全权限。mark名:drive
ID of the root folder
Leave blank normally.
Fill in to access "Computers" folders. (see docs).
Enter a string value. Press Enter for the default ("").
root_folder_id>         #留空,后面再配,主要是怕路径敲错
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file>   #留空,不是交互式的登录方式需配置。
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n                  #选择n,不需要自己配置
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> y                  #选择y,弹出网页登陆授权
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=***********.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=93b4e5cd8a54e060c8b73df9b6883106
Log in and authorize rclone for access
Enter verification code>                    #复制上面http后面一大串,粘贴到浏览器,登陆拿到一 
                                             串授权码,粘贴回来填上
Configure this as a team drive?
y) Yes
n) No
y/n> n                 #选择n,如果你是g suite可以选择y(前提是确定suite成员是安全的)
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y               #选择y,完成配置

挂载:

指定软连接的文件夹,创建一个目录

划重点:因为要与kodexplorer对接,需将文件夹创建在kodexplorer站点目录下

mkdir /www/wwwroot/kod/data/Group/public/home/gdrive

【如果将来这个无限空间的目录是公共使用的,设置为站点下/data/Group/public/目录名称】

挂载命令

rclone mount 【配置时填写的name】:【对应你的谷歌云盘下的一个目录】【创建的本地目录】 --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
我的一个云盘目录

则我的挂载命令

rclone mount gdrive:rclone /www/wwwroot/kod/data/Group/public/home/gdrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

检查是否挂载成功

df -h
看到如图这个1.0p分区即挂载成功

卸载挂载:

fusermount -qzu /www/wwwroot/kod/data/Group/public/home/gdrive

自启:

下载配置文件:

wget https://www.moerats.com/usr/shell/rcloned && nano rcloned

修改配置文件内容:

NAME=""  #rclone name名,初次配置时输入的Name
REMOTE=''  #远程文件夹,Google Drive网盘里的挂载的一个文件夹
LOCAL=''  #挂载地址,VPS本地挂载目录

移动到配置文件目录并给权限,启动服务

mv rcloned /etc/init.d/rcloned
chmod +x /etc/init.d/rcloned
bash /etc/init.d/rcloned start

开机自启服务:

vim /etc/rc.d/rc.local 
#加入一句
 bash /etc/init.d/rcloned start

其他命令:

bash /etc/init.d/rcloned start               #开启服务
bash /etc/init.d/rcloned stop               #关闭服务
bash /etc/init.d/rcloned restart            #重启服务

>>至此rclone安装完成

aria2的配置优化:aria2_perfect_config

github项目地址: https://github.com/P3TERX/aria2_perfect_config

下载命令:

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

详细如下

Aria2 一键安装管理脚本 [v2.0.5]
  -- 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
————————————

 当前状态: 已安装 并 已启动

 请输入数字 [0-12]:7                     #选择7
你要做什么?
 1.  修改 Aria2 RPC密码
 2.  修改 Aria2 RPC端口
 3.  修改 Aria2 文件下载位置
 4.  修改 Aria2 密码+端口+文件下载位置
 5.  手动 打开配置文件修改
 ————————————
 0.  重置/更新 Aria2 完美配置

(默认: 取消):0                           #选择0

修改自动上传脚本:

vim /root/.aria2/autoupload.sh 

#修改下面几项↓
downloadpath='/root/Download' #Aria2下载目录
name='gdrive' #配置Rclone时填写的name
folder='/rclone' #网盘里的文件夹,留空为整个网盘。

不要忘记保存

修改优化后的aria2配置文件:

vim /root/.aria2//aria2.conf 


## 执行额外命令 ##
# 调用 rclone 上传(move)到网盘
on-download-complete=/root/.aria2/autoupload.sh       #下掉最左端的#,开启自动上传功能

下载一个文件,完成后文件将自动从/root/Download移动到kodexplorer的挂载目录,即网盘下。一段时间后,可以在kodexplorer中查看。

如果下载的是视频什么的,是可以直接在kodexplorer里播放哦

>>至此整合完成!

发表回复