VPS服务器使用GoogleDrive做硬盘,搭建Emby影视站

1. 搭建Emby服务的需求

自己搭建Emby服务器纯粹是因为蛋疼,其实也没有时间去看剧,成本也很高,不过不是蛋疼,就不要入坑了。

2. 资源准备

3. 安装Rclone,并挂载GoogleDrive作为本地硬盘

Rclone是可将GoogleDrive作为本地硬盘使用的一个工具

3.1 下载并安装Rclone

安装支持库Fuse

  • # Debian/Ubantu
  • apt-get update && apt-get install -y fuse3
  • # CentOS
  • yum install -y fuse3

安装Rclone

  • curl https://rclone.org/install.sh | sudo bash

3.2 配置Rclone与GoogleDrive的连接

  • rclone config

配置过程:

  • Current remotes:
  • Name Type
  • ==== ====
  • 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> n #####选择新增网盘:n
  • name> test #####自定义连接名称
  • .........
  • 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"
  • .........
  • Storage>16 #####选择Google Drive
  • .........
  • nter 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 scope.
  • 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 #####我有GoogleDrive的写权限,所以选1。如果只有读权限,选2。其他选项根据自己的情况进行选择
  • .........
  • Enter a string value. Press Enter for the default ("").
  • root_folder_id> #####选择默认
  • ........
  • Enter a string value. Press Enter for the default ("").
  • service_account_file> #####选择默认
  • Edit advanced config?
  • y) Yes
  • n) No (default)
  • y/n> #####直接回车,选择默认No
  • 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,选择不自动配置<----------重要
  • Option config_verification_code.
  • Verification code
  • Go to this URL, authenticate then paste the code here.
  • ####复制下面连接,在本地浏览器打开,登录Google账户授权,获取验证码
  • https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=202264815644.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=LgVDuFJFSk4GKjj1JF7Wnw
  • Enter a string value. Press Enter for the default ("").
  • config_verification_code>8/1AX4adfadlymaADFcvsF9fHAua23429TTdfa123Lvi9fmiFJRsdfz3g ######填入本地浏览器得到的验证码
  • ###########以上认证步骤的时候很多小伙伴说没有跳出Google验证的网站,只有一个127.0.0.1的验证网站####
  • #####所以这里讲一下方法2,手动Token认证的方式,之前认证通过可跳过该步骤###########
  • 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
  • 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 "drive" "eyJzY29wZSI6121yabcabc0" <----------这条命令记下来
  • #本机安装rlcone,并在命令提示符执行
  • rclone authorize "drive" "eyJzY29wZSI6121yabcabc0"
  • #浏览器认证后会在浏览器提示成功,同时在命令提示符出现一串token
  • Paste the following into your remote machine --->
  • eyJ0b2tTzZIWHZDaDImFjY2Vzc190b2tlblwiOTzZIWHZDaD5hMEFWQTl5MXNvTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDRU96YmVsbmdNTVdqVThpNVEwMTYzXCIsXCJ0b2tlbl90eXBlXCI6XCJCZWFyZXJcIi9ybFExS0tJTzBVSmRIbjBnUXowNHlyT1NIenVIaGNWTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDxTW5fZnJaU0dFVDVxNVNsOU9qSnQ3RE1JQTJZbEdHenRtMVNxYV9oxcInJlZnJlc2hfdG9rZW5cIjpcIjEvLzBlRTZxZ2VFYzVjUEJDZ1lJQVJBQUdBNFNOd0YtTDlJcmRfMVJYU0kwRHl3RXFaTVN2dHFGeUU1Q0VjaW0yOThhSEs4UllPeXU0dnFfX1JhZ1ZoZlR3RmFwVVlwQjliYWoyWEVcIixcImV4cGlyeVwiOlwiMjAyMi0wOS0wNVQxMzozNzozNi4xNDQyOTcrMDg6MDBcIn0ifQ
  • <---End paste #复制两个箭头中间这一段,到服务器上: Then paste the result. Enter a value. config_token>eyJ0b2tTzZIWHZDaDImFjY2Vzc190b2tlblwiOTzZIWHZDaD5hMEFWQTl5MXNvTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDRU96YmVsbmdNTVdqVThpNVEwMTYzXCIsXCJ0b2tlbl90eXBlXCI6XCJCZWFyZXJcIi9ybFExS0tJTzBVSmRIbjBnUXowNHlyT1NIenVIaGNWTzZIWHZDaDTzZIWHZDaDTzZIWHZDaDxTW5fZnJaU0dFVDVxNVNsOU9qSnQ3RE1JQTJZbEdHenRtMVNxYV9oxcInJlZnJlc2hfdG9rZW5cIjpcIjEvLzBlRTZxZ2VFYzVjUEJDZ1lJQVJBQUdBNFNOd0YtTDlJcmRfMVJYU0kwRHl3RXFaTVN2dHFGeUU1Q0VjaW0yOThhSEs4UllPeXU0dnFfX1JhZ1ZoZlR3RmFwVVlwQjliYWoyWEVcIixcImV4cGlyeVwiOlwiMjAyMi0wOS0wNVQxMzozNzozNi4xNDQyOTcrMDg6MDBcIn0ifQ
  • ######方法2本地Token认证的方式结束###########
  • Configure this as a Shared Drive (Team Drive)?
  • y) Yes
  • n) No (default)
  • y/n> y ######如果是个人的盘,填入n回车;如果是团队盘,填入y,我是团队盘,所以填入y
  • Option config_team_drive.
  • Shared Drive
  • Enter a string value. Press Enter for the default ("0CJ1oCe4-dANICk8PcA").
  • Choose a number from below, or type in an existing value.
  • 1 / GSS_A
  • \ "0BA9oUe4XdHNIEA9PVE"
  • 2 / GSS_B
  • \ "0BAG6qwACAHZ4Uk9PVC"
  • 3 / GSS_C
  • \ "0BA0iCZwCDuCqUk9PVD"
  • 4 / TestDrive
  • \ "0BAEYA22XX98QUk9PVA"
  • config_team_drive> 4 ######选择需要连接的团队盘的编号
  • --------------------
  • [test]
  • type = drive
  • scope = drive
  • token = {"access_token":"ysdfsf.A0ARrdaM-qSNdAk-Dsdfsfcxvsfsdfq1WUHFkJ-n9T_rMGEFQhfOkqsfqerUkxsdfsdfEdW3tqoyOEqA0H9xfXjK4_CZqCRy0FnInOELaX0FO5sqkH_oQTdTsY54Q1kzI8PBxz","token_type":"Bearer","refresh_token":"1//0adfv234dYwEcCAAsdfsazcNwF-L9IrTp8HVfda1235tLj8HuKORBE6YCy9mLIaUW6123-3g-Q7g1vE","expiry":"2022-02-16T14:58:15.743003591+08:00"}
  • team_drive = 0BAEYA22XX98QUk9PVA
  • root_folder_id =
  • --------------------
  • y) Yes this is OK (default)
  • e) Edit this remote
  • d) Delete this remote
  • y/e/d> y ######确认上面的配置是否正确
  • Current remotes:
  • Name Type
  • ==== ====
  • test drive ###### Rclone和GoogleDrive的连接配置成功
  • 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挂载的名为test目录的根路径上目录和文件
  • rclone lsf test:/
  • #有输出,表示成功
  • 最新剧集/
  • 最新电影/

 

3.3 将Rclone连接的GoogleDrive挂载为本地盘

3.3.1 本例将test连接到的GoogleDrive,挂载到本机/mnt目录下,创建rclone通用服务。

  • 服务中ExecStart为挂载盘的参数,其中两个目录可以进行修改。其他参数,如不明白建议不动,有时间增加个参数解析
    • /mnt  :Google盘挂载的目录
    • /home/cache:缓存所在的位置
  • cat > /etc/systemd/system/rclone@.service <<EOF
  • [Unit]
  • Description=rclone mount %I drive
  • After=network.target
  • [Service]
  • Type=simple
  • ExecStart=/usr/bin/rclone mount %i: /mnt/%i --use-mmap --umask 000 --default-permissions --no-check-certificate --allow-other --allow-non-empty --dir-cache-time 24h --cache-dir=/home/cache --vfs-cache-mode full --buffer-size 256M --vfs-read-ahead 512M --vfs-read-chunk-size 32M --vfs-read-chunk-size-limit 128M --vfs-cache-max-size 20G --low-level-retries 200 --config /root/.config/rclone/rclone.conf
  • [Install]
  • WantedBy=multi-user.target
  • EOF

3.3.2 给每个连接每个盘创建专属的挂载服务:

  • 参数中可修改挂载的目录,需和上面的rclone通用服务一致
  • /mnt
  • for a in `grep '^\[' /root/.config/rclone/rclone.conf`
  • do
  • b=${a:1:-1}
  • [ ! -d "/mnt/${b}" ] && mkdir /mnt/${b}
  • systemctl enable rclone@${b}
  • systemctl start rclone@${b}
  • done

 

3.3.3 测试,可在服务器/mnt目录下看到test目录,该目录和Google Drive中内容保持一致

  • #查看是否和Google Drive中文件相同:
  • ls /mnt/test

 

 

4. Docker版本Emby的安装

4.1 安装Docker

  • curl -sSL https://get.daocloud.io/docker | sh
  • systemctl start docker
  • systemctl enable docker

4.2 拉取镜像,并启动Emby服务

此处内容需要 回复 后才能查看

THE END
分享
二维码
海报
<<上一篇
下一篇>>