15
12月
2021
系统版本:CentOS 8.5.2111
前期准备
需要先在windows上,通过网页授权获取token。
在本地Windows电脑上下载rclone,下载地址:https://rclone.org/downloads/ 。然后解压出来,进入cmd,输入以下命令:rclone authorize "onedrive"
然后后自动弹出浏览器窗口认证,输入账号密码登录,授权成功后会获得token。复制整个json数据,格式大概是这样:{"access_token":"eyJ0eXAitgXtw","token_type":"Bearer","refresh_token":"0.AVMA14KfZ2p8GKjs094i","expiry":"2021-12-15T16:29:15.1575606+08:00"}
安装rclonecurl https://rclone.org/install.sh | sudo bash
输入命令进行配置:rclone config
[root@VM82 ~]# rclone config
2021/12/15 15:24:46 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 # 输入n
name> onedrive
Option Storage.
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 Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, SeaweedFS, and Tencent COS
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Better checksums for other remotes
\ "hasher"
7 / Box
\ "box"
8 / Cache a remote
\ "cache"
9 / Citrix Sharefile
\ "sharefile"
10 / Compress a remote
\ "compress"
11 / Dropbox
\ "dropbox"
12 / Encrypt/Decrypt a remote
\ "crypt"
13 / Enterprise File Fabric
\ "filefabric"
14 / FTP Connection
\ "ftp"
15 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
16 / Google Drive
\ "drive"
17 / Google Photos
\ "google photos"
18 / Hadoop distributed file system
\ "hdfs"
19 / Hubic
\ "hubic"
20 / In memory object storage system.
\ "memory"
21 / Jottacloud
\ "jottacloud"
22 / Koofr
\ "koofr"
23 / Local Disk
\ "local"
24 / Mail.ru Cloud
\ "mailru"
25 / Mega
\ "mega"
26 / Microsoft Azure Blob Storage
\ "azureblob"
27 / Microsoft OneDrive
\ "onedrive"
28 / OpenDrive
\ "opendrive"
29 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
30 / Pcloud
\ "pcloud"
31 / Put.io
\ "putio"
32 / QingCloud Object Storage
\ "qingstor"
33 / SSH/SFTP Connection
\ "sftp"
34 / Sia Decentralized Cloud
\ "sia"
35 / Sugarsync
\ "sugarsync"
36 / Tardigrade Decentralized Cloud Storage
\ "tardigrade"
37 / Transparently chunk/split large files
\ "chunker"
38 / Union merges the contents of several upstream fs
\ "union"
39 / Uptobox
\ "uptobox"
40 / Webdav
\ "webdav"
41 / Yandex Disk
\ "yandex"
42 / Zoho
\ "zoho"
43 / http Connection
\ "http"
44 / premiumize.me
\ "premiumizeme"
45 / seafile
\ "seafile"
Storage> 27 # 选择oneDrive对应的序号
Option client_id.
OAuth Client Id.
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
Option region.
Choose national cloud region for OneDrive.
Enter a string value. Press Enter for the default ("global").
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> 1 # 选1,全球版
Edit advanced config?
y) Yes
n) No (default)
y/n>
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
Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
rclone authorize "onedrive"
Then paste the result.
Enter a string value. Press Enter for the default ("").
config_token> # 粘贴windows下复制的token信息 {"access_token":"eyJ0eXAiOiJKV1QiLL5muKSVBSYbtgXtw","token_type":"Bearer","refresh_token":"0.AVMA14KfZ41ax0a1qBDnSYHDizSlH32p48GKjs094i","expiry":"2021-12-15T16:29:15.1575606+08:00"}
Option config_type.
Type of connection
Enter a string value. Press Enter for the default ("onedrive").
Choose a number from below, or type in an existing value.
1 / OneDrive Personal or Business
\ "onedrive"
2 / Root Sharepoint site
\ "sharepoint"
/ Sharepoint site name or URL
3 | 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"
/ Sharepoint server-relative path (advanced)
7 | E.g. /teams/hr
\ "path"
config_type> 1
Drive OK?
Found drive "root" of type "business"
URL: https://lscy-my.sharepoint.com/personal/photos_msdn_ayuns_com/Documents
y) Yes (default)
n) No
y/n> y
--------------------
[onedrive]
type = onedrive
token = {"access_token":"eyJ0eXAiO5muKSVBSYbtgXtw","token_type":"Bearer","refresh_token":"0.AVMA14KfZ41YEj4P48GKjs094i","expiry":"2021-12-15T16:29:15.1575606+08:00"}
drive_id = b!M4fIDYMFTku8ypfx8yaMayLhOczdFA5IhkF24qgvSWTyb2gXJzhPT7E96WDnrfLl
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
==== ====
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
至此,安装完成了。
挂载
挂载网盘并设置开机启动
下载脚本并编辑wget -N git.io/rcloned && vi rcloned
需修改一下内容:
NAME="onedrive" # rclone name名,也就是上面第一步配置时输入的名称
REMOTE='Test' # 远程onedrive的文件夹,留空为整个网盘
LOCAL='/mnt/OneDrive' # 本地挂载地址
设置开机启动:
mv rcloned /etc/init.d/rcloned
chmod +x /etc/init.d/rcloned
update-rc.d -f rcloned defaults # Debian/Ubuntu
chkconfig rcloned on # CentOS
bash /etc/init.d/rcloned start
查看挂载情况:df -Th
非特殊说明,本文版权归 作者 所有,转载请注明出处.