在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
  • 前言 在我們開發過程中基本上不可或缺的用到一些敏感機密數據,比如SQL伺服器的連接串或者是OAuth2的Secret等,這些敏感數據在代碼中是不太安全的,我們不應該在源代碼中存儲密碼和其他的敏感數據,一種推薦的方式是通過Asp.Net Core的機密管理器。 機密管理器 在 ASP.NET Core ...
  • 新改進提供的Taurus Rpc 功能,可以簡化微服務間的調用,同時可以不用再手動輸出模塊名稱,或調用路徑,包括負載均衡,這一切,由框架實現並提供了。新的Taurus Rpc 功能,將使得服務間的調用,更加輕鬆、簡約、高效。 ...
  • 順序棧的介面程式 目錄順序棧的介面程式頭文件創建順序棧入棧出棧利用棧將10進位轉16進位數驗證 頭文件 #include <stdio.h> #include <stdbool.h> #include <stdlib.h> 創建順序棧 // 指的是順序棧中的元素的數據類型,用戶可以根據需要進行修改 ...
  • 前言 整理這個官方翻譯的系列,原因是網上大部分的 tomcat 版本比較舊,此版本為 v11 最新的版本。 開源項目 從零手寫實現 tomcat minicat 別稱【嗅虎】心有猛虎,輕嗅薔薇。 系列文章 web server apache tomcat11-01-官方文檔入門介紹 web serv ...
  • C總結與剖析:關鍵字篇 -- <<C語言深度解剖>> 目錄C總結與剖析:關鍵字篇 -- <<C語言深度解剖>>程式的本質:二進位文件變數1.變數:記憶體上的某個位置開闢的空間2.變數的初始化3.為什麼要有變數4.局部變數與全局變數5.變數的大小由類型決定6.任何一個變數,記憶體賦值都是從低地址開始往高地 ...
  • 如果讓你來做一個有狀態流式應用的故障恢復,你會如何來做呢? 單機和多機會遇到什麼不同的問題? Flink Checkpoint 是做什麼用的?原理是什麼? ...
  • C++ 多級繼承 多級繼承是一種面向對象編程(OOP)特性,允許一個類從多個基類繼承屬性和方法。它使代碼更易於組織和維護,並促進代碼重用。 多級繼承的語法 在 C++ 中,使用 : 符號來指定繼承關係。多級繼承的語法如下: class DerivedClass : public BaseClass1 ...
  • 前言 什麼是SpringCloud? Spring Cloud 是一系列框架的有序集合,它利用 Spring Boot 的開發便利性簡化了分散式系統的開發,比如服務註冊、服務發現、網關、路由、鏈路追蹤等。Spring Cloud 並不是重覆造輪子,而是將市面上開發得比較好的模塊集成進去,進行封裝,從 ...
  • class_template 類模板和函數模板的定義和使用類似,我們已經進行了介紹。有時,有兩個或多個類,其功能是相同的,僅僅是數據類型不同。類模板用於實現類所需數據的類型參數化 template<class NameType, class AgeType> class Person { publi ...
  • 目錄system v IPC簡介共用記憶體需要用到的函數介面shmget函數--獲取對象IDshmat函數--獲得映射空間shmctl函數--釋放資源共用記憶體實現思路註意 system v IPC簡介 消息隊列、共用記憶體和信號量統稱為system v IPC(進程間通信機制),V是羅馬數字5,是UNI ...