部署条件 VPS空间一个:系统为linux AriaNg:用于离线下载。 OneDriveUploader:用于将本地文件上传至OneDrive网盘中的程序。
安装AriaNg 为了确保能正常使用,请先安装基础组件wget
、curl
、ca-certificates
,以 Debian 为例子
1 apt install wget curl ca-certificates
下载脚本 1 wget -N git.io/aria2.sh && chmod +x aria2.sh && ./aria2.sh
默认下载目录:/root/downloads
RPC 密钥:随机生成,可使用选项修改 配置文件
自定义
OneDriveUploader 取得onedrive授权 点击右侧URL登录并授权,授权地址→【国际版、个人版(家庭版) 】、【中国版(世纪互联) 】 授权后会获取一个localhost开头打不开的链接,这里复制好整个链接地址
,包括localhost
安装OneDriveUploader 1 2 3 4 5 6 7 8 9 wget https:// raw.githubusercontent.com/MoeClub/ OneList/master/ OneDriveUploader/amd64/ linux/OneDriveUploader -P /u sr/local/ bin/ wget https:// raw.githubusercontent.com/MoeClub/ OneList/master/ OneDriveUploader/i386/ linux/OneDriveUploader -P /u sr/local/ bin/ wget https:// raw.githubusercontent.com/MoeClub/ OneList/master/ OneDriveUploader/arm/ linux/OneDriveUploader -P /u sr/local/ bin/ chmod +x /usr/ local/bin/ OneDriveUploader
初始化配置 1 2 3 4 5 6 7 8 #国际版,将url换成你上面复制的授权地址,包括http: OneDriveUploader -a "url" #个人版(家庭版),将url换成你上面复制的授权地址,包括http: OneDriveUploader -ms -a "url" #中国版(世纪互联),将url换成你上面复制的授权地址,包括http: OneDriveUploader -cn -a "url"
如果提示Init config file: /path/to/file/auth.json类似信息,则初始化成功。友情提示,可能需要等待十几秒。
使用命令 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 Usage of OneDriveUploader: -a string Setup and Init auth.json. -b string Set block size. [Unit: M; 5 <=b<=60 ;] (default "10" ) -c string Config file . (default "auth.json" ) -n string Rename file on upload to remote . -r string Upload to reomte path. -s string Upload item . -t string Set thread num . (default "2" ) -f Force Read config form config file . [BlockSize, ThreadNum] -skip Skip exist file on remote . -cn OneDrive by 21 Vianet. -ms OneDrive by Microsoft.
Aria2自动上传 上传脚本代码如下,自己简单修改配置后,保存为upload.sh
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 #!/bin/bash GID="$1 " ; FileNum="$2 " ; File="$3 " ; MaxSize="15728640" ; Thread="3" ; Block="20" ; RemoteDIR="" ; LocalDIR="/www/download/" ; Uploader="/usr/local/bin/OneDriveUploader" ; Config="/root/auth.json" ; 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 (){ if [[ ! -e "${Uploader} " ]]; then return ; fi IFS_BAK=$IFS IFS=$'\n' tmpFile="$(echo "${File/#$LocalDIR} " |cut -f1 -d'/') " FileLoad="${LocalDIR} ${tmpFile} " if [[ ! -e "${FileLoad} " ]]; then return ; fi 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${FileLoad} \033[0mtoo large to spik.\n" ; return ; fi ${Uploader} -c "${Config} " -t "${Thread} " -b "${Block} " -s "${FileLoad} " -r "${RemoteDIR} " -skip if [[ $? == '0' ]]; then rm -rf "${FileLoad} " ; fi IFS=$IFS_BAK } LoadFile;
编辑好上传脚本后,可以检测下脚本编码是否正确,比如我脚本路径为/root/upload.sh,使用命令:
如果无任何输出,则正确,反之输出类似$'r': command not found
错误,则需要转换下编码格式,具体步骤如下。
先安装dos2unix
1 2 3 4 5 yum install dos2unix -y apt install dos2unix -y
再转换编码:
1 2 dos2unix /root/u pload.sh
配置AriaNg的上传脚本 原理很简单,通过配置项on-download-complete
来完成下载文件自动移动上传到onedrive里面
打开/root/aria2/conf/aria2.conf
文件,可以使用vim或者本地文件编辑器。
在文本末尾加上这段代码,保存后重启aria2即可。记得路径修改为你配置的路径。
1 on -download-complete=/root/u pload.sh