【原创】Centos7 使用 RCLONE 挂载 OneDrive 搭建离线下载 、在线播放
友情提醒 : 没有OneDrive for Business 的童鞋可以注册一年免费的开发者认证 【传送门】
笔者这里使用的是 VIRMACH 特价虚拟主机 [传送门] 也可以用搬瓦工的主机 [传送门]
虚拟技术:KVM (理论 OpenVZ、Xen、VMware 都可以)
CPU model : QEMU Virtual CPU version (cpu64-rhel6)
Number of cores : 1
CPU frequency : 2599.998 MHz
Total size of Disk : 9.6 GB (1.3 GB Used)
Total amount of Mem : 236 MB (74 MB Used)
Total amount of Swap : 255 MB (1 MB Used)
OS : CentOS 7.4.1708
Arch : x86_64 (64 Bit)
Kernel : 3.10.0-693.21.1.el7.x86_64
1.安装命令
mkdir /home/Download
wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/aria2.sh
chmod +x aria2.sh
bash aria2.sh
安装完后运行 ./aria2.sh
1、配置 自动更新 BT-Tracker服务器
2、重新设置密码并更改下载目录为 /home/Download
1.安装命令
yum -y update
yum -y install fuse
curl https://rclone.org/install.sh | sudo bash
安装成功后会提示 rclone v1.xx has successfully installed.
首先需要在本地电脑也下载 rclone (用于获取 OneDrive 登录 TOKEN , 因为过程当中会打开网页,登录 OneDrive
由于 SSH 配置是无法看到网页的)
下载地址:https://rclone.org/downloads/ 然后解压出来,比如我解压到D盘,文件夹命名rclone,此时点击Win+R,然后输入cmd,确定。再输入以下命令:
cd /d d:\rclone rclone authorize "onedrive"
会出现以下信息:
D:\rclone>cd /d d:\rclone
D:\rclone>rclone authorize "onedrive"
Choose OneDrive account type?
* Say b for a OneDrive business account
* Say p for a personal OneDrive account
b) Business
p) Personal
b/p> b <== (这里 个人账号选 p 工作账号选 b 因为我是 OneDrive Business)
If your browser doesn't open automatically go to the following link: http://127.
0.0.1:53682/auth <== (这里会打开网页 登录你的 OneDrive 账号即可)
Log in and authorize rclone for access
Waiting for code...
Got code <== (这里是返回你的 TOKEN)
Paste the following into your remote machine --->
{"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImlCakwxUmNxemhpeTR
mcHhJeGRacW9oTTJZayIsImtpZCI6ImlCakwxUmNxemhpeTRmcHhJeGRacW9oTTJZayJ9.eyJhdWQiOi
JodHRwczovL2FwaS5vZmZpY2UuY29tL2Rpc2NvdmVyeS8iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3
dzLm5ldC8zOWE2Y2E2MS05OGRjLTRkY2MtYjU5Mi1kM2JhYzYxNDkzOTQvIiwiaWF0IjoxNTI1Mjc2OD
...
98JnWA_VvhIUeW98RvBSAA","expiry":"2018-05-03T01:04:55.9347103+08:00"}
<---End paste
我们所需要的就是下面绿色区域中间的内容 {"access_token":" .... "expiry":"2018-05-03T01:04:55.9347103+08:00"}
小技巧: 因为我们是从Console控制台中复制出来的文本,所以里面会有换行符。等下是无法直接在 SSH 粘贴使用的,所以这里用到了 Notepad++ 来转换一下
1、粘贴文本到新建的记事本
2、用 Notepad++ 打开 菜单中选择 搜索 - 替换
3、设置 查找目标为 (\r\n) 勾选下面的 (扩展(\n,\r,\t...)选项)后 全部替换
然后再切换到 VPS 中配置 rclone 输入以下命令:
rclone config
会出现以下信息:
[root@MeiamOS ~]# rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> OneDrive <== (这里输入挂在项目的名字)
Type of storage to configure.
Choose a number from below, or type in your own value
1 / Alias for a existing remote
\ "alias"
2 / Amazon Drive
\ "amazon cloud drive"
3 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
\ "s3"
4 / Backblaze B2
\ "b2"
5 / Box
\ "box"
6 / Cache a remote
\ "cache"
7 / Dropbox
\ "dropbox"
8 / Encrypt/Decrypt a remote
\ "crypt"
9 / FTP Connection
\ "ftp"
10 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
11 / Google Drive
\ "drive"
12 / Hubic
\ "hubic"
13 / Local Disk
\ "local"
14 / Mega
\ "mega"
15 / Microsoft Azure Blob Storage
\ "azureblob"
16 / Microsoft OneDrive
\ "onedrive"
17 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
18 / Pcloud
\ "pcloud"
19 / QingCloud Object Storage
\ "qingstor"
20 / SSH/SFTP Connection
\ "sftp"
21 / Webdav
\ "webdav"
22 / Yandex Disk
\ "yandex"
23 / http Connection
\ "http"
Storage> 16 <== (这里选择 所需要挂在类型的 ID 上面是可以挂在网盘的列表)
Microsoft App Client Id - leave blank normally.
client_id> <== (回车留空)
Microsoft App Client Secret - leave blank normally.
client_secret> <== (回车留空)
Remote config
Choose OneDrive account type?
* Say b for a OneDrive business account
* Say p for a personal OneDrive account
b) Business
p) Personal
b/p> b <== (我的账号是 OneDrive Business 账号所以选择 b)
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> n <== (这里选择 N )
For this to work, you will need rclone available on a machine that has a web browser available.
Execute the following on your machine:
rclone authorize "onedrive"
Then paste the result below:
result> {"access_token":"","expiry":""} <== (这里贴入刚才获取TOKEN)
--------------------
[OneDrive]
type = onedrive
client_id =
client_secret =
token = {"access_token":"","expiry":"2018-05-02T22:56:29.794396289-04:00"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name Type
==== ====
OneDrive onedrive
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> q
[root@MeiamOS ~]#
1、下载RCLOAD自启动挂载脚本:
wget -N --no-check-certificate https://raw.githubusercontent.com/x91270/Centos/master/rcloned
vim rcloned
2、修改RCLOAD自启动脚本关联目录
NAME="" #rclone name名,及配置时输入的Name
REMOTE='' #远程文件夹,OneDrive 网盘里的挂载的一个文件夹
LOCAL='' #挂载地址,VPS本地挂载目录
3、设置RCLOAD自动启动
mv rcloned /etc/init.d/rcloned
chmod +x /etc/init.d/rcloned
chkconfig rcloned on
bash /etc/init.d/rcloned start
4、给ARIA2添加下载完成移动到网盘脚本
cd /root/.aria2/
wget -N --no-check-certificate https://raw.githubusercontent.com/x91270/Centos/master/move.sh
chmod +x move.sh
echo "on-download-complete=/root/.aria2/move.sh" >> aria2.conf
注意:如果你的目录和教程中不一样请在 move.sh 中设定
RCLOAD启动停止命令
bash /etc/init.d/rcloned start bash /etc/init.d/rcloned stop
查看挂载磁盘
df -h
到这里就完成了搭建过程用 AriaNg 链接 你的服务器 愉快的下载吧
我用这个脚本手动bash /etc/init.d/rcloned start可以挂载,但是重启没有自启动,是什么问题呢
添加服务 chkconfig rcloned on
输入token之后就报错
2018/05/15 12:15:51 ERROR : Failed to save new token in config file: section ‘OneDrive’ not found
这个错误
你的这个问题我估计还是你从CMD中复制 转换 TOKEN 时的问题
根据博主做的,挂载成功了,可是下载以后不会运行move.sh自动上传,不是网速上传慢的原因,就是不会上传,下载地址和博主一致、home/Download,挂载的目录也是home/Onedrive。可就是不会上传,求博主支招,自己粘贴去挂载盘,onedrive上是可以同步的
/root/.aria2/mvcompleted.log
看看日志
另外注意一下 目录名的大小写问题
/root/.aria2/ 目录下没有找到日志mvcompleted.log,只有aria2的日志,
aria2.config已经添加on-download-complete=/root/.aria2/oneup.sh 好奇怪就是未运行
已经添加on-download-complete=/root/.aria2/mv.sh,刚刚复制错了
我也是没有自动上传,那个日志刚刚下载试验了下没有记录这次下载,只有昨天某一次测试后的记录ERROR not under /home/Download.文件夹大小写对着的
91270 at 麻花疼
弄了好几天终于找到个可以正常使用的脚本了
一、cd /root/.aria2/
二、vi move.sh
粘贴下面的脚本
#!/bin/sh
# $1 is gid.
# $2 is the number of files.
# $3 is the path of the first file.
DOWNLOAD=/home/Download # no trailing slash!
COMPLETE=/home/OneDrive # no trailing slash!
LOG=/root/.aria2/mvcompleted.log
SRC=$3
if [ “$2” == “0” ]; then
echo `date` “INFO no file to move for” “$1”. >> “$LOG”
exit 0
fi
while true; do
DIR=`dirname “$SRC”`
if [ “$DIR” == “$DOWNLOAD” ]; then
echo `date` “INFO ” “$SRC” moved as “$SRC”. >> “$LOG”
mv “$SRC” “$COMPLETE” >> “$LOG” 2>&1
exit $?
elif [ “$DIR” == “/” -o “$DIR” == “.” ]; then
echo `date` ERROR “$SRC” not under “$DOWNLOAD”. >> “$LOG”
exit 1
else
SRC=$DIR
fi
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
三、esc—:wq(保存脚本)
四、chmod +x move.sh
echo “on-download-complete=/root/.aria2/move.sh” >> aria2.conf
五、配置好后记得重启aria2.
启动:/etc/init.d/aria2 start
停止:/etc/init.d/aria2 stop
重启:/etc/init.d/aria2 restart
查看状态:/etc/init.d/aria2 status
谢谢博主的帮助,虽然不知道为什么我的用不了博主的脚本,环境为centos7,ARIA2用的逗比大佬的脚本(如果我没记错的话)(win10下获取onedrive我是不需要去替换换行符,直接粘贴就可以连接上rcloned)希望有同样问题的童鞋可以解决。
https://raw.githubusercontent.com/x91270/Centos/master/move.sh
我用这个脚本在 N 台服务上测试都正常。 不知道你们的环境具体怎么导致的
兄弟这个脚本你能再发一次吗。有的符号是中文的、`这个符号需要改成英文的’吗
127.0.0.1:83682 window10打不开
[#6102c5 SEED(0.0) CN:10 SD:0 UL:152KiB(27MiB)]
[#6102c5 SEED(0.0) CN:10 SD:0 UL:142KiB(27MiB)]
06/20 11:19:26 [NOTICE] Seeding is over.
[#6102c5 SEED(0.1) CN:7 SD:0 UL:172KiB(27MiB)]
06/20 11:19:27 [NOTICE] Download complete: /home/Download/BBB930
06/20 11:19:27 [NOTICE] Your share ratio was 0.1, uploaded/downloaded=27MiB/279MiB
Could not execute user command: /root/.aria2/move.sh: No such file or directory
无法执行用户命令:/root/. aria2/move。sh:没有这样的文件或目录
看看是否赋予了运行权限
06/23 08:18:42 [ERROR] IPv4 RPC: failed to bind TCP port 6800
Exception: [SocketCore.cc:312] errorCode=1 Failed to bind a socket, cause: Address already in use
06/23 08:18:42 [ERROR] IPv6 RPC: failed to bind TCP port 6800
Exception: [SocketCore.cc:312] errorCode=1 Failed to bind a socket, cause: Address already in use
06/23 08:18:42 [ERROR] Exception caught
Exception: [DownloadEngineFactory.cc:219] errorCode=1 Failed to setup RPC server.
下载时候报错,这是什么情况
Aria2 重复启动了吧。端口被占用了
Could not execute user command: /root/.aria2/move.sh: No such file or directory一直提示找不到move.sh 但是move.sh确实存在
修改 文件名称。确认是否有运行权限
把 aria2.conf 文件里面的 这个文件名修改一下试试
前几天改了下文件名就找得到了,后来aria2连接不上重装了一下 今天怎么改怎么给权限怎么换路径都找不到
经过上百次的调试,发现是编码问题,直接用脚本wget -N –no-check-certificate https://raw.githubusercontent.com/x91270/Centos/master/move.sh会导致编码问题而提示No such file or directory错误,可以将move.sh的内容手动粘贴进去就可以了
感谢。我已经修复了此问题
[root@lan-pc .aria2]# bash /etc/init.d/rcloned stop
[信息] rclone 停止成功 !
[root@lan-pc .aria2]# bash /etc/init.d/rcloned start
[错误] rclone 启动失败 !
[root@lan-pc .aria2]# cd ..
[root@lan-pc ~]# bash /etc/init.d/rcloned start
[错误] rclone 启动失败 !
[root@lan-pc ~]# bash /etc/init.d/rcloned start
停止后就无限失败 不知道怎么搞了
修改RCLOAD自启动脚本关联目录
这一步具体该怎样做呀,卡在这一步无法进行了,能详细说明一下吗?谢谢!
请问站长,我按照您的教程在谷歌云上挂载了OD的网盘,然后在谷歌云上装了一套“可道云”网盘程序,地址是:kodcloud.com,想用这个网盘程序操作挂载上的OD网盘,这个想法可行吗?
输入 token后显示下面这个 请问哪里出错了?
Then paste the result below:
result>
:22:32 Failed to query available drives: HTTP error 401 (401 Unauthorized) returned body: “{\r\n \”error\”: {\r\n \”code\”: \”InvalidAuthenticationToken\”,\r\n \”message\”: \”Access token validation failure.\”,\r\n \”innerError\”: {\r\n \”request-id\”: \”e6271faa-e2d2-4ad0-829a-275ed42fba8a\”,\r\n \”date\”: \”2018-12-29T13:22:33\”\r\n }\r\n }\r\n}”
一样呀 大哥 寻求解决方法
大佬遇到过这种情况吗?(输入token时间报错了) Your choice> 1
2019/03/07 23:45:57 Failed to query available drives: HTTP error 401 (401 Unauthorized) returned body: “{\r\n \”error\”: {\r\n \”code\”: \”InvalidAuthenticationToken\”,\r\n \”message\”: \”Access token validation failure.\”,\r\n \”innerError\”: {\r\n \”request-id\”: \”1d237177-e64f-4c98-a1cb-93ec1ee3c64c\”,\r\n \”date\”: \”2019-03-07T15:45:57\”\r\n }\r\n }\r\n}”
暂时没遇见过这种情况。注意复制是否有多余的字符
其实我只想知道这容量是不是买的,反正新用户只有5G
应该是服务器版和Windows版不一致导致的。
hu Jul 4 10:44:41 CST 2019 ERROR not under /home/Download.
这个是什么原因,在使用move.sh时
可以直接下载到挂载onedrive网盘吗