Unraid上rclone插件的使用

友情提示 页面过长 请善用右侧目录

安装rclone插件

应用中搜素rclone
选择这个插件安装,其他两个为docker
安装完成后会出现在设置-用户实用程序

连接网盘

谷歌团队盘

终端中输入rclone config

No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n

选择n新建

name> googleemby

建立个名称

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, and Tencent COS
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Citrix Sharefile
   \ "sharefile"
 9 / Compress a remote
   \ "compress"
10 / Dropbox
   \ "dropbox"
11 / Encrypt/Decrypt a remote
   \ "crypt"
12 / Enterprise File Fabric
   \ "filefabric"
13 / FTP Connection
   \ "ftp"
14 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
15 / Google Drive
   \ "drive"
16 / Google Photos
   \ "google photos"
17 / Hadoop distributed file system
   \ "hdfs"
18 / Hubic
   \ "hubic"
19 / In memory object storage system.
   \ "memory"
20 / Jottacloud
   \ "jottacloud"
21 / Koofr
   \ "koofr"
22 / Local Disk
   \ "local"
23 / Mail.ru Cloud
   \ "mailru"
24 / Mega
   \ "mega"
25 / Microsoft Azure Blob Storage
   \ "azureblob"
26 / Microsoft OneDrive
   \ "onedrive"
27 / OpenDrive
   \ "opendrive"
28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
29 / Pcloud
   \ "pcloud"
30 / Put.io
   \ "putio"
31 / QingCloud Object Storage
   \ "qingstor"
32 / SSH/SFTP Connection
   \ "sftp"
33 / Sugarsync
   \ "sugarsync"
34 / Tardigrade Decentralized Cloud Storage
   \ "tardigrade"
35 / Transparently chunk/split large files
   \ "chunker"
36 / Union merges the contents of several upstream fs
   \ "union"
37 / Webdav
   \ "webdav"
38 / Yandex Disk
   \ "yandex"
39 / Zoho
   \ "zoho"
40 / http Connection
   \ "http"
41 / premiumize.me
   \ "premiumizeme"
42 / seafile
   \ "seafile"
Storage> 15

如要连接谷歌的盘,根据标识选择15(版本不同,序号不一定一样,按实际标识选择)

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

Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id> 

不输入,直接回车

OAuth 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> 1

选择1

ID of the root folder
Leave blank normally.

Fill in to access "Computers" folders (see docs), or for rclone to use
a non root folder as its starting point.

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.

Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.

Enter a string value. Press Enter for the default ("").
service_account_file> 

不输入,直接回车

Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> 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

选择n,因为unraid没有浏览器,所以我们需要手动获取code

Please go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=2022***s.googleusercontent.com&redirect_uri=urn%3Aietf%3Aw***************************gleapis.com%2Fau***ive&state=1Tc3s8imv7v7yK6y//SBg

电脑上打开连接,登陆账户,授权给rclone使用,复制显示的code

Log in and authorize rclone for access
Enter verification code> 4/1AY0e-g64_jCl62pm7Y1oLDE****wyWKvlIY8VlBxdvhdZoFNes

粘贴code回车

Configure this as a Shared Drive (Team Drive)?
y) Yes
n) No (default)
y/n> y

询问是否是团队盘,因为我需要挂载的是团队盘,所以选y

Fetching Shared Drive list...
Choose a number from below, or type in your own value
 1 / 诺亚方舟3
   \ "0AOLCuxbrocW***9PVA"
 2 / 神秘礼物影视
   \ "0AFKcdHXz9s60U***VA"
 3 / emby
   \ "0AA0yqh7***JEUk9PVA"
 4 / G Drive
   \ "0AGv7GHb8S75***PVA"
Enter a Shared Drive ID> 3

罗列出账户上有的团队盘,我需要挂载第3个,所以输入3回车

--------------------
[googleemby]
type = drive
scope = drive
token = {"access_token":"y******************************************************************************08:00"}
team_drive = 0AA0yqh7N2ZJE***A
root_folder_id = 
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

显示相关config信息,提示你是否确认
输入y

Name                 Type
====                 ====
googleemby           drive

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

q退出配置界面
到此网盘已经成功连接到rclone

微软网盘

因Unraid没有浏览器
所以rclone无法直接获取code来连接网盘
我们采用这种的方式来,在windows上获取config内容
下载个客户端
假设解压到c盘根目录

C:\Users\Administrator>cd c:\rclone

切换到解压目录

c:\rclone>rclone config

开始配置

No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n

选择n新建

name> onedrive

建立个名称

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, and Tencent COS
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Citrix Sharefile
   \ "sharefile"
 9 / Compress a remote
   \ "compress"
10 / Dropbox
   \ "dropbox"
11 / Encrypt/Decrypt a remote
   \ "crypt"
12 / Enterprise File Fabric
   \ "filefabric"
13 / FTP Connection
   \ "ftp"
14 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
15 / Google Drive
   \ "drive"
16 / Google Photos
   \ "google photos"
17 / Hadoop distributed file system
   \ "hdfs"
18 / Hubic
   \ "hubic"
19 / In memory object storage system.
   \ "memory"
20 / Jottacloud
   \ "jottacloud"
21 / Koofr
   \ "koofr"
22 / Local Disk
   \ "local"
23 / Mail.ru Cloud
   \ "mailru"
24 / Mega
   \ "mega"
25 / Microsoft Azure Blob Storage
   \ "azureblob"
26 / Microsoft OneDrive
   \ "onedrive"
27 / OpenDrive
   \ "opendrive"
28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
29 / Pcloud
   \ "pcloud"
30 / Put.io
   \ "putio"
31 / QingCloud Object Storage
   \ "qingstor"
32 / SSH/SFTP Connection
   \ "sftp"
33 / Sugarsync
   \ "sugarsync"
34 / Tardigrade Decentralized Cloud Storage
   \ "tardigrade"
35 / Transparently chunk/split large files
   \ "chunker"
36 / Union merges the contents of several upstream fs
   \ "union"
37 / Webdav
   \ "webdav"
38 / Yandex Disk
   \ "yandex"
39 / Zoho
   \ "zoho"
40 / http Connection
   \ "http"
41 / premiumize.me
   \ "premiumizeme"
42 / seafile
   \ "seafile"
Storage> 26

如要连接谷歌的盘,根据标识选择26(版本不同,序号不一定一样,按实际标识选择)

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

OAuth Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>

不输入,直接回车

OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>

不输入,直接回车

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/n)
y) Yes
n) No (default)
y/n> 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> y

选择1自动配置

If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=FDOLLiSz***rSJBbag
Log in and authorize rclone for access
Waiting for code...
Got code

点击链接,登陆账户,授权给rclone使用,脚本自动获取code

Choose a number from below, or type in an existing value
 1 / OneDrive Personal or Business
   \ "onedrive"
 2 / Root Sharepoint site
   \ "sharepoint"
 3 / Sharepoint site name or URL (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"
 7 / Sharepoint server-relative path (advanced, e.g. /teams/hr)
   \ "path"
Your choice> 1

选择1

Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!jC7ndQM3XkO5C6RFjk8FC0l6JPipknpLuC4BB4ohz64u3aY5OQn_T4Vh-Rr-ZaZD
Chose drive to use:> 0

选择标识的0网盘

Found drive 'root' of type 'business', URL: https://kogfw***.sharepoint.com/personal/s1oz_****/Documents
Is that okay?
y) Yes (default)
n) No
y/n> y

选择y

--------------------
[onedrive]
type = onedrive
region = global
token = {"access_token":"eyJ0eXAiLiIs**gU2l0ZXMuUmVhZC5BbGwgcHJvZmlsZSMastoKDtaM8uxbH-ypRGI0y8H_ysiRw20QRRLc7pdol6BmYo0BcRNXJgJN6xccP5b20-iyLejE_vF1Iw5AKQP4-qirH3NHP-S5l*********pLuC4BB4ohz64u3aY5OQn_T4Vh-Rr-ZaZD
drive_type = business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y

显示相关config信息,提示你是否确认
输入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

按q退出配置界面
将刚显示的这段config信息粘贴到rclone插件中

--------------------
[onedrive]
type = onedrive
region = global
token = {"access_token":"eyJ0eXAiLiIs**gU2l0ZXMuUmVhZC5BbGwgcHJvZmlsZSMastoKDtaM8uxbH-ypRGI0y8H_ysiRw20QRRLc7pdol6BmYo0BcRNXJgJN6xccP5b20-iyLejE_vF1Iw5AKQP4-qirH3NHP-S5l*********pLuC4BB4ohz64u3aY5OQn_T4Vh-Rr-ZaZD
drive_type = business

粘贴至Unraid设置-用户实用程序-rclcone

然后在Unraid终端中输入

rclone config

即可看到已经连接的网盘信息

创建用于挂载磁盘的目录

根据自己需求,新建一个用于挂载网盘的空文件夹

mkdir -p /mnt/user/rclone/onedrive

我想分的细一点,所以等下使用`onedrive空文件夹挂载刚刚连接的谷歌团队盘

挂载网盘到本地

示例

rclone mount onedrive:test /mnt/user/rclone/onedrive --use-mmap --umask 0000 --default-permissions --allow-non-empty --allow-other --buffer-size 1G --low-level-retries 10 --vfs-read-chunk-size 64M --vfs-read-chunk-size-limit 1G --vfs-cache-mode off --checkers=8 --transfers=4 --rc &

需要修改的就是
onedrive:test onedrive为网盘的名字不特指微软网盘test为要挂载的网盘文件夹路径,不填留为挂载整个网盘
/mnt/user/rclone/onedrive本地用于挂载的空目录
关于其他参数含义,可自行查阅最下方命令说明
如emby之类添加挂载文件夹不显示文
请在emby终端输入 umask

/ # umask
0022
/ # 

将示例中--umask 0000修改为--umask 0022emby即可正常访问文件

查询是否成功将网盘挂载到本地

df -h

输入命令后,如成功挂载,就会有显示挂载的目录了

shell脚本

可使用User Scripts插件新建开机任务,例如我的脚本如下

开机挂载

我内存反正过剩,直接不要缓存,按需修改OPTIONS中的内容

#!/bin/bash
# 设置变量
MOUNT_POINT="/mnt/user/rclone/onedrive"    # 挂载点目录
REMOTE_NAME="onedrive"          # rclone 配置的服务商名称
REMOTE_PATH=""              # 实际的远程路径
OPTIONS="--use-mmap --umask 0000 --default-permissions --allow-non-empty --allow-other --buffer-size 1G --low-level-retries 10 --vfs-read-chunk-size 64M --vfs-read-chunk-size-limit 1G --vfs-cache-mode off --checkers=8 --transfers=4 --rc"  # rclone 挂载选项


# 创建挂载点目录,如果不存在
if [ ! -d "$MOUNT_POINT" ]; then
    mkdir -p "$MOUNT_POINT"
fi

# 执行 rclone 挂载命令
rclone mount "$REMOTE_NAME:$REMOTE_PATH" "$MOUNT_POINT" $OPTIONS &

# 获取挂载进程的PID
MOUNT_PID=$!

# 等待一段时间,确保挂载完成
sleep 10

# 检查挂载是否成功
if mountpoint -q "$MOUNT_POINT"; then
    echo "挂载成功!"
else
    echo "挂载失败!"
    exit 1
fi

# 显示挂载状态
df -h | grep "$MOUNT_POINT"

# 提示挂载完毕
echo "挂载完毕"

停止阵列卸载

#!/bin/bash

# 设置挂载点目录
MOUNT_POINT="/mnt/user/rclone/onedrive"

# 检查挂载点是否存在并卸载
if mountpoint -q "$MOUNT_POINT"; then
    fusermount -zu "$MOUNT_POINT"
    if ! mountpoint -q "$MOUNT_POINT"; then
        echo "卸载成功!"
    else
        echo "卸载失败!"
        exit 1
    fi
else
    echo "挂载点未挂载。"
fi

常用命令

https://rclone.org/commands/

官方的命令说明

onedrvie私有API

创建私有api所需勾选的权限