【VPS折腾记】nextcloud——扩展功能之挂载onedrive(三)

普通VPS的硬盘容量作为网盘还远远不足,因此我比较喜欢在个人服务器上挂载Onedrive的E5开发者版来作为网盘使用(国际版的onedrive也不会和谐某些资源,很舒服)

  1. 先在应用处搜索,External storage support进行安装
  2. 宝塔应用商店->PHP->安装扩展 处,安装smbclient扩展
  3. SSH登录你的VPS,安装Rclone官方脚本 curl https://rclone.org/install.sh | bash
  4. 在你自己的windows电脑上,访问https://rclone.org/downloads/,下载rclone windows版。
  5. 在解压出来的目录下,运行命令行,并输入rclone authorize "onedrive",登录你的开发者/教育版微软账户,登录成功后回到命令行,复制输出内容,并保存。
  6. https://portal.azure.com/
    页面登录你的开发者/教育版微软账户,并在上方搜索栏搜索 应用注册
    进入,并选择 新注册
    • 名称 随意填写

    • 账户类型选择 任何组织目录(任何 Azure AD 目录 - 多租户)中的帐户和个人 Microsoft帐户(例如,Skype、Xbox)

    • 重定向 URI 平台选择 Web ,URI 回到你的nextcloud页面,确保当前页面为外部存储的插件页面,复制当前网页地址并填入

    • 点击注册

  7. 复制 Onedrive页面->概述->应用程序(客户端) ID 并保存
  8. 进入 证书和密码 页面,选择 新客户端密码,截止期限建议自定义两年时间(两年为最长),复制 并保存
  9. 进入 应用权限 页面,选择 添加权限->Microsoft Graph->委托的权限,并在搜索处搜索并勾选 User.Read | Files.ReadWrite.All | offline_access 三个权限,点击添加
  10. 回到SSH,输入 rclone config 进行配置,配置有点长,不作解释,自行观看
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> onedrive
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
 1 / 1Fichier
   \ (fichier)
 2 / Akamai NetStorage
   \ (netstorage)
 3 / Alias for an existing remote
   \ (alias)
 4 / Amazon Drive
   \ (amazon cloud drive)
 5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, China Mobile, Digital Ocean, Dreamhost, IBM COS, Lyve Cloud, Minio, Netease, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Tencent COS and Wasabi
   \ (s3)
 6 / Backblaze B2
   \ (b2)
 7 / Better checksums for other remotes
   \ (hasher)
 8 / Box
   \ (box)
 9 / Cache a remote
   \ (cache)
10 / Citrix Sharefile
   \ (sharefile)
11 / Compress a remote
   \ (compress)
12 / Dropbox
   \ (dropbox)
13 / Encrypt/Decrypt a remote
   \ (crypt)
14 / Enterprise File Fabric
   \ (filefabric)
15 / FTP Connection
   \ (ftp)
16 / Google Cloud Storage (this is not Google Drive)
   \ (google cloud storage)
17 / Google Drive
   \ (drive)
18 / Google Photos
   \ (google photos)
19 / Hadoop distributed file system
   \ (hdfs)
20 / Hubic
   \ (hubic)
21 / In memory object storage system.
   \ (memory)
22 / Jottacloud
   \ (jottacloud)
23 / Koofr, Digi Storage and other Koofr-compatible storage providers
   \ (koofr)
24 / Local Disk
   \ (local)
25 / Mail.ru Cloud
   \ (mailru)
26 / Mega
   \ (mega)
27 / Microsoft Azure Blob Storage
   \ (azureblob)
28 / Microsoft OneDrive
   \ (onedrive)
29 / OpenDrive
   \ (opendrive)
30 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ (swift)
31 / Pcloud
   \ (pcloud)
32 / Put.io
   \ (putio)
33 / QingCloud Object Storage
   \ (qingstor)
34 / SSH/SFTP Connection
   \ (sftp)
35 / Sia Decentralized Cloud
   \ (sia)
36 / Storj Decentralized Cloud Storage
   \ (storj)
37 / Sugarsync
   \ (sugarsync)
38 / Transparently chunk/split large files
   \ (chunker)
39 / Union merges the contents of several upstream fs
   \ (union)
40 / Uptobox
   \ (uptobox)
41 / Webdav
   \ (webdav)
42 / Yandex Disk
   \ (yandex)
43 / Zoho
   \ (zoho)
44 / http Connection
   \ (http)
45 / premiumize.me
   \ (premiumizeme)
46 / seafile
   \ (seafile)
Storage> 28
Option client_id.
OAuth Client Id.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_id> 之前保存的应用程序ID
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret> 之前保存的密码值
Option region.
Choose national cloud region for OneDrive.
Choose a number from below, or type in your own string value.
Press Enter for the default (global).
 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
Edit advanced config?
y) Yes
n) No (default)
y/n> 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" "eyJjbGllbnRfaWQiOiIzODMxM2QzYS1lOTk5LTRlMjYtOTQ5Mi0wYjE0ZmJhYjg2NGYiLCJjbGllbnRfc2VjcmV0IjoieGZJOFF+elVhbVFQRHd4Qm10eko4aGhaSGc1LTFNYjRrakFKdmRnQSJ9"
Then paste the result.
Enter a value.
config_token> 刚刚保存的token
Option config_type.
Type of connection
Choose a number from below, or type in an existing string value.
Press Enter for the default (onedrive).
 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://pantwooosix-my.sharepoint.com/personal/twosix_pantwooosix_onmicrosoft_com/Documents

y) Yes (default)
n) No
y/n> y
--------------------
[onedrive]
type = onedrive
client_id = ***
client_secret = ***
token = ***
drive_id = ***
drive_type = business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>
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

  1. 输入 rclone mount onedrive:/nextcloud /data/lius1999 --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --vfs-cache-mode writes --umask 000 ,若无报错则挂载成功(会卡住),此时ctrl+c返回。
  2. 设置开机自启动
command="刚才挂载的命令"
cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
After=network-online.target
 
[Service]
Type=simple
ExecStart=${command}
Restart=on-abort
User=root
 
[Install]
WantedBy=default.target
EOF

再输入

systemctl enable rclone.service
systemctl start rclone.service

此时输入 df -h即可查看是否挂载成功。

  1. 回到nextcloud页面,选择外部存储,挂载本地,并在配置里填入你挂载的本地目录即可。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值