Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。
安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
PS D:\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> mediy 🚩这里输入新建远程的名称
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 🚩我这里创建的是OneDrive,所以选择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> 🚩这里输入你创建的应用密钥key,输入完成回车确认
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> 4 🚩这里选OneDrive所属区域,因为我用的世纪互联就选的4,你们是国际就选1,然后回车确认
Edit advanced config?
y) Yes
n) No (default)
y/n> 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> y 🚩🚩🚩这一步很重要,选择y,下面将会出现授权验证的url链接,并且自动跳转浏览器配置,你点授权就行了。
2022/06/03 23:50:28 NOTICE: Make sure your Redirect URL is set to "http://localhost:53682/" in your custom config.
2022/06/03 23:50:28 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=MQc-xMiPSiLZZLbPwdP__g
2022/06/03 23:50:28 NOTICE: Log in and authorize rclone for access
2022/06/03 23:50:28 NOTICE: Waiting for code...
2022/06/03 23:50:29 NOTICE: Got code
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> 2 🚩这里我添加的是sharepoint所以选2,你们添加OneDrive就选1
Drive OK?
Found drive "root" of type "documentLibrary"
URL: https://miaowu.sharepoint.cn/Shared%20Documents
y) Yes (default)
n) No
y/n> y 🚩这里选择y,确认连接
[mediyOD]
type = onedrive
client_id = 67281d27-d9e7-43c5-988b-f2be83a0781d
client_secret = L_Ck2f-WOeq-M23a8wmm2Y0rmTQ.4_-Mro
region = cn
token = {🚩🚩🚩这里面的连同外面两个大括号就是你的token}
drive_id = b!80FBvI7Eb0-hwVMIABJrhXqKHTjHR4RNsef6js-wZfDLG-76G9U6TabuhsK4y4n3
drive_type = documentLibrary
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y 🚩这里选择y,出现下面的内容就表示连接成功。
Current remotes:
Name Type
==== ====
mediyOD 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直接退出
第三步,在服务器上安装rclone,点我下载
开始在服务器上安装rclone,我用的是ubuntu,使用SSH链接到您的服务器
SSH安装:wget https://www.moerats.com/usr/shell/rclone_debian.sh && bash rclone_debian.sh
宝塔以上传zip压缩形式安装:
cd 进入您的目录。
> sudo cp rclone /usr/bin/
> sudo chown root:root /usr/bin/rclone
> sudo chmod 755 /usr/bin/rclone
> sudo mkdir -p /usr/local/share/man/man1
> sudo cp rclone.1 /usr/local/share/man/man1/
> sudo mandb
卸载命令
> rm /usr/bin/rclone
> sudo rm /usr/bin/rclone
> apt-get remove rclone
> fusermount -qzu /root/mm
安装完成后开始运行配置: rclone config
这里的步骤和上面一样,但是在🚩
获取授权验证的那一步的时候选择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 🚩🚩🚩这里选择n,把上面获取到的token填进去回车确认
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" "eyJjbGllbnRfaWQiOiI2NzI4MWQyNy1kOWU3LTQzYzUtOTg4Yi1mMmJlODNhMDc4MWQiLCJjbGllbnRfc2VjcmV0IjoiTF9DazJmLVdPZXEtTTIzYTh3bW0yWTBybVRRLjRfLU1ybyIsInJlZ2lvbiI6ImNuIn0"
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> 2 🚩这里连接类型选择sharepoint,你们是OneDrive就选1
Drive OK?
Found drive "root" of type "documentLibrary"
URL: https://miaowu.sharepoint.cn/Shared%20Documents
y) Yes (default)
n) No
y/n> y 🚩这里选择y,确认回车
--------------------
[mediy12]
type = onedrive
client_id = 67281d27-d9e7-43c5-988b-f2be83a0781d
client_secret = L_Ck2f-WOeq-M23a8wmm2Y0rmTQ.4_-Mro
region = cn
token = {这里会显示新的token,有需要的话可以保存下来}
drive_id = b!80FBvI7Eb0-hwVMIABJrhXqKHTjH
drive_type = documentLibrary
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y 🚩这里选y,一切都OK
Current remotes:
Name Type
==== ====
mediy-sharepoint 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,创建本地挂载目录,以下路径可以自己更改
mkdir -p /home/sharepoint
2,挂载:aaa为创建的名称,bbb为远程文件目录,不填为就是根目录。ccc是本地目录位置
下面的都要改成你自己的:
rclone mount aaa:/bbb /ccc/ccc --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --vfs-cache-mode writes
如果在挂载的时候出现了类似下面的错误提示:
Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH
需要安装 fuse。
CentOS/Fedora 安装 fuse:
yum install -y fuse
Ubuntu/Debian 安装 fuse:
apt install -y fuse
3,查看挂载是否成功:
df -h
4,卸载挂载盘(路径都要改成自己的)
fusermount -qzu /ccc/ccc
卸载所有盘
fusermount -qzu /root/mm
5,🚩
多个网盘全自动挂载,在/etc/systemd/system目录内创建名为rclone@.service的文件,添加如下内容
[Unit]
Description=Rclone mount %I drive
AssertPathIsDirectory=LocalFolder
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/rclone mount %i: /%i \
--config /root/.config/rclone/rclone.conf \
--copy-links \
--no-gzip-encoding \
--no-check-certificate \
--vfs-cache-mode full \
--umask 0000 \
--default-permissions \
--allow-non-empty \
--allow-other \
--attr-timeout 5m \
--vfs-cache-max-size 1G \
--buffer-size 500M \
--vfs-read-chunk-size 64M \
--vfs-read-chunk-size-limit 1G
ExecStop=/bin/fusermount -u LocalFolder
Restart=on-abort
User=root
[Install]
WantedBy=default.target
6,🚩
设置开机自启动,自动挂载
systemctl enable rclone
systemctl start rclone
如果有新添加的网盘,重启服务后没有成功挂载的。用如下命令手动启动一次即可,Odrive_233为新盘名称
mkdir /root/Odrive_233
systemctl enable rclone@Odrive_233
systemctl start rclone@Odrive_233
开机自启 - 宝塔用户
Supervisor管理器,设定为/根目录,Root,启动命令就是上面的启动命令,实例如下:
rclone mount cnsp1:/ /www/wwwroot/sharepoint --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --vfs-cache-mode writes
服务器开启BBR加速内核,添加到 /etc/sysctl.conf
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
执行sysctl -p
生效
lsmod | grep bbr
*
—
同步大量数据使用 screen 会话尽可能保护 rclone 执行不被中断
yum install screen
screen -S rclone
开机自启:systemctl enable rclone
立即启动:systemctl start rclone
立即重启:systemctl restart rclone
立即停止:systemctl stop rclone
查看状态:systemctl status rclone
卸载程序1:apt-get remove rclone
卸载程序2:rm /usr/bin/rclone
卸载程序3:sudo rm /usr/bin/rclone
rclone copy
– 复制示例🚩rclone copy cnsp1:/alist/Movie sgsp1:/alist/Movie
需要复制和同步的路径不能包含特殊字符和空格,否则无法启动任务
rclone copy 源:/路径/路径 目的地:/路径/路径
rclone sync
– 同步 将目录内容同步到网盘目录
rclone move
– 移动 将目录内文件移动到网盘,默认删除路径文件
rclone purge
– 删除路径及所有文件
rclone delete
– 删除路径所有文件但不删除路径
rclone mkdir
– 创建目录
rclone rmdir
– 删除目录
rclone check
– 检查目标文件与源文件是否匹配
rclone ls
– 列出指定路径下的所有的文件以及文件大小
rclone lsl
– 仅列出对象的修改时间,大小和路径
rclone lsd
– 仅列出目录
rcloen lsf
– 以易于解析的格式列出对象和目录
rcloen lsjson
– 以JSON格式列出对象和目录
rclone lsd
– 列出路径下的所有目录
rclone size
– 打印目录中对象的总大小和数量
rclone mount
– 将远程文件路径挂载到本地路径
第五步,为挂载盘添加emby媒体程序,提供远程音视频服务。
官网:https://emby.media/download.html
我的服务器系统是Ubuntu X64
下载emby-server-deb_4.7.2.0_amd64.deb并上传到你服务器的某个目录
cd /你刚才上传的目录/
dpkg -i emby-server-deb_4.7.2.0_amd64.deb
服务器放行8096端口,使用ip:8096访问,您也可以反代至域名。
然后在emby的后台设置,加载你挂载的OneDrive
使用emby播放挂载盘里面的视频资源受限于你的服务器宽带。不知道还有其他办法没。