之前因为比较懒就没有写,正好最近又用到这个,就补上吧。
需要配合《OneDrive for Business in Linux》一起使用
前期准备
项目地址:https://github.com/mayswind/AriaNg/releases
项目地址:https://github.com/donwa/oneindex
项目地址:https://github.com/weiyidu/OneDrive
Aria2一键安装脚本(逗比制作)
1 2 3 4 |
wget -N --no-check-certificate https://softs.loan/Bash/aria2.sh && chmod +x aria2.sh && bash aria2.sh # 如果上面这个脚本无法下载,尝试使用备用下载: wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/aria2.sh && chmod +x aria2.sh && bash aria2.sh |
使用教程https://doub.io/shell-jc4/(需要科学上网访问)
安装
网站运行环境:推荐“宝塔面板”,安装教程
1、创建AriaNg网站
如果连接不上宝塔面板安全放行6800端口
2、创建oneindex网站
1、PHP空间,PHP 5.6+ 打开curl支持
2、onedrive 账号 (个人、企业版或教育版/工作或学校帐户)
3、oneindex 程序
在文件夹底部添加说明:在onedrive的文件夹中添加README.md文件,使用markdown语法。
在文件夹头部添加说明:在onedrive的文件夹中添加HEAD.md 文件,使用markdown语法。
加密文件夹:在onedrive的文件夹中添加.password文件,填入密码,密码不能为空。
直接输出网页:在onedrive的文件夹中添加index.html 文件,程序会直接输出网页而不列目录。
配合 文件展示设置-直接输出 效果更佳
修改Aria2配置
1、修改下载目录,如下图,选择7 修改配置文件,选择3
2、选择5 手动 打开配置文件修改,在最后一行on-download-complete=/root/autoupload.sh
autoupload.sh脚本内容,需要配合《OneDrive for Business in Linux》使用
赋予运行权限 chmod +x autoupload.sh
1 |
wget --no-check-certificate -q -O /root/autoupload.sh "https://raw.githubusercontent.com/weiyidu/OneDrive/master/autoupload_new.sh" && chmod +x /root/autoupload.sh |
修改LocalDIR目录与第1步的目录地址一样
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#!/bin/bash GID="$1"; FileNum="$2"; File="$3"; MaxSize="15728640" RemoteDIR=""; #上传到Onedrive的路径,默认为根目录。 LocalDIR="/home/"; #Aria2下载目录,记得最后面加上/ if [[ -z $(echo "$FileNum" |grep -o '[0-9]*' |head -n1) ]]; then FileNum='0'; fi if [[ "$FileNum" -le '0' ]]; then exit 0; fi if [[ "$#" != '3' ]]; then exit 0; fi function LoadFile(){ IFS_BAK=$IFS IFS=$'\n' if [[ ! -d "$LocalDIR" ]]; then return; fi if [[ -e "$File" ]]; then if [[ $(dirname "$File") == $(readlink -f $LocalDIR) ]]; then ONEDRIVE="onedrive"; else ONEDRIVE="onedrive-d"; fi FileLoad="${File/#$LocalDIR}" while true do if [[ "$FileLoad" == '/' ]]; then return; fi echo "$FileLoad" |grep -q '/'; if [[ "$?" == "0" ]]; then FileLoad=$(dirname "$FileLoad"); else break; fi; done; if [[ "$FileLoad" == "$LocalDIR" ]]; then return; fi if [[ -n "$RemoteDIR" ]]; then Option=" -f $RemoteDIR"; else Option=""; fi EXEC="$(command -v $ONEDRIVE)"; if [[ -z "$EXEC" ]]; then return; fi cd "$LocalDIR"; if [[ -e "$FileLoad" ]]; then ItemSize=$(du -s "$FileLoad" |cut -f1 |grep -o '[0-9]*' |head -n1) if [[ -z "$ItemSize" ]]; then return; fi if [[ "$ItemSize" -ge "$MaxSize" ]]; then echo -ne "\033[33m$File \033[0mtoo large to spik.\n"; return; fi eval "${EXEC}${Option}" \'"${FileLoad}"\'; if [[ $? == '0' ]]; then rm -rf "$FileLoad"; fi fi fi IFS=$IFS_BAK } LoadFile; |
文章评论
大佬,ox挂了能不能发个备份源码
@nasic 这个没有,你在网上找一个OD的源码就可以了没必要用OX
博主您好,我遇到了一个问题,尝试用 centos和ubantu 搭建之后还是会出现如下问题:下载大文件的时候下载没有完成就自动上传tmp文件,请问怎么解决呢?
@陈尚良 应该不会出现这个问题吧,脚本是下载完成后才执行的,我下载6G文件都正常。
为什么不会上传目录啊,例如/a/a.txt,直接上传文件夹里的a.txt而不会创建a目录
大佬,为什么不会上传文件夹,光把文件夹里面的文件上传上去了?