rclone配置onedrive跟Googledrive及挂载

前言

Rclone是一款非常强大的网盘工具,支持Dropbox、Box、Onedrive、Gdrive、Mega等在内的主流网盘中的各类资源,支持在不同对象存储、网盘间同步、上传、下载数据。

官网网址:https://rclone.org
Github 项目:https://github.com/ncw/rclone

安装(一键脚本)

要在Linux/macOS/BSD系统上安装正式版的rclone,请运行:

curl https://rclone.org/install.sh | sudo bash

对于测试版安装,请运行:

curl https://rclone.org/install.sh | sudo bash -s beta

配置

进入rclone的配置页面,选择n创建新的配置文件

root@localhost:~# rclone config
2019/02/17 01:16:17 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name>

微软的Onedrive

第一步

在name那边输入你要叫的配置名称,随便都行,这里用one。

name> one
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
...
17 / Microsoft Azure Blob Storage
   \ "azureblob"
18 / Microsoft OneDrive
   \ "onedrive"
19 / OpenDrive
   \ "opendrive"
...
Storage> 

第二步

从中找到我们要配置Onedrive,序号是18,输入18,进入下一步

Storage> 18
** See help for onedrive backend at: https://rclone.org/onedrive/ **

Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id> 
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> 
Edit advanced config? (y/n)
y) Yes
n) No
y/n> 

第三步

上面client_id client_secret都是直接按回车,默认为空就行。最后是问你是否进入高级设置,这里选择y

y/n> y
Chunk size to upload files with - must be multiple of 320k.

Above this size files will be chunked - must be multiple of 320k. Note
that the chunks will be buffered into memory.
Enter a size with suffix k,M,G,T. Press Enter for the default ("10M").
chunk_size> 
The ID of the drive to use
Enter a string value. Press Enter for the default ("").
drive_id> 
The type of the drive ( personal | business | documentLibrary )
Enter a string value. Press Enter for the default ("").
drive_type>

第四步

chunk_size这里可以根据需要进行设置,回车默认也行,drive_id这里也按回车默认空。drive_type这里看你的onedrive账号是属于哪类的,有个人(personal),商业(business),文库(documentLibrary)

drive_type> business
Set to make OneNote files show up in directory listings.

By default rclone will hide OneNote files in directory listings because
operations like "Open" and "Update" won't work on them.  But this
behaviour may also prevent you from deleting them.  If you want to
delete OneNote files or otherwise want them to show up in directory
listing, set this option.
Enter a boolean value (true or false). Press Enter for the default ("false").
expose_onenote_files> 
Remote config
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> 

第五步

expose_onenote_files这里设置是否包含OneNote的文件,看个人需要,这里按回车,默认false就行
最后是问你是否自动配置接下里的token还是你手动输,由于一般我们的服务器都是headless的,无界面的,所以这里选择n。然后在你本地,选择对应的版本,下载rclone。我这边是window10,命令如下:

.\rclone.exe authorize "onedrive"

登录你的onedrive账号后,会成功获得到token

If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
Log in and authorize rclone for access
Waiting for code...
Got code
Paste the following into your remote machine --->
{"access_token":""}
<---End paste

复制---><---End paste之间的内容到result

第六步

Choose a number from below, or type in an existing value
 1 / OneDrive Personal or Business
   \ "onedrive"
 2 / Root Sharepoint site
   \ "sharepoint"
 3 / Type in driveID
   \ "driveid"
 4 / Type in SiteID
   \ "siteid"
 5 / Search a Sharepoint site
   \ "search"
Your choice> 1
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=XXXXXXX
Chose drive to use:> 0
Found drive 'root' of type 'business', URL: https://accelerider-my.sharepoint.com/personal/XXXXX/Documents
Is that okay?
y) Yes
n) No
y/n> y

Your choice根据你的选择来,后面后出现你账号有几个盘,这里选择第0个,最后选择y表示已经ok。最后还有个确认,继续y,ok就行。这样就添加成功了:

Current remotes:

Name                 Type
====                 ====
one                  onedrive

谷歌的Googledrive

第一步

Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
...
11 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
12 / Google Drive
   \ "drive"
13 / Hubic
   \ "hubic"
...
Storage> 

这里寻找我们要的Googledrive,可以看到序号是12,输入12

第二步

Storage> 12
** See help for drive backend at: https://rclone.org/drive/ **

Google Application Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id> 
Google Application Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> 
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
 2 / Read-only access to file metadata and file contents.
   \ "drive.readonly"
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ "drive.file"
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ "drive.appfolder"
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ "drive.metadata.readonly"
scope> 

client_idclient_secret一样按回车默认为空就行,scope这里大家根据需要选择,这里选择1。

第三步

scope> 1
ID of the root folder
Leave blank normally.
Fill in to access "Computers" folders. (see docs).
Enter a string value. Press Enter for the default ("").
root_folder_id> 
Service Account Credentials JSON file path 
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file> 
Edit advanced config? (y/n)
y) Yes
n) No
y/n> y

root_folder_idservice_account_file一样按回车默认为空就行。输y进入高级设置。后面过程可以一路回车按默认来就行,这里不再贴内容。

第四步

Enter a signed integer. Press Enter for the default ("100").
pacer_burst> 
Remote config
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

到了这里,开始填token了,一样由于一般服务器都是无界面的,这里还是选择n。
打开:输入n后,它给的授权地址

弹出窗口,登录账号(这里需要科学上网),登录成功点允许。这样可以获取代码,根据提示复制代码到Enter verification code里。

Configure this as a team drive?
y) Yes
n) No
y/n> n

这里就看个人实际来选,最后的就剩两部确认了,一直输y确认就行。

验证

rclone lsd 配置名称:目录

输入命令,看有没列出内容来,有的话说明配置没问题。

挂载到硬盘

rclone mount允许Linux,FreeBSD,macOS和Windows将任何Rclone的云存储系统作为带有FUSE的文件系统安装。

首先需要安装libfuse库才能运行,官方省略了这个步骤,我这里加上。

  • Ubuntu或Debian的:

    • 64位的请运行

      yum install fuse-devel.x86_64 fuse.x86_64
    • 32位的请运行

      yum install fuse-devel.i686 fuse.i686
  • centos的:

    • 直接运行

      apt-get install -y fuse

需要创建一个目录,设为挂载点,然后运行:

rclone mount 配置名称:对应里面的文件夹名  目录地址 --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

既可以挂载上去,最后用df -m来查看有没挂载成功~
后话:还有什么开机自动挂载的设置啥的,这些搜索下会有很多的,大同小异这里就不放上了。

posted @ 2019-02-17 15:39:00 kuye 阅读(20101) 评论(0)
发表评论
昵称
邮箱
网址