在ubuntu 20.04下安裝配置onedrive

来源:https://www.cnblogs.com/dysonxxxxx/archive/2022/08/03/16546102.html
-Advertisement-
Play Games

lamp 1. lamp簡介 lamp,其實就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一組動態網站或者伺服器的開源軟體 LAMP指的是Linux(操作系統)、Apache(HTTP伺服器)、MySQL(也指MariaDB,資料庫軟體)和PHP(有時也 ...


項目地址:https://github.com/abraunegg/onedrive

筆者系統版本:Ubuntu 20.04

本文將介紹的主要內容:在Ubuntu20.04版本下下載、安裝onedrive,並完成對該軟體的基本設置,包括:修改保存位置、跳過onedrive下特定文件夾、開啟日誌、將onedrive設為系統服務

下載與安裝

前往頁面https://github.com/abraunegg/onedrive/blob/master/docs/ubuntu-package-install.md查看對應指令,系統版本和我一樣的同學可以直接複製下列指令完成下載與安裝

wget -qO - https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/xUbuntu_20.04/Release.key | sudo apt-key add -
echo 'deb https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/xUbuntu_20.04/ ./' | sudo tee /etc/apt/sources.list.d/onedrive.list
sudo apt-get update
sudo apt install onedrive

配置

本文主要完成以下配置

  • onedrive授權
  • 下載、修改配置文件
  • 開始同步
  • 將onedrive設置成系統服務

項目給出的配置教程文件地址如下,有需要的同學可以查看其他未提及的用法與配置

https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md

授權

  1. 推薦連接梯子後操作,但非必須

  2. 打開命令行,輸入onedrive

  3. 在命令行中的url按住ctrl後左鍵單擊打開。註意此時不要關閉打開的命令行

  4. 在網頁中輸入自己的帳號密碼,隨後會頁面跳轉至一個空白頁。

  5. 複製空白頁的地址,回到命令行並粘貼上一部複製的地址

註意:這一步可能會連接失敗,各位多嘗試幾次。

下載、編輯配置文件

下載

  1. 在用戶目錄下創建文件夾
mkdir -p ~/.config/onedrive
  1. 下載配置文件:
wget https://raw.githubusercontent.com/abraunegg/onedrive/master/config -O ~/.config/onedrive/config

配置文件具體內容如下:

# Configuration for OneDrive Linux Client
# This file contains the list of supported configuration fields
# with their default values.
# All values need to be enclosed in quotes
# When changing a config option below, remove the '#' from the start of the line
# For explanations of all config options below see docs/USAGE.md or the man page.
#
# sync_dir = "~/OneDrive"
# skip_file = "~*|.~*|*.tmp"
# monitor_interval = "300"
# skip_dir = ""
# log_dir = "/var/log/onedrive/"
# drive_id = ""
# upload_only = "false"
# check_nomount = "false"
# check_nosync = "false"
# download_only = "false"
# disable_notifications = "false"
# disable_upload_validation = "false"
# enable_logging = "false"
# force_http_11 = "false"
# local_first = "false"
# no_remote_delete = "false"
# skip_symlinks = "false"
# debug_https = "false"
# skip_dotfiles = "false"
# dry_run = "false"
# min_notify_changes = "5"
# monitor_log_frequency = "5"
# monitor_fullscan_frequency = "12"
# sync_root_files = "false"
# classify_as_big_delete = "1000"
# user_agent = ""
# remove_source_files = "false"
# skip_dir_strict_match = "false"
# application_id = ""
# resync = "false"
# resync_auth = "false"
# bypass_data_preservation = "false"
# azure_ad_endpoint = ""
# azure_tenant_id = "common"
# sync_business_shared_folders = "false"
# sync_dir_permissions = "700"
# sync_file_permissions = "600"
# rate_limit = "131072"
# operation_timeout = "3600"
# webhook_enabled = "false"
# webhook_public_url = ""
# webhook_listening_host = ""
# webhook_listening_port = "8888"
# webhook_expiration_interval = "86400"
# webhook_renewal_interval = "43200"
# space_reservation = "50"

編輯配置

配置方面,我主要修改了:

  • 同步在linux上的存儲位置
  • 跳過一些在onedrive上,但不想保存在linux上的文件
  • 開啟日誌並修改日誌存儲位置

其他具體的各項設置可以前往下列地址查看幫助

https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md

修改存儲位置

  1. onedrive預設的保存位置為~/OneDrive,也可以修改保存位置。方法如下

  2. 用任意編輯器打開文件:~/.config/onedrive/config

  3. 找到項sync_dir ,刪去其前的#

  4. 這裡筆者想要存儲在本地目錄~/Documents下,故將該項改成了sync_dir = "~/Documents",大家按需修改即可

跳過onedrive中的特定目錄

  1. 筆者用linux學習記錄更多一些,而onedrive中一些內容與學習記錄這一目的無關。這時,為了節省空間,我們就需要跳過對這些與學習無關文件夾的同步了。方法如下
  2. 筆者onedrive的根目錄下有三個文件夾:attachdocumentspictures,而我並不需要對pictures這一文件夾同步
  3. 用任意編輯器打開文件:~/.config/onedrive/config
  4. 找到項skip_dir ,刪去其前的#
  5. 將該項改成skip_dir = "pictures"

註:

  1. 文件夾可以有多個,其間用|分隔
  2. 文件夾可以定位至子文件夾如:pictures/arch1

開啟日誌並修改日誌存儲位置

  1. 筆者想要存儲的日誌位置為:~/.config/onedrive
  2. 打開配置文件
  3. 找到項log_dir ,刪去其前的#
  4. 將該項改成log_dir = "~/.config/onedrive/",特別註意這裡要確保在文件末尾加上/,否則無法正確識別

開始同步

  1. 同步往往會因為GFW,導致連接出錯,建議在聯好梯子後運行
  2. 在正式運行前,可以先輸入下列命令看看運行結果而不對系統產生變化,即dry run

onedrive --dry-run --synchronize

命令會因為GFW而連接出錯,我在配置的過程中就出現了兩種錯誤,但在嘗試了三次後就正常了

  1. 如果dry run符合你的預期,那麼便可以正式運行啦,輸入下列命令。

onedrive --synchronize --verbose --resync --local-first

  1. 運行完後,雲端文件便保存至本地啦

將onedrive設置成系統服務

官方的幫助文件中給出了三種方法,我採用的是通過systemd 以非root用戶身份運行OneDrive服務,這種方法的好處是規避了root用戶創建的文件許可權的問題

  1. 此方法需要知曉root的密碼,以及普通用戶的用戶名
  2. 運行onedrive --synchronize --verbose,查看是否正常運行
  3. 運行su,切換為root
  4. 運行systemctl enable [email protected],這裡的dyson需要改成大家自己的用戶名
  5. 運行systemctl start [email protected]dyson同上。此時系統服務就設置好了
  6. 運行systemctl status [email protected]dyson同上。這條命令用於查看是否正確運行
  7. 運行exit,回退至普通用戶

附:onedrive --help

Configuration file successfully loaded
OneDrive - a client for OneDrive Cloud Services

Usage:
  onedrive [options] --synchronize
      Do a one time synchronization
  onedrive [options] --monitor
      Monitor filesystem and sync regularly
  onedrive [options] --display-config
      Display the currently used configuration
  onedrive [options] --display-sync-status
      Query OneDrive service and report on pending changes
  onedrive -h | --help
      Show this help screen
  onedrive --version
      Show version

Options:

  --auth-files ARG
      Perform authentication not via interactive dialog but via files read/writes to these files.
  --auth-response ARG
      Perform authentication not via interactive dialog but via providing the response url directly.
  --check-for-nomount
      Check for the presence of .nosync in the syncdir root. If found, do not perform sync.
  --check-for-nosync
      Check for the presence of .nosync in each directory. If found, skip directory from sync.
  --classify-as-big-delete
      Number of children in a path that is locally removed which will be classified as a 'big data delete'
  --confdir ARG
      Set the directory used to store the configuration files
  --create-directory ARG
      Create a directory on OneDrive - no sync will be performed.
  --create-share-link ARG
      Create a shareable link for an existing file on OneDrive
  --debug-https
      Debug OneDrive HTTPS communication.
  --destination-directory ARG
      Destination directory for renamed or move on OneDrive - no sync will be performed.
  --disable-download-validation
      Disable download validation when downloading from OneDrive
  --disable-notifications
      Do not use desktop notifications in monitor mode.
  --disable-upload-validation
      Disable upload validation when uploading to OneDrive
  --display-config
      Display what options the client will use as currently configured - no sync will be performed.
  --display-sync-status
      Display the sync status of the client - no sync will be performed.
  --download-only
      Replicate the OneDrive online state locally, by only downloading changes from OneDrive. Do not upload local changes to OneDrive.
  --dry-run
      Perform a trial sync with no changes made
  --enable-logging
      Enable client activity to a separate log file
  --force
      Force the deletion of data when a 'big delete' is detected
  --force-http-11
      Force the use of HTTP 1.1 for all operations
  --force-sync
      Force a synchronization of a specific folder, only when using --synchronize --single-directory and ignore all non-default skip_dir and skip_file rules
  --get-O365-drive-id ARG
      Query and return the Office 365 Drive ID for a given Office 365 SharePoint Shared Library
  --get-file-link ARG
      Display the file link of a synced file
  --help -h
      This help information.
  --list-shared-folders
      List OneDrive Business Shared Folders
  --local-first
      Synchronize from the local directory source first, before downloading changes from OneDrive.
  --log-dir ARG
      Directory where logging output is saved to, needs to end with a slash.
  --logout
      Logout the current user
  --min-notify-changes ARG
      Minimum number of pending incoming changes necessary to trigger a desktop notification
  --modified-by ARG
      Display the last modified by details of a given path
  --monitor -m
      Keep monitoring for local and remote changes
  --monitor-fullscan-frequency ARG
      Number of sync runs before performing a full local scan of the synced directory
  --monitor-interval ARG
      Number of seconds by which each sync operation is undertaken when idle under monitor mode.
  --monitor-log-frequency ARG
      Frequency of logging in monitor mode
  --no-remote-delete
      Do not delete local file 'deletes' from OneDrive when using --upload-only
  --operation-timeout
      Maximum amount of time (in seconds) an operation is allowed to take
  --print-token
      Print the access token, useful for debugging
  --reauth
      Reauthenticate the client with OneDrive
  --remove-directory ARG
      Remove a directory on OneDrive - no sync will be performed.
  --remove-source-files
      Remove source file after successful transfer to OneDrive when using --upload-only
  --resync
      Forget the last saved state, perform a full sync
  --resync-auth
      Approve the use of performing a --resync action
  --single-directory ARG
      Specify a single local directory within the OneDrive root to sync.
  --skip-dir ARG
      Skip any directories that match this pattern from syncing
  --skip-dir-strict-match
      When matching skip_dir directories, only match explicit matches
  --skip-dot-files
      Skip dot files and folders from syncing
  --skip-file ARG
      Skip any files that match this pattern from syncing
  --skip-size ARG
      Skip new files larger than this size (in MB)
  --skip-symlinks
      Skip syncing of symlinks
  --source-directory ARG
      Source directory to rename or move on OneDrive - no sync will be performed.
  --space-reservation ARG
      The amount of disk space to reserve (in MB) to avoid 100% disk space utilisation
  --sync-root-files
      Sync all files in sync_dir root when using sync_list.
  --sync-shared-folders
      Sync OneDrive Business Shared Folders
  --syncdir ARG
      Specify the local directory used for synchronization to OneDrive
  --synchronize
      Perform a synchronization
  --upload-only
      Replicate the locally configured sync_dir state to OneDrive, by only uploading local changes to OneDrive. Do not download changes from OneDrive.
  --user-agent ARG
      Specify a User Agent string to the http client
  --verbose -v+
      Print more details, useful for debugging (repeat for extra debugging)
  --version
      Print the version and exit

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 很多時候,我們在本地開發過程中程式運行很正常,但是發佈到線上之後由於環境的原因,可能會有一些異常。通常我們會通過日誌來分析問題,除了日誌還有一種常用的調試手段就是:附加進程。 VS中的附加進程非常強大,目前提供了9種常用的附加方式。 在當前.Net Core支持跨平臺的大背景下,其中Linux環境和 ...
  • 一:背景 1. 講故事 前段時間遇到了好幾起關於窗體程式的 進程載入鎖 引發的 程式卡死 和 線程暴漲 問題,這種 dump 分析難度較大,主要涉及到 Windows操作系統 和 C++ 的基礎知識,所以有必要簡單整理和大家分享一下,上 windbg 說話。 二:WinDbg 分析 1. 主線程此時 ...
  • 經過長時間的規劃和編碼,終於出來了.NET 版本的微服務框架,而且框架的使用簡單,無入侵集成,可幫助任意項目輕鬆向大併發架構演進。 ...
  • 前言 接著上周寫的截圖控制項繼續更新添加 文字。 1.WPF實現截屏「仿微信」 2.WPF 實現截屏控制項之移動(二)「仿微信」 3.WPF 截圖控制項之伸縮(三) 「仿微信」 4.WPF 截圖控制項之繪製方框與橢圓(四) 「仿微信」 5.WPF 截圖控制項之繪製箭頭(五)「仿微信」 6.WPF 截圖控制項之繪 ...
  • 為什麼要用ssh密鑰登錄 購買的伺服器設置密碼很容易被暴力破解,用密鑰登錄安全很多。root用戶新建的用戶也要用密鑰登錄更安全,如果一直su - 用戶名登錄 不方便 用xftp等服務上傳文件到用戶使用的服務下,歸屬人是root,還要chown改許可權才能使用。 為其他用戶創建ssh密鑰的步驟 # 密鑰 ...
  • Naarak Studio DirEqua mac版是Mac的高級目錄比較實用程式。它可以檢測文件夾之間最小的變化,並以清晰直觀的方式顯示結果。使用顏色和圖標突出顯示差異類型(大小,日期或項目內容),以突出顯示差異。DirEqual Mac版將比較的目錄併排顯示為可擴展樹,併為每個項目指示大小和日期 ...
  • sudo:superuser do,實現普通用戶執行root命令的授權工具。 一般用戶管理系統的方式是利用su切換為超級用戶。但是使用su的缺點之一在於必須要先告知超級用戶的密碼。 sudo使一般用戶不需要知道超級用戶的密碼即可獲得許可權 #過程: (1)超級用戶授權:首先 超級用戶 將普通用戶的名字 ...
  • 今天是接觸C++的第二天,學習了基礎內容之後用了兩個多小時的時間完成了一個通訊錄管理程式,功能相對簡單,代碼也不複雜,歡迎各位大佬指出不足之處 點擊查看代碼 #include<iostream> #include<string> #include<regex> using namespace std ...
一周排行
    -Advertisement-
    Play Games
  • 概述:在C#中,++i和i++都是自增運算符,其中++i先增加值再返回,而i++先返回值再增加。應用場景根據需求選擇,首碼適合先增後用,尾碼適合先用後增。詳細示例提供清晰的代碼演示這兩者的操作時機和實際應用。 在C#中,++i 和 i++ 都是自增運算符,但它們在操作上有細微的差異,主要體現在操作的 ...
  • 上次發佈了:Taurus.MVC 性能壓力測試(ap 壓測 和 linux 下wrk 壓測):.NET Core 版本,今天計劃準備壓測一下 .NET 版本,來測試並記錄一下 Taurus.MVC 框架在 .NET 版本的性能,以便後續持續優化改進。 為了方便對比,本文章的電腦環境和測試思路,儘量和... ...
  • .NET WebAPI作為一種構建RESTful服務的強大工具,為開發者提供了便捷的方式來定義、處理HTTP請求並返迴響應。在設計API介面時,正確地接收和解析客戶端發送的數據至關重要。.NET WebAPI提供了一系列特性,如[FromRoute]、[FromQuery]和[FromBody],用 ...
  • 原因:我之所以想做這個項目,是因為在之前查找關於C#/WPF相關資料時,我發現講解圖像濾鏡的資源非常稀缺。此外,我註意到許多現有的開源庫主要基於CPU進行圖像渲染。這種方式在處理大量圖像時,會導致CPU的渲染負擔過重。因此,我將在下文中介紹如何通過GPU渲染來有效實現圖像的各種濾鏡效果。 生成的效果 ...
  • 引言 上一章我們介紹了在xUnit單元測試中用xUnit.DependencyInject來使用依賴註入,上一章我們的Sample.Repository倉儲層有一個批量註入的介面沒有做單元測試,今天用這個示例來演示一下如何用Bogus創建模擬數據 ,和 EFCore 的種子數據生成 Bogus 的優 ...
  • 一、前言 在自己的項目中,涉及到實時心率曲線的繪製,項目上的曲線繪製,一般很難找到能直接用的第三方庫,而且有些還是定製化的功能,所以還是自己繪製比較方便。很多人一聽到自己畫就害怕,感覺很難,今天就分享一個完整的實時心率數據繪製心率曲線圖的例子;之前的博客也分享給DrawingVisual繪製曲線的方 ...
  • 如果你在自定義的 Main 方法中直接使用 App 類並啟動應用程式,但發現 App.xaml 中定義的資源沒有被正確載入,那麼問題可能在於如何正確配置 App.xaml 與你的 App 類的交互。 確保 App.xaml 文件中的 x:Class 屬性正確指向你的 App 類。這樣,當你創建 Ap ...
  • 一:背景 1. 講故事 上個月有個朋友在微信上找到我,說他們的軟體在客戶那邊隔幾天就要崩潰一次,一直都沒有找到原因,讓我幫忙看下怎麼回事,確實工控類的軟體環境複雜難搞,朋友手上有一個崩潰的dump,剛好丟給我來分析一下。 二:WinDbg分析 1. 程式為什麼會崩潰 windbg 有一個厲害之處在於 ...
  • 前言 .NET生態中有許多依賴註入容器。在大多數情況下,微軟提供的內置容器在易用性和性能方面都非常優秀。外加ASP.NET Core預設使用內置容器,使用很方便。 但是筆者在使用中一直有一個頭疼的問題:服務工廠無法提供請求的服務類型相關的信息。這在一般情況下並沒有影響,但是內置容器支持註冊開放泛型服 ...
  • 一、前言 在項目開發過程中,DataGrid是經常使用到的一個數據展示控制項,而通常表格的最後一列是作為操作列存在,比如會有編輯、刪除等功能按鈕。但WPF的原始DataGrid中,預設只支持固定左側列,這跟大家習慣性操作列放最後不符,今天就來介紹一種簡單的方式實現固定右側列。(這裡的實現方式參考的大佬 ...