广告

本站里的文章大部分经过自行整理与测试

2019年2月18日星期一

Ubuntu - OneDrive (rclone 挂载)

1) rclone 安装
https://rclone.org/downloads/

$ wget https://downloads.rclone.org/v1.46/rclone-v1.46-linux-amd64.deb
$ sudo apt install libfuse2 rclone-browser
$ sudo dpkg -i rclone-v1.46-linux-amd64.deb

2) 让软件得到权限处理 OneDrive 文件 (取得 access_token)

$ rclone authorize "onedrive"
$ rclone authorize "box"
$ rclone authorize "yandex"
$ rclone authorize "dropbox"
# google drive 不需要, 直接可跑 rclone config

2019/02/18 02:15:53 NOTICE: Config file "/home/username/.config/rclone/rclone.conf" not found - using defaults
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":"","expiry":"2019-02-18T03:16:12.502116809+08:00"}
<---End paste

3) rclone 配置 (new remote_name: bat)(OneDrive)

$ rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> bat (之后可以改名)
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
 1 / A stackable unification remote, which can appear to merge the contents of several remotes
   \ "union"
 2 / Alias for a existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Dropbox
   \ "dropbox"
 9 / Encrypt/Decrypt a remote
   \ "crypt"
10 / FTP Connection
   \ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
12 / Google Drive
   \ "drive"
13 / Hubic
   \ "hubic"
14 / JottaCloud
   \ "jottacloud"
15 / Local Disk
   \ "local"
16 / Mega
   \ "mega"
17 / Microsoft Azure Blob Storage
   \ "azureblob"
18 / Microsoft OneDrive
   \ "onedrive"
19 / OpenDrive
   \ "opendrive"
20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
21 / Pcloud
   \ "pcloud"
22 / QingCloud Object Storage
   \ "qingstor"
23 / SSH/SFTP Connection
   \ "sftp"
24 / Webdav
   \ "webdav"
25 / Yandex Disk
   \ "yandex"
26 / http Connection
   \ "http"
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> 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> 
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> n (如果是 Google Drive, 选 y)
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":"2019-02-18T03:16:12.502116809+08:00"}
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:  (personal) id=abc123567890
Chose drive to use:> 0
Found drive 'root' of type 'personal', URL: https://onedrive.live.com/?cid=abc123567890
Is that okay?
y) Yes
n) No
y/n> y
--------------------
[bat]
type = onedrive
token = {"access_token":"","expiry":"2019-02-18T03:16:12.502116809+08:00"}
drive_id = abc123567890
drive_type = personal
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name                 Type
====                 ====
bat                  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

4) fuse 配置 (拿掉以下前面的 # 符号)
$ sudo gedit /etc/fuse.conf
user_allow_other

5) 挂载
$ mkdir -p /home/username/My_OneDrive

$ rclone mount bat:/ /home/username/My_OneDrive 
--copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

6) 卸载
$ fusermount -qzu /home/username/My_OneDrive

7) 自启 Startup Applications
将步骤5挂载命令加入到 Startup Application 即可

没有评论:

发表评论