zoukankan      html  css  js  c++  java
  • Ubuntu 18.04 安装OneDrive自动同步

    Ubuntu 18.04 安装OneDrive自动同步

    Windows10系统已经自带了OneDrive的自动同步功能,对于多设备用户而言已经成为了一个非常方便传输保存文件的途径,在Ubuntu下也有办法做到几乎一样的自动同步功能。

    项目GitHub地址:https://github.com/skilion/onedrive

    原文(有删改):https://zhuanlan.zhihu.com/p/105522169

    安装依赖

    需要安装的依赖有libcurlsqlite3DMD

    使用Ctrl+Alt+T等方式打开终端,执行以下命令:

    sudo apt install -y libcurl4-openssl-dev libsqlite3-dev git make
    sudo snap install --classic dmd && sudo snap install --classic dub
    

    安装OneDrive

    由于作者没有给出二进制发行版,需要自行编译并安装,源代码也需要从git上获取。

    执行命令前,请确保make以及git已安装,若未安装请先使用sudo apt install进行安装。

    git clone https://github.com/skilion/onedrive.git && cd onedrive
    make
    sudo make install
    

    登录并获取OneDrive文件

    在开启同步前,需要先进行初始化,登录到OneDrive并下载OneDrive中所有的文件到本地,执行命令

    onedrive
    

    稍等片刻,屏幕上会出现一个微软的oauth链接,

    $ onedrive
    Authorize this app visiting:
    ## 复制到浏览器,打开这个链接:
    #https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=22c49a0d-d21c-4792-aed1-8f163c982546&scope=files.readwrite%20files.readwrite.all%20offline_access&response_type=code&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient
    
    Enter the response uri: 需要输入一个链接
    

    这时候需要在浏览器中打开这个链接,并登录微软账户,登录完成后,会被重定向到一个空白页面。

    将这个页面的地址复制进终端,并按下回车,登录过程就完成了。

    登录完成后,终端会出现正在下载的文件,稍等片刻待所有文件都下载完成后,初始化完毕,在默认设置下,OneDrive文件夹将位于~/OneDrive

    Downloading changes of 7F311D93082DFCB5!103
    Processing 7F311D93082DFCB5!103 root
    Root
    Processing 7F311D93082DFCB5!7095 test.rar
    Downloading test.rar... done.
    

    开启自动同步

    初始化完毕后,便可以开启自动同步功能。

    如果想每次登录都自动开启onedrive的登录和同步,执行:

    systemctl --user enable onedrive
    systemctl --user start onedrive
    

    此后,对于~/OneDrive文件夹中内容的所有更改都将被同步到安装了OneDrive的其他设备中了。

    附录:认证错误

    如果OneDrive版本太老,那么会有下面的提示:

    onedrive.OneDriveException@src/onedrive.d(403): HTTP request returned status code 400 (Bad Request)
    {
        "correlation_id": "xxxx",
        "error": "invalid_grant",
        "error_codes": [
            70000
        ],
        "error_description": "AADSTS70000: The provided value for the 'code' parameter is not valid.
    Trace ID: xxxx
    Correlation ID: xxxx
    Timestamp: 2021-06-06 03:21:38Z",
        "error_uri": "https://login.microsoftonline.com/error?code=70000",
        "timestamp": "2021-06-06 03:21:38Z",
        "trace_id": "xxxx"
    }
    
    如果说我的文章对你有用,只不过是我站在巨人的肩膀上再继续努力罢了。
    若在页首无特别声明,本篇文章由 Schips 经过整理后发布。
    博客地址:https://www.cnblogs.com/schips/
  • 相关阅读:
    Branching / Tagging
    Working with JSON in C# & VB
    Web API 入门指南
    #进阶系列——WebApi 身份认证解决方案:Basic基础认证
    springboot与shiro在html中使用shiro标签
    springboot与shiro和mybatis和mysql
    springboot和solr结合测试使用
    springboot没有webapp目录——手动添加
    谷歌浏览器不能安装离线插件——可行方法
    elasticsearch7.1.1【win】下载安装
  • 原文地址:https://www.cnblogs.com/schips/p/using_OneDrive_on_Ubuntu-1804.html
Copyright © 2011-2022 走看看