利用Aria2+Oneindex等脚本搭建自动上传onedrive离线下载在线播放网盘

这里介绍在VPS上搭建离线网盘等诸多功能的oneindex。因为功能多,所以比较复杂。
准备工作
onedrive账号1枚
VPS一台
信心和耐力。。
搭建oneindex
首先将域名解析到自己的vps上,连接vps后根据你的系统选择下面命令安装。

#Centos系统
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh
#Ubuntu系统
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh
#Debian系统
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && bash install.sh
安好后会提示你的IP:8888地址还有账号密码,在浏览器中输入地址还有账号密码登录。
登陆后会提示安装套件

 

这里选择nginx和php5.6就行,点一键安装,等安装结束后,选择左侧网站–>添加站点,填写你的域名后选择php版本,其他的不需要勾选。

 

下载oneindex
确定后选择左侧的文件–>上传,上传刚才下载的文件,上传成功后,选择该zip文件–>解压。

 

进入oneindex-master文件夹,将cache、config两个文件夹的权限设置为777。

 

回到网站–>设置。

 

选择网站目录,选择刚才域名下oneindex-master文件夹,保存。

 

选择伪静态,贴入以下代码,保存。

location / {
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = “21”){
rewrite ^/(.*)$ /index.php?/$1 last;
}
}

 

之后浏览器输入域名看到以下界面就表示后台设置可以了,之后一直下一步然后登陆onedrive账号,授权就可以了。

 

aria2、ariaNG安装
aria2安装
使用逗比的脚本安装就很简单了

wget -N –no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/aria2.sh && chmod +x aria2.sh && bash aria2.sh
#备用地址
wget -N –no-check-certificate https://www.moerats.com/usr/shell/Aria2/aria2.sh && chmod +x aria2.sh && bash aria2.sh

 

运行之后会出现登录地址、密码等,记下来一会用。如果需要修改默认配置使用bash aria2.sh按选项走就可以。

AriaNg安装
这里需要在BT面板中网站——>新建网站,添加另一个域名,或者填写该主机ip或ip+端口号也可以,自行选择。之后后台cd到新网站目录里

wget https://www.moerats.com/usr/down/aria-ng-0.2.0.zip && unzip aria-ng-0.2.0.zip
之后就能在浏览器中通过设置的域名或IP访问了。在AriaNg设置RPC这里输入刚才aria2的密码,刷新一下,Aria2状态显示已连接就表示安装好了。

 

之后下载东西直接浏览器里输入IP,和迅雷等工具一样就能下载到VPS上了。

Aria自动上传
这里需要用到OneDrive for Business on Bash项目
Github地址:https://github.com/0oVicero0/OneDrive

wget –no-check-certificate -qO- “https://raw.githubusercontent.com/0oVicero0/OneDrive/master/OneDrive.sh” |bash
脚本中已内置参数,我自己按大佬的教程申请自己的Api参数几次都设置不成功。还是用大佬的吧。
之后onedrive -a进行账号认证。

 

将划横线的网站在浏览器中打开,授权之后浏览器跳转,获得一个常常的网址,如下:

 

将code=与&session之间的字符串复制一下,再到后台粘贴,回车。

 

显示It seems like we have a refresh token,这句表示成功。
之后运行命令onedrive -l测试一下。

 

能看到onedrive目录里的文件就表示成功了。
之后在某一目录先新建一个文件vi /root/rcloneupload.sh贴入以下内容

#!/bin/bash
num=”$2″
path=”$3″
downloadpath=’/home’ #下载目录

if [ $num -eq 0 ]
then
exit 0
fi

function getdir(){
IFS=$’n’;for file in `ls “$1″`
do
if [ -d “$1/$file” ]
then
getdir “$1/$file”
else
if [ “${1%/*}” = “$downloadpath” ] && [ $num -eq 1 ]
then
onedrive “$1”
elif [ $num -eq 1 ]
then
onedrive “$1/$file”
else
onedrive -u “$downloadpath” “$1/$file”
fi
fi
done
}

while true; do
filepath=$path
path=${path%/*};
if [ “$path” = “$downloadpath” ]
then
getdir “$filepath”
if [ -d $filepath ]
then
rm -r “$filepath”
else
rm “$filepath”
fi
echo 3 > /proc/sys/vm/drop_caches
swapoff -a && swapon -a
exit 0
fi
done
注意downloadpath=’/home’;这里的目录要和Aria的下载目录一致。然后chmod +x rcloneupload.sh授予权限,修改Aria配置文件vi /root/.aria2/aria2.conf,将on-download-complete=/root/rcloneupload.sh贴在里面。重启一下Aria就可以了。
之后测试一下,使用Aria下载一个文件,下载完成后看是否上传到了onedrive里即可。

About the Author

发表评论

邮箱地址不会被公开。 必填项已用*标注

You may also like these