Rclone官方版1.54.0已正式支持世纪互联(含sharepoint)了。
一、获取应用 ID 和密匙
地址:https://portal.azure.cn/,登录完成后按下面步骤进行
1.左侧Azure Active Directory
->应用注册->新注册.

2.名称部分:随便写->受支持的账户类型:任何组织目录(任何 Azure AD 目录 - 多租户)中的帐户
—重定向 URI (可选):http://localhost:53682
—注册

3.应用程序(客户端) ID

4.获取密匙:左侧证书和密码—
右侧客户端密码部分:+新客户端密码


说明:自己填写—截止日期:2 年内—添加
5.左侧 API 权限—
添加权限—Microsoft Graph—委托的权限— 搜索并勾选下面 6 个权限:
Files.Read
Files.Read.All
Files.ReadWrite
Files.ReadWrite.All
offline_access
User.Read

到这样,就注册结束了!用记事本记录一下 ID 和密匙(后面用到)
二、rclone配置世纪互联
1、简介
目前最新版本是1.54.0,已经正常支持世纪互联(含sharepoint)!
官网:https://rclone.org/
项目:https://github.com/rclone/rclone
下载:https://github.com/rclone/rclone/releases
2、windonws10安装rclone
1)Windows客户端:rclone-v1.54.0-windows-amd64.zip
2)下载后将其解压,并将rclone.exe
移动到C:\Windows\System32
这个目录,这样就可以使用rclone命令了
3)在cmd窗口继续输入命令rclone config
进行配置,输入n
新建一个远程,并取一个名字,比如od
4)输入名称后,找到OneDrive,目前最新版1.54.0,od序号是26,不是固定的,会随着版本号改变。
5)下面就需要输入Client Secret和Client Id
应用程序(客户端) ID(client_id)
客户端密码部分:值(client_secret)
6)选择世纪互联和其他一堆操作。
我们看到序号4,是世纪互联,其他就跟着教程走。这里就不细说了。
Choose a number from below, or type in your own value
1 / Microsoft Cloud Global
\ "global"
2 / Microsoft Cloud for US Government
\ "us"
3 / Microsoft Cloud Germany
\ "de"
4 / Azure and Office 365 operated by 21Vianet in China
\ "cn"
region> 4 #选择4
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n #这里选择n
Remote config
Make sure your Redirect URL is set to "http://localhost:53682/" in your custom config.
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> y #选择y
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=A_tjjKrdfKTLdPftq9phRw
Log in and authorize rclone for access
Waiting for code...
Got code
7)这之后,会进入登录页面,输入你的账号和密码登录即可,会自动获得token,如果打不开可以把前面的网址换为:https://login.chinacloudapi.cn/common,后面的都不要动。之后的操作如下:
Choose a number from below, or type in an existing value
1 / OneDrive Personal or Business
\ "onedrive"
2 / Root Sharepoint site
\ "sharepoint"
3 / Sharepoint site name or URL (e.g. mysite or https://contoso.sharepoint.com/sites/mysite)
\ "url"
4 / Search for a Sharepoint site
\ "search"
5 / Type in driveID (advanced)
\ "driveid"
6 / Type in SiteID (advanced)
\ "siteid"
7 / Sharepoint server-relative path (advanced, e.g. /teams/hr)
\ "path"
Your choice> 1 #这里选择1,od和sharepoint都是支持的,自己根据需要选择
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!5sR5nrtytytytytytytyVITcXXmJQaF8EznkrHDU
Chose drive to use:> 0 #选择0
Found drive 'root' of type 'business', URL: https://universitytongji-my.sharepoint.cn/personal/suoquhao_alumni_tongji_edu_cn/Documents
Is that okay?
y) Yes (default)
n) No
y/n> y #选择y
8)之后会出现token等配置,会自动生产配置文件,这里配置好,就算是结束了,下面的工作就是挂载,具体如下:
--------------------
[od]
type = onedrive
client_id = a58cc5
client_secret = YQ
region = cn
token = {"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6IjhrZ19JdUR0XzNzaklJanVlb052cFozVjlqWGp5czhRbE03Ym9WYmtkSE0iLCJ0VuE-hIAA","expiry":"2021-02-04T17:41:16.475507+08:00"}
drive_id = b!5sR5nWktPUG
drive_type = business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y #选择y
Current remotes:
Name Type
==== ====
od 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 #选择q退出配置
三、rclone挂载世纪互联
1、windows挂载之前需要下载Winfsp,没有这玩意挂载会出错。
Winfsp下载:https://github.com/billziss-gh/winfsp/releases
下载之后直接安装即可,无需修改安装位置,一路按默认的点下去就可。
打开cmd,输入如下挂载命令。
rclone mount od:/ F: --cache-dir D:\Temp\OneDrive --vfs-cache-mode writes
挂载成功如下:
C:\Users\ddd>rclone mount od:/ F: --cache-dir D:\Temp\OneDrive --vfs-cache-mode writes
The service rclone has been started.
2、Linux挂载
mkdir /mnt/od
rclone mount od: /mnt/od --allow-other --allow-non-empty &
如果在挂载的时候出现了类似下面的提示:failed to mount FUSE fs
需要安装 fuse。
CentOS/Fedora 安装 fuse:
yum install -y fuse
Ubuntu/Debian 安装 fuse:
apt install -y fuse
四、开机自动挂载
到这里还没结束,电脑重启后磁盘会消失,下面看看怎么解决。
windows系统新建两个文件,分别为rclone.bat和rclone.vbs
1)rclone.bat中写入上述挂载命令:
rclone mount od:/ F: --cache-dir D:\Temp\OneDrive --vfs-cache-mode writes
2)rclone.vbs设置开机自动调用cmd运行rclone.bat文件并退出cmd,写入如下代码:
CreateObject("WScript.Shell").Run "cmd /c D:/rclone.bat",0
3)将rclone.bat文件放到D盘(或其他的盘)目录下,我放在了D盘,所以在rclone.vbs中该文件的路径就是D:/rclone.bat
4)将rclone.vbs文件放到windows系统启动项目录下,在文件夹的路径框中输入如下代码:即可进入启动项目录
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
至此,onedrive磁盘的挂载完成,且电脑下次开机时onedrive磁盘也不会消失,同理sharepoint同样的挂载方法。
Linux系统先新建systemd
配置文件,适用CentOS 7
、Debian 8+
、Ubuntu 16+
。
#以下是一整条命令,一起复制到SSH客户端运行
cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
After=network-online.target
[Service]
Type=simple
ExecStart=$(command -v rclone) mount od: /mnt/od --allow-other --allow-non-empty
Restart=on-abort
User=root
[Install]
WantedBy=default.target
EOF
开始启动:
systemctl start rclone
设置开机自启:
systemctl enable rclone
其他命令:
重启:systemctl restart rclone
停止:systemctl stop rclone
状态:systemctl status rclone
5、最后
挂载后,访问速度不是太快,个人感觉没有微软官方提供的OneDrive程序打开的速度快。配置也很麻烦,其实完全可以用微软官方提供的OneDrive程序来部署。
Linux挂载就不做介绍了,然后标题是Linux下如何挂载?
哈哈,没注意。。不好意思,没想到会有人看。。。本意是自己记录下怕以后自己会忘记。。我再补充下
现在我的世纪互联和商业版都挂载不了,正好看看