侧边栏壁纸
博主头像
EchoSpace博主等级

Have mind ,Have future!

  • 累计撰写 15 篇文章
  • 累计创建 1 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Onedrive for linux

echowang
2024-08-09 / 0 评论 / 0 点赞 / 20 阅读 / 6537 字

Onedrive

安装

sudo apt update sudo apt install onedrive

使用

sudo onedrive --monitor  #访问生成的url,将登录后的地址复制粘贴

配置

$ onedrive --display-config
onedrive version                       = v2.4.10-1
Config path                            = /home/baoguoxiao/.config/onedrive
Config file found in config path       = false
Config option 'check_nosync'           = false
Config option 'sync_dir'               = /home/baoguoxiao/OneDrive
Config option 'skip_dir'               = 
Config option 'skip_file'              = ~*|.~*|*.tmp
Config option 'skip_dotfiles'          = false
Config option 'skip_symlinks'          = false
Config option 'monitor_interval'       = 300
Config option 'min_notify_changes'     = 5
Config option 'log_dir'                = /var/log/onedrive/
Config option 'classify_as_big_delete' = 1000
Config option 'upload_only'            = false
Config option 'no_remote_delete'       = false
Config option 'remove_source_files'    = false
Config option 'sync_root_files'        = false
Selective sync 'sync_list' configured  = false
Business Shared Folders configured     = false

*下载配置文件

mkdir -p ~/.config/onedrive#创建配置文件目录,有就直接进入

wget https://raw.githubusercontent.com/abraunegg/onedrive/master/config -O ~/.config/onedrive/config#下载配置文件

配置具体文件

# sync_dir = "~/OneDrive"
# skip_# 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 = "/home/samba"
# 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"
# skip_size = "1000"
# dry_run = "false"
# min_notify_changes = "5"
# monitor_log_frequency = "6"
# 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 = "777"
sync_file_permissions = "777"
# rate_limit = "131072"
# webhook_enabled = "false"
# webhook_public_url = ""
# webhook_listening_host = ""
# webhook_listening_port = "8888"
# webhook_expiration_interval = "86400"
# webhook_renewal_interval = "43200"
# space_reservation = "50"
# display_running_config = "false"
# read_only_auth_scope = "false"
# cleanup_local_files = "false"
# operation_timeout = "3600"
# dns_timeout = "60"
# connect_timeout = "10"
# data_timeout = "600"
# ip_protocol_version = "0"file = "~*|.~*|*.tmp"

配置进入systemctl

创建 systemd 服务文件: 创建一个名为 onedrive.service 的文件,并将其放置在 /etc/systemd/system/ 目录中。 该文件应包含以下内容:

[Unit]
Description=OneDrive Linux Client
After=network.target

[Service]
User=onedrive
Group=onedrive
ExecStart=/usr/bin/onedrive --monitor
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

其中:

  • Description: 设置服务描述。

  • After: 指定服务在哪些服务之后启动。 在此处,我们指定 network.target,确保网络可用后启动 OneDrive。

  • User: 设置运行服务的用户。 在此处,我们使用 onedrive 用户。

  • Group: 设置运行服务的用户组。 在此处,我们使用 onedrive 用户组。

  • ExecStart: 指定要运行的命令来启动客户端。 在此处,我们使用 onedrive 命令。

  • Restart: 指定服务在失败时是否重新启动。 在此处,我们设置 on-failure,以便在服务失败时重新启动。

  • RestartSec: 设置服务重新启动之间的延迟(以秒为单位)。 在此处,我们设置 10 秒。

  • WantedBy: 指定服务应该在哪些运行级别启动。 在此处,我们使用 multi-user.target,确保在多用户模式下启动服务。

  1. 重新加载 systemd 配置: 运行以下命令重新加载 systemd 配置,使其识别新的服务文件:

sudo systemctl daemon-reload
  1. 启用 OneDrive 服务: 运行以下命令启用 OneDrive 服务:

sudo systemctl enable onedrive
  1. 启动 OneDrive 服务: 运行以下命令启动 OneDrive 服务:

sudo systemctl start onedrive

验证:

您可以使用以下命令查看 OneDrive 服务的状态:

sudo systemctl status onedrive

如果服务正在运行,您应该会看到以下输出:

Active: active (running) since Sat 2024-05-12 15:17:23 +08; 1s ago
   State: running
   Main PID: 12345
   Command: /usr/bin/onedrive

停止服务:

要停止 OneDrive 服务,请运行以下命令:

sudo systemctl stop onedrive

重启服务:

要重启 OneDrive 服务,请运行以下命令:

sudo systemctl restart onedrive

0

评论区