VPS配置rclone+googledrive

安装rclone

  • 像ubuntu16以上,可以直接输入以下指令安装:
    sudo snapd rclone
  • centos可以通过以下指令完成安装:
    curl https://rclone.org/install.sh | sudo bash
  • 配置rclone

  • 安装完后,输入以下指令即可配置:
    rclone config
  • 
     # rclone config
    2018/11/25 09:31:54 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
    name> codesofun
    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 / A stackable unification remote, which can appear to merge the contents of several remotes
       \ "union"
     2 / Alias for a existing remote
       \ "alias"
     3 / Amazon Drive
       \ "amazon cloud drive"
     4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
       \ "s3"
     5 / Backblaze B2
       \ "b2"
     6 / Box
       \ "box"
     7 / Cache a remote
       \ "cache"
     8 / Dropbox
       \ "dropbox"
     9 / Encrypt/Decrypt a remote
       \ "crypt"
    10 / FTP Connection
       \ "ftp"
    11 / Google Cloud Storage (this is not Google Drive)
       \ "google cloud storage"
    12 / Google Drive
       \ "drive"
    13 / Hubic
       \ "hubic"
    14 / JottaCloud
       \ "jottacloud"
    15 / Local Disk
       \ "local"
    16 / Mega
       \ "mega"
    17 / Microsoft Azure Blob Storage
       \ "azureblob"
    18 / Microsoft OneDrive
       \ "onedrive"
    19 / OpenDrive
       \ "opendrive"
    20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
       \ "swift"
    21 / Pcloud
       \ "pcloud"
    22 / QingCloud Object Storage
       \ "qingstor"
    23 / SSH/SFTP Connection
       \ "sftp"
    24 / Webdav
       \ "webdav"
    25 / Yandex Disk
       \ "yandex"
    26 / http Connection
       \ "http"
    Storage> 12
    ** See help for drive backend at: https://rclone.org/drive/ **
    
    Google Application Client Id
    Leave blank normally.
    Enter a string value. Press Enter for the default ("").
    client_id>
    Google Application 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
    ID of the root folder
    Leave blank normally.
    Fill in to access "Computers" folders. (see docs).
    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.
    Enter a string value. Press Enter for the default ("").
    service_account_file>
    Edit advanced config? (y/n)
    y) Yes
    n) No
    y/n> n
    Remote config
    Use auto config?
     * Say Y if not sure
     * Say N if you are working on a remote or headless machine or Y didn't work
    y) Yes
    n) No
    y/n> n
    If your browser doesn't open automatically go to the following link: 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=0fbdd**********************05a3b00e23
    Log in and authorize rclone for access
    Enter verification code> 4/owSACseTxM*************c2HtEVX_yEhBcr--JiFTA7-Pfg
    
    Configure this as a team drive?
    y) Yes
    n) No
    y/n> y
    Fetching team drive list...
    No team drives found in your account--------------------
    [codesofun]
    type = drive
    scope = drive
    token = {"access_token":"ya29.GltfBn_YA8e0lgJNKeMAHZ3b_IeIBXHHrJxMO7wfW0AsY6v_Nso8YczhZafVe8UIIgK6ft1dn6BqP-UWp-W2YXBtcf6zbLuIZgKcPqwnhsVAkx3f7QcO5m0EUvAv","token_type":"Bearer","refresh_token":"1/hFSVnEeJ8CkFmrpdd7IGNx69mhkj8Cpny6JUktv3xcY","expiry":"2018-11-25T10:42:09.400295503Z"}
    --------------------
    y) Yes this is OK
    e) Edit this remote
    d) Delete this remote
    y/e/d> y
    Current remotes:
    
    Name                 Type
    ====                 ====
    codesofun            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
    
  • 完成后挂在磁盘,新建文件夹:
    mkdir -p /data/GoogleDrive
  • 挂载为磁盘:
    格式为[name]:[google drive dir] [mount dir]

    [name]就是配置文件是输入的name,例如我的就是ct

    [google drive dir] 这个是谷歌云盘的目录,根目录的花直接空开就可以了

    [mount dir]就是本地挂载位置,/data/GoogleDrive
  • Fatal error: failed to mount FUSE fs: fusermount: exec: “fusermount”: executable file not found in $PATH 没有安装 fuse ,自行安装就可以了
    yum -y install fuse
  • 完成设置

  • 查看效果
    df -h
  • 设置开机自动挂载
    wget https://blog.codesofun.com/scripts/rcloned && vim rcloned
    然后修改文件内如下内容

    NAME=”” #[name]

    REMOTE=” #[google drive dir]

    LOCAL=” #[mount dir]
  • 设置开机启动
    mv rcloned /etc/init.d/rcloned
    REMOTE=” #[google drive dir]

    chmod +x /etc/init.d/rcloned

    vim /etc/rc.d/rc.local #在末尾加入 bash /etc/init.d/rcloned start

    chmod +x /etc/rc.d/rc.local

    bash /etc/init.d/rcloned status
  • 这个时候可以测试了
    cd /data/GoogleDrive
    touch codesofun.txt
  • 至于aria+rclone的配合使用暂时未实现,不过我都是参照以下原网站尝试的:https://blog.codesofun.com/ariang-rclone-for-google-drive-offline-download

    留下评论

    您的电子邮箱地址不会被公开。 必填项已用*标注