在ubuntu上使用onedrive

linux,ubuntu 2019-12-21 282 次浏览 次点赞


在ubuntu上使用onedrive

自从使用了onedrive过后就像发现宝贝似得,跨机器自动同步文件很是方便,特别是一些正在进行调试笔记、开发文档。所以在ubuntu也马上考虑使用onedrive。

I. dependences

通过apt安装如下依赖工具包。

# Install gcc and other C-level pre-requisites.
$ sudo apt-get install build-essential python3-dev libssl-dev inotify-tools python3-dbus
  • gcc
  • python3-dev

    $ python3 --version
    Python 3.5.2
  • libssl-dev
  • inotify-tools
  • python3-dbus (or probably libdbus-glib-1-dev)

安装pip3和setuptools。

# Download pip installation script from official site using wget.
$ wget -O- https://bootstrap.pypa.io/get-pip.py | sudo python3
# Upgrade the components (e.g., setuptools) to latest version.
$ sudo pip3 install -U pip setuptools

同时还需要手动下载ngrok,解压后导出环境变量NGROK

EXPORT NGROK=~/utils/ngrok

II. install

成功下载依赖过后通过通过clone源码安装onedrived。

$ git clone https://github.com/xybu/onedrived-dev.git
$ cd onedrived-dev
# Or use the built-in setuptools package from Python.
$ python3 ./setup.py install --us

III. config

成功安装onedrived后系config统会增加onedrivedonedrived-pref 两个应用工具。

$onedrived #tab 自动补全
onedrived       onedrived-pref  

需要通过onedrived-pref配置onedrive信息,选择交互模式执行命令添加账户onedrived-pref account add。该命令会生产onedrive登录链接并提示你浏览器打开。成功打开该链接后会自动引导从Microsoft登录onedrive,成功登录后会自动跳转到空白网页,并且生成包含登录token的url,我们拷贝该url到命令输入窗口完成认证。

$ onedrived-pref account add

NOTE: To better manage your OneDrive accounts, onedrived needs permission to access your account info (e.g., email
address to distinguish different accounts) and read/write your OneDrive files.

Paste this URL into your browser to sign in and authorize onedrived:

https://login.live.com/oauth20_authorize.srf?response_type=code&scope=wl.signin+wl.emails+wl.offline_access+
onedrive.readwrite&client_id=000000004010C916&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf

The authentication web page will finish with a blank page whose URL starts with
"https://login.live.com/oauth20_desktop.srf". Paste this URL here.
Paste URL here: https://login.live.com/oauth20_desktop.srf?code=<some_code_here>&lc=1033

Successfully authorized onedrived.
Successfully added account for Xiangyu Bu (xybu92@live.com, <account_id_token>)!

All OneDrive accounts associated with user "xb":

  #  Account ID          Owner Name    Email Address
---  ------------------  ------------  ---------------
  0  <account_id_token>  Xiangyu Bu    xybu92@live.com
提示:成功登录后的空白页会显示https://login.live.com/oauth20_desktop.srf?code=xxxxxxx-4041-b23e-baac-xxxxxxxxxx&lc=2052 格式的认证信息。

完成登录认证后还需要去通过 onedrived-pref drive set配置onedrive本地路径和配置文件路径。

$ onedrived-pref drive set
Reading drives information from OneDrive server...

All available Drives of authorized accounts:

  #  Account Email    Drive ID          Type      Quota                        Status
---  ---------------  ----------------  --------  ---------------------------  --------
  0  <some_email>     <some_drive_id>   personal  5.3 GB Used / 33.0 GB Total  active

Please enter row number of the Drive to add or modify (CTRL+C to abort): 0

Going to add/edit Drive "<some_drive_id>" of account "<some_email>"...
Enter the directory path to sync with this Drive [/home/xb/OneDrive]:  
Syncing with directory "/home/xb/OneDrive"? [y/N]: y
Enter the path to ignore file for this Drive [/home/xb/.config/onedrived/ignore_v2.txt]: 

Successfully configured Drive <some_drive_id> of account <some_email> (<some_user_id>):
  Local directory: /home/xb/OneDrive
  Ignore file path: /home/xb/.config/onedrived/ignore_v2.txt

之后便可以通过通过daemon模式启动onedrive完成同步。

$onedrived-pref config set logfile_path ~/onedrived.log
提示:如上~/onedrived.log为onedrive日志文件,首次启动强烈建议通过该日志分析异常。
$onedrived start
$onedrived stop

IV. troubleshootings

Error reading ngrok API

[2019-12-21 13:31:18,605] ERROR: MainThread: Error reading ngrok API: ngrok API did not return any tunnel.. Retry in 1sec.

参考如上dependences手动下载ngrok,解压后导出环境变量NGROK

onedrivesdk install failed

Writing /tmp/easy_install-mch5gxnb/onedrivesdk-2.0/setup.cfg
Running onedrivesdk-2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-mch5gxnb/onedrivesdk-2.0/egg-dist-tmp-hlme4ic3
error: [Errno 20] Not a directory: '/tmp/easy_install-mch5gxnb/onedrivesdk-2.0/setup.py/../NOTICE.rst'

参考 https://github.com/xybu/onedrived-dev/issues/128 修改onedrived-dev根目录下requirements.txt文件中的onedrivesdk版本<2.0

$cat requirements.txt 
#onedrivesdk
onedrivesdk<2   #patch

本文由 lijie 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处,点赞2

还不快抢沙发

添加新评论