惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
爱范儿
爱范儿
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
美团技术团队
Y
Y Combinator Blog
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
Martin Fowler
Martin Fowler
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
M
MIT News - Artificial intelligence
博客园 - Franky
V
Visual Studio Blog
I
InfoQ
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
博客园 - 司徒正美
L
LangChain Blog

Rat's Blog - Aria2Ng

AriaNg使用Https/WebSocket(安全)协议连接Aria2的方法 - Rat's Blog 使用Docker安装Aria2+AriaNg+Filebrowser,可离线BT下载/在线播放 - Rat's Blog Aria2+Aria2Ng+OneIndex一键安装脚本,下载后自动上传至OneDrive - Rat's Blog
使用Aria2+Aria2Ng+OneIndex+OneDrive建立不限流量/离线BT下...
博主: Rat's · 2018-08-16 · via Rat's Blog - Aria2Ng

说明:这个教程之前发过一个脚本:Aria2+Aria2Ng+OneIndex一键安装脚本,下载后自动上传至OneDrive,不过由于系统支持较少,加上很多人想手动安装,这里就单独拿来水一篇文章。

获取OneDrive

现在OneIndex是可以使用个人的OneDrive网盘,不过容量太小,很难满足一些人的需求,这里提一下之前说过的2个申请OneDrive 5T的方法。

1、申请微软的Office 365开发者计划,地址:免费获得一年的21TB OneDrive和Microsoft Office 365企业
2、使用热心大佬提供的临时邮箱申请一个,方法如下:

1)、进入注册地址https://products.office.com/en-us/student?tab=students
2)、输入如有乐享提供的临时邮箱,地址:https://51.ruyo.net/8263.html
3)、填入密码,和从临时邮箱获取的验证码

安装

1、安装宝塔

#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

安装完成后,进入面板安装PHP 5.6+Nginx

2、安装OneIndex
先添加域名,然后上传程序文件到网站根目录/www/wwwroot/xx.com,将文件解压出来,并设置config/cache/可读写权限,程序下载:OneIndex.zip

也可以使用命令上传到根目录:

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

#修改为自己域名根目录后再运行
cd /www/wwwroot/xx.com
git clone https://github.com/iiiiiii1/Oneindex.git
mv oneindex/* ./
chmod -R 777 config/ cache/

再点击域名设置,添加Nginx伪静态:

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了,后台地址:https://xx.com/?/admin,默认密码:oneindex。如果你想给域名加上https安全访问,可以通过域名设置配置一下SSL证书。

3、安装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,再选择修改配置即可,这里建议使用该脚本配置自动更新BT-Tracker服务器,对下载BT有加成。

4、安装AriaNg
这一步和安装OneIndex差不多,先添加一个域名,不想用域名的可以在添加域名那里填上IP或者IP:端口,然后将AriaNg程序上传到对应的根目录,可以使用命令:

#这里以添加IP为例
#Debian/Ubuntu系统
apt-get install unzip -y
#CentOS系统
yum install unzip -y

cd /www/wwwroot/11.22.33.44
wget https://www.moerats.com/usr/down/aria-ng-0.2.0.zip && unzip aria-ng-0.2.0.zip

这时候我们就可以使用IP访问AriaNg界面了,或者IP:端口,这取决于你添加域名的时候填的什么了。

配置Aria2上传

这里说下3种自动上传的方法,第1种使用OneIndex程序自带的上传,第2种使用Rclone挂载后自动上传,第3种使用上传脚本,由于前2种上传有BUG,建议使用第3种脚本上传,对于不想折腾的人来说,也可以直接使用第1种方法。

1、OneIndex上传
先在/root/.aria2文件夹新建一个上传脚本,命名oneindexup.sh

#这里也可以使用vi命令,自己看着办
nano /root/.aria2/oneindexup.sh

将以下代码修改后,复制进脚本:

#!/bin/bash
path=$3 #取原始路径,我的环境下如果是单文件则为/data/demo.png,如果是文件夹则该值为文件夹内某个文件比如/data/a/b/c/d.jpg
downloadpath='/usr/local/caddy/www/aria2/Download'  #修改成Aria2下载文件夹
domain='moerats.com'  #修改成自己域名

if [ $2 -eq 0 ]
        then
                exit 0
fi
while true; do  #提取下载文件根路径,如把/data/a/b/c/d.jpg变成/data/a
filepath=$path
path=${path%/*}; 
if [ "$path" = "$downloadpath" ] && [ $2 -eq 1 ]  #如果下载的是单个文件
    then
    php /www/wwwroot/$domain/one.php upload:file $filepath /$folder/
    rm -rf $filepath
    php /www/wwwroot/$domain/one.php cache:refresh
    exit 0
elif [ "$path" = "$downloadpath" ]
    then
    php /www/wwwroot/$domain/one.php upload:folder $filepath /$folder/
    rm -rf "$filepath/"
    php /www/wwwroot/$domain/one.php cache:refresh
    exit 0
fi
done

然后再授权:

chmod +x /root/.aria2/oneindexup.sh

最后在配置文件aria2.conf里加上一行on-download-complete=/root/.aria2/oneindexup.sh,可以直接使用命令:

echo "on-download-complete=/root/.aria2/oneindexup.sh" >>/root/.aria2/aria2.conf
#重启Aria2
service aria2 restart

2、Rclone挂载上传
我们先使用挂载Rclone挂载OneDrive,挂载方法查看:在Debian/Ubuntu上使用rclone挂载OneDrive网盘,然后步骤就和上面的OneIndex上传方法一样了,就是上传脚本不一样,上传脚本如下:

#!/bin/bash
path=$3 #取原始路径,我的环境下如果是单文件则为/data/demo.png,如果是文件夹则该值为文件夹内某个文件比如/data/a/b/c/d.jpg
downloadpath='/root/Download'  #Aria2下载文件目录
name='RATS'  #配置Rclone时的name
folder='VPS'  #网盘里的文件夹

if [ $2 -eq 0 ]
        then
                exit 0
fi
while true; do  #提取下载文件根路径,如把/data/a/b/c/d.jpg变成/data/a
filepath=$path
path=${path%/*}; 
if [ "$path" = "$downloadpath" ] && [ $2 -eq 1 ]  #如果下载的是单个文件
    then
    rclone move "$filepath" ${name}:${folder}/     
    exit 0
elif [ "$path" = "$downloadpath" ]   #文件夹
    then
    while [[ "`ls -A "$filepath/"`" != "" ]]; do
    rclone move "$filepath"/ ${name}:${folder}/"${filepath##*/}"/ --delete-empty-src-dirs
    done
    rm -rf "$filepath/"
    exit 0
fi
done

3、使用上传脚本
方法参考:VPS上传文件到OneDrive网盘脚本,可配合Aria2实现自动上传

关于更多OneIndex的使用方法请查看:OneIndex一键安装脚本 for Debian


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/700/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。