使用rclone挂载OneDrive网盘
  • 分类:Linux
  • 发表:2020-03-16
  • 围观(297)
  • 评论(0)

安装rclone:

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

配置rclone:

rclone config

以下是配置过程


[root@MC ~]# rclone config#配置
2020/03/16 22:02:44 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 #新建
name> A5T#名称
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 / 1Fichier
\ "fichier"
2 / Alias for an 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 / Citrix Sharefile
\ "sharefile"
9 / Dropbox
\ "dropbox"
10 / Encrypt/Decrypt a remote
\ "crypt"
11 / FTP Connection
\ "ftp"
12 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
13 / Google Drive
\ "drive"
14 / Google Photos
\ "google photos"
15 / Hubic
\ "hubic"
16 / In memory object storage system.
\ "memory"
17 / JottaCloud
\ "jottacloud"
18 / Koofr
\ "koofr"
19 / Local Disk
\ "local"
20 / Mail.ru Cloud
\ "mailru"
21 / Mega
\ "mega"
22 / Microsoft Azure Blob Storage
\ "azureblob"
23 / Microsoft OneDrive
\ "onedrive"
24 / OpenDrive
\ "opendrive"
25 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
26 / Pcloud
\ "pcloud"
27 / Put.io
\ "putio"
28 / QingCloud Object Storage
\ "qingstor"
29 / SSH/SFTP Connection
\ "sftp"
30 / Sugarsync
\ "sugarsync"
31 / Transparently chunk/split large files
\ "chunker"
32 / Union merges the contents of several remotes
\ "union"
33 / Webdav
\ "webdav"
34 / Yandex Disk
\ "yandex"
35 / http Connection
\ "http"
36 / premiumize.me
\ "premiumizeme"
Storage> 23#选择23号OneDrive
** 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#Enter键跳过
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret#Enter键跳过
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n
Remote 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 #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 (same rclone version recommended) :
rclone authorize "onedrive"
Then paste the result below:
result

好的到这一步暂停一下,需要在自己的win/Mac电脑上打开链接获取token。

result>获取token

https://rclone.org/install/下载windows/Mac版本

打开cmd,进入到下载的软件文件夹,与上面同样的配置一遍,不过在Remote config时要选择y

Remote 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

随后选择1,会跳转浏览器登录

授权成功后回到cmd窗口,已获得token{"access_token":"xxxx"},复制 {xx}整个内容到Linux

复制过来后,继续往下就ok

{"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6Im0tSXV2NVdoWEhwcFpZcmNwNWF5RmEwLXFieFJEZVEwRlY1QldpblVTTE0iLCJhbGciOiJSUzI1NiIsIng1dCI6IllNRUxIVDBndmIwbXhvU0RvWWZvbWpxZmpZVSIsImtpZCI6IllNRUxIVDBndmIwbXhvU0RvWWZvbWpxZmpZVSJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9jODZhMDY4YS1hYTE4LTQzYjMtOWQyNC00ZTA3NWI2MDRhOTcvIiwiaWF0IjoxNTg0MzY2ODg4LCJuYmYiOjE1ODQzNjY4ODgsImV4cCI6MTU4NDM3MDc4OCwiYWNjdCI6MCwiYWNy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8_KWSv03JKCs5M-a-wOi2t2dgGMTROkxa9OjWR50lbPXZHEcELIbaq3lj-eKwe90duNR1HEus5TKgKTJLIeduWFg-AvElKiCKUBSv-Nqm8zFkJS_LgELVRosW5KnYuDDtV8OFYp_-Adm-_BMjO64tDjIMOMxISEGEXXxeydg5AsCfsgop7sdU52irDeY_wlWoitsg-bOtBtesHNC3GjVQWwtUBwBFHT62QCVCrsq3CcNK5TZjy5ZZQCyQqMnVs05J716cNZ9SsEeQxQhwBC5cCPPhB1g9bzkVp1nn4HbrpB9O_C9dhza8xCHnEiGvyMb6qKYOGLIixmC_HpPqlBZcMVdblOhUyTJMVr9B7RSjDe-gSkJBmyFdEs74rzl5UtF1Adt8Rud_CZ-w9BfcwAlyf2fpQ8iSNu8QH28GFjqdVwxRboxRc-iGVUWtO84OWBCAA","expiry":"2020-03-16T22:59:47.3155208+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: OneDrive (business) id=b!W766y52TE0mQuoUMoV2TyqF4YMVbK_ZNq0E6ySjNJpjfQtqDfSfERKH1MHy1q_wh
Chose drive to use: 0
Found drive 'root' of type 'business', URL: https://anblus-my.sharepoint.com/personal/a_anblus_onmicrosoft_com/Documents
Is that okay?
y) Yes (default)
n) No
y/n y
--------------------
[A5T]
type = onedrive
token = {"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6Im0tSXV2NVdoWEhwcFpZcmNwNWF5RmEwLXFieFJEZVEwRlY1QldpblVTTE0iLCJhbGciOiJSUzI1NiIsIng1dCI6IllNRUxIVDBndmIwbXhvU0RvWWZvbWpxZmpZVSIsImtpZCI6IllNRUxIVDBndmIwbXhvU0RvWWZvbWpxZmpZVSJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDA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PBN8R-z9RphD2gRCb7JdJ1wipSvz6034yCkvjl7Quie68QjH6lwIo1qogJvJvjvSN4YnoueZBOhqlKF12pWYWKZIQ4DmHwmR0axcprPzrgYYzPbUT2_DHiyFQ0VaCeDwGOSpLLrmmN0ECYvwwT5MoT7huW6q8yT5SXK0rp9psjyrwFyMfBsbeaRw3IIE9HTScNzcJ0QYkjIg0dBrr8_KWSv03JKCs5M-a-wOi2t2dgGMTROkxa9OjWR50lbPXZHEcELIbaq3lj-eKwe90duNR1HEus5TKgKTJLIeduWFg-AvElKiCKUBSv-Nqm8zFkJS_LgELVRosW5KnYuDDtV8OFYp_-Adm-_BMjO64tDjIMOMxISEGEXXxeydg5AsCfsgop7sdU52irDeY_wlWoitsg-bOtBtesHNC3GjVQWwtUBwBFHT62QCVCrsq3CcNK5TZjy5ZZQCyQqMnVs05J716cNZ9SsEeQxQhwBC5cCPPhB1g9bzkVp1nn4HbrpB9O_C9dhza8xCHnEiGvyMb6qKYOGLIixmC_HpPqlBZcMVdblOhUyTJMVr9B7RSjDe-gSkJBmyFdEs74rzl5UtF1Adt8Rud_CZ-w9BfcwAlyf2fpQ8iSNu8QH28GFjqdVwxRboxRc-iGVUWtO84OWBCAA","expiry":"2020-03-16T22:59:47.3155208+08:00"}
drive_id = b!W766y52TE0mQuoUMoV2TyqF4YMVbK_ZNq0E6ySjNJpjfQtqDfSfERKH1MHy1q_wh
drive_type = business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d y
Current remotes:

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

挂载Ondrive

新建文件夹(自己定位置,随便):

mkdir -p /home/OneDrive

挂载:

rclone mount Drive:DriveFolder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

Drive为初始化配置填的name,DriveFolder为OneDrive里的文件夹,LocalFolder为挂载的本地文件夹。

如我的Drive:A5T,DriveFolder:/ (挂载总目录),LocalFolder:/home/OneDrive 
rclone mount A5T:/ /home/OneDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 

挂载若提示NOTICE: One drive root 'test': poll-interval is not supported by this remote,可以无视。

挂载成功后,输入df -h查看

卸载:

fusermount -qzu LocalFolder 

 

开始启动:systemctl start rclone

设置开机自启:systemctl enable rclone

重启:systemctl restart rclone

停止:systemctl stop rclone

状态:systemctl status rclone 

 

开机自启

先新建systemd配置文件,再使用命令(注意修改:Drive:DriveFolder LocalFolder)

command="mount Drive:DriveFolder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000"

以下是一整条命令,一复制到SSH运行

cat > /etc/systemd/system/rclone.service <<EOF

[Unit]

Description=Rclone

After=network-online.target

&nbsp;

[Service] Type=simple

ExecStart=$(command -v rclone) ${command}

Restart=on-abort

User=root

&nbsp;

[Install] WantedBy=default.target EOF

如果想挂载多个网盘,那么将systemd配置文件的rclone.service改成rclone1.service即可,重启动什么的同样换成rclone1。

参考原文

   

共有 0 条留言


Top