diff --git a/docs/SharePoint-Shared-Libraries.md b/docs/SharePoint-Shared-Libraries.md index dcf45d55..c2674a89 100644 --- a/docs/SharePoint-Shared-Libraries.md +++ b/docs/SharePoint-Shared-Libraries.md @@ -9,12 +9,12 @@ Syncing a OneDrive SharePoint library requires additional configuration for your **Note:** The `--get-O365-drive-id` process below requires a fully configured 'onedrive' configuration so that the applicable Drive ID for the given Office 365 SharePoint Shared Library can be determined. It is highly recommended that you do not use the application 'default' configuration directory for any SharePoint Site, and configure separate items for each site you wish to use. -## Listing available OneDrive SharePoint Libraries -1. Login to the OneDrive web interface and determine which shared library you wish to configure the client for: +## 1. Listing available OneDrive SharePoint Libraries +Login to the OneDrive web interface and determine which shared library you wish to configure the client for: ![shared_libraries](./images/SharedLibraries.jpg) -## Query that shared library name using the client to obtain the required configuration details -2. Run the following command using the 'onedrive' client +## 2. Query OneDrive API to obtain required configuration details +Run the following command using the 'onedrive' client to query the OneDrive API to obtain the required 'drive_id' of the SharePoint Library that you wish to sync: ```text onedrive --get-O365-drive-id '' ``` @@ -48,33 +48,162 @@ The following SharePoint site names were returned: ``` This list of site names can be used as a basis to search for the correct site for which you are searching +## 3. Create a new configuration directory and sync location for this SharePoint Library +Create a new configuration directory for this SharePoint Library in the following manner: +```text +mkdir ~/.config/SharePoint_My_Library_Name +``` -## Configure the client's config file with the required 'drive_id' & 'sync_dir' options -3. Create a new local folder to store the SharePoint Library data in +Create a new local folder to store the SharePoint Library data in: ```text mkdir ~/SharePoint_My_Library_Name ``` **Note:** Do not use spaces in the directory name, use '_' as a replacement -Update your 'onedrive' configuration file (`~/.config/onedrive/config`) with the following: +## 4. Configure SharePoint Library config file with the required 'drive_id' & 'sync_dir' options +Download a copy of the default configuration file by downloading this file from GitHub and saving this file in the directory created above: +```text +wget https://raw.githubusercontent.com/abraunegg/onedrive/master/config -O ~/.config/SharePoint_My_Library_Name/config +``` + +Update your 'onedrive' configuration file (`~/.config/SharePoint_My_Library_Name/config`) with the local folder where you will store your data: ```text sync_dir = "~/SharePoint_My_Library_Name" ``` -4. Once you have obtained the 'drive_id' above, add to your 'onedrive' configuration file (`~/.config/onedrive/config`) the following: +Update your 'onedrive' configuration file(`~/.config/SharePoint_My_Library_Name/config`) with the 'drive_id' value obtained in the steps above: ```text drive_id = "insert the drive_id value from above here" ``` -The OneDrive client will now be configured to sync this SharePoint shared library to your local system. +The OneDrive client will now be configured to sync this SharePoint shared library to your local system and the location you have configured. **Note:** After changing `drive_id`, you must perform a full re-synchronization by adding `--resync` to your existing command line. -## Test the configuration using '--dry-run' -5. Test your new configuration using the `--dry-run` option to validate the the new configuration +## 5. Validate and Test the configuration +Validate your new configuration using the `--display-config` option to validate you have configured the application correctly: +```text +onedrive --confdir="~/.config/SharePoint_My_Library_Name" --display-config +``` -## Sync the SharePoint Library as required -6. Sync the SharePoint Library to your system with either `--synchronize` or `--monitor` operations +Test your new configuration using the `--dry-run` option to validate the application configuration: +```text +onedrive --confdir="~/.config/SharePoint_My_Library_Name" --synchronize --verbose --dry-run +``` + +**Note:** As this is a *new* configuration, the application will be required to be re-authorised the first time this command is run with the new configuration. + +## 6. Sync the SharePoint Library as required +Sync the SharePoint Library to your system with either `--synchronize` or `--monitor` operations: +```text +onedrive --confdir="~/.config/SharePoint_My_Library_Name" --synchronize --verbose +``` + +```text +onedrive --confdir="~/.config/SharePoint_My_Library_Name" --monitor --verbose +``` + +**Note:** As this is a *new* configuration, the application will be required to be re-authorised the first time this command is run with the new configuration. + +## 7. Enable custom systemd service for SharePoint Library +Systemd can be used to automatically run this configuration in the background, however, a unique systemd service will need to be setup for this SharePoint Library instance + +In order to automatically start syncing each SharePoint Library, you will need to create a service file for each SharePoint Library. From the applicable 'systemd folder' where the applicable systemd service file exists: +* RHEL / CentOS: `/usr/lib/systemd/system` +* Others: `/usr/lib/systemd/user` and `/lib/systemd/system` + +### Step1: Create a new systemd service file +#### Red Hat Enterprise Linux, CentOS Linux +Copy the required service file to a new name: +```text +sudo cp /usr/lib/systemd/system/onedrive.service /usr/lib/systemd/system/onedrive-SharePoint_My_Library_Name.service +``` +or +```text +sudo cp /usr/lib/systemd/system/onedrive@.service /usr/lib/systemd/system/onedrive-SharePoint_My_Library_Name@.service +``` + +#### Others such as Arch, Ubuntu, Debian, OpenSuSE, Fedora +Copy the required service file to a new name: +```text +sudo cp /usr/lib/systemd/user/onedrive.service /usr/lib/systemd/user/onedrive-SharePoint_My_Library_Name.service +``` +or +```text +sudo cp /lib/systemd/system/onedrive@.service /lib/systemd/system/onedrive-SharePoint_My_Library_Name@.service +``` + +### Step 2: Edit new systemd service file +Edit the new systemd file, updating the line beginning with `ExecStart` so that the confdir mirrors the one you used above: +```text +ExecStart=/usr/local/bin/onedrive --monitor --confdir="/full/path/to/config/dir" +``` + +Example: +```text +ExecStart=/usr/local/bin/onedrive --monitor --confdir="/home/myusername/.config/SharePoint_My_Library_Name" +``` + +**Note:** When running the client manually, `--confdir="~/.config/......` is acceptable. In a systemd configuration file, the full path must be used. The `~` must be expanded. + +### Step 3: Enable the new systemd service +Once the file is correctly editied, you can enable the new systemd service using the following commands. + +#### Red Hat Enterprise Linux, CentOS Linux +```text +systemctl enable onedrive-SharePoint_My_Library_Name +systemctl start onedrive-SharePoint_My_Library_Name +``` + +#### Others such as Arch, Ubuntu, Debian, OpenSuSE, Fedora +```text +systemctl --user enable onedrive-SharePoint_My_Library_Name +systemctl --user start onedrive-SharePoint_My_Library_Name +``` +or +```text +systemctl --user enable onedrive-SharePoint_My_Library_Name@myusername.service +systemctl --user start onedrive-SharePoint_My_Library_Name@myusername.service +``` + +### Step 4: Viewing systemd status and logs for the custom service +#### Viewing systemd service status - Red Hat Enterprise Linux, CentOS Linux +```text +systemctl status onedrive-SharePoint_My_Library_Name +``` + +#### Viewing systemd service status - Others such as Arch, Ubuntu, Debian, OpenSuSE, Fedora +```text +systemctl --user status onedrive-SharePoint_My_Library_Name +``` + +#### Viewing journalctl systemd logs - Red Hat Enterprise Linux, CentOS Linux +```text +journalctl --unit=onedrive-SharePoint_My_Library_Name -f +``` + +#### Viewing journalctl systemd logs - Others such as Arch, Ubuntu, Debian, OpenSuSE, Fedora +```text +journalctl --user --unit=onedrive-SharePoint_My_Library_Name -f +``` + +### Step 5: (Optional) Run custom systemd service at boot without user login +In some cases it may be desirable for the systemd service to start without having to login as your 'user' + +All the systemd steps above that utilise the `--user` option, will run the systemd service as your particular user. As such, the systemd service will not start unless you actually login to your system. + +To avoid this issue, you need to reconfigure your 'user' account so that the systemd services you have created will startup without you having to login to your system: +```text +loginctl enable-linger +``` + +Example: +```text +alex@ubuntu-headless:~$ loginctl enable-linger alex +``` + +## 8. Configuration for a SharePoint Library is complete +The 'onedrive' client configuration for this particular SharePoint Library is now complete. # How to configure multiple OneDrive SharePoint Shared Library sync -Refer to [./advanced-usage.md](advanced-usage.md) for configuration assistance. +Create a new configuration as per the process above. Repeat these steps for each SharePoint Library that you wish to use. diff --git a/docs/USAGE.md b/docs/USAGE.md index 557f4062..95a84762 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -42,6 +42,7 @@ * [How to sync shared folders (OneDrive Personal)?](#how-to-sync-shared-folders-onedrive-personal) * [How to sync shared folders (OneDrive Business or Office 365)?](#how-to-sync-shared-folders-onedrive-business-or-office-365) * [How to sync sharePoint / Office 365 Shared Libraries?](#how-to-sync-sharepoint--office-365-shared-libraries) + * [How to run a user systemd service at boot without user login?](#how-to-run-a-user-systemd-service-at-boot-without-user-login) - [Running 'onedrive' in 'monitor' mode](#running-onedrive-in-monitor-mode) * [Use webhook to subscribe to remote updates in 'monitor' mode](#use-webhook-to-subscribe-to-remote-updates-in-monitor-mode) * [More webhook configuration options](#more-webhook-configuration-options) @@ -821,6 +822,14 @@ Do not use the 'Add shortcut to My files' from the OneDrive web based interface ### How to sync sharePoint / Office 365 Shared Libraries? Refer to [./SharePoint-Shared-Libraries.md](SharePoint-Shared-Libraries.md) for configuration assistance. +### How to run a user systemd service at boot without user login? +In some cases it may be desirable for the systemd service to start without having to login as your 'user' + +To avoid this issue, you need to reconfigure your 'user' account so that the systemd services you have created will startup without you having to login to your system: +```text +loginctl enable-linger +``` + ## Running 'onedrive' in 'monitor' mode Monitor mode (`--monitor`) allows the onedrive process to continually monitor your local file system for changes to files. @@ -928,6 +937,11 @@ systemctl --user start onedrive **Note:** This will run the 'onedrive' process with a UID/GID of '0', thus, any files or folders that are created will be owned by 'root' +To view the status of the service running, use the following: +```text +systemctl --user status onedrive.service +``` + To see the systemd application logs run: ```text journalctl --user-unit=onedrive -f @@ -1006,6 +1020,11 @@ systemctl --user enable onedrive systemctl --user start onedrive ``` +To view the status of the service running for the user, use the following: +```text +systemctl --user status onedrive.service +``` + To see the systemd application logs run: ```text journalctl --user-unit=onedrive -f diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 2e5fd858..2701909d 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -92,18 +92,29 @@ In order to automatically start syncing your OneDrive accounts, you will need to * RHEL / CentOS: `/usr/lib/systemd/system` * Others: `/usr/lib/systemd/user` and `/lib/systemd/system` -**Note:** The `onedrive.service` runs the service as the 'root' user, whereas the `onedrive@.service` runs the service as your user account. - +### Step1: Create a new systemd service file +#### Red Hat Enterprise Linux, CentOS Linux Copy the required service file to a new name: ```text -cp onedrive.service onedrive-my-new-config.service +sudo cp /usr/lib/systemd/system/onedrive.service /usr/lib/systemd/system/onedrive-my-new-config ``` or ```text -cp onedrive@.service onedrive-my-new-config@.service +sudo cp /usr/lib/systemd/system/onedrive@.service /usr/lib/systemd/system/onedrive-my-new-config@.service ``` -Edit the line beginning with `ExecStart` so that the confdir mirrors the one you used above: +#### Others such as Arch, Ubuntu, Debian, OpenSuSE, Fedora +Copy the required service file to a new name: +```text +sudo cp /usr/lib/systemd/user/onedrive.service /usr/lib/systemd/user/onedrive-my-new-config.service +``` +or +```text +sudo cp /lib/systemd/system/onedrive@.service /lib/systemd/system/onedrive-my-new-config@.service +``` + +### Step 2: Edit new systemd service file +Edit the new systemd file, updating the line beginning with `ExecStart` so that the confdir mirrors the one you used above: ```text ExecStart=/usr/local/bin/onedrive --monitor --confdir="/full/path/to/config/dir" ``` @@ -113,14 +124,18 @@ Example: ExecStart=/usr/local/bin/onedrive --monitor --confdir="/home/myusername/.config/my-new-config" ``` -Then you can safely run these commands: -#### Custom systemd service on Red Hat Enterprise Linux, CentOS Linux +**Note:** When running the client manually, `--confdir="~/.config/......` is acceptable. In a systemd configuration file, the full path must be used. The `~` must be expanded. + +### Step 3: Enable the new systemd service +Once the file is correctly editied, you can enable the new systemd service using the following commands. + +#### Red Hat Enterprise Linux, CentOS Linux ```text systemctl enable onedrive-my-new-config systemctl start onedrive-my-new-config ``` -#### Custom systemd service on Arch, Ubuntu, Debian, OpenSuSE, Fedora +#### Others such as Arch, Ubuntu, Debian, OpenSuSE, Fedora ```text systemctl --user enable onedrive-my-new-config systemctl --user start onedrive-my-new-config @@ -131,11 +146,42 @@ systemctl --user enable onedrive-my-new-config@myusername.service systemctl --user start onedrive-my-new-config@myusername.service ``` -#### Viewing systemd logs for the custom service +### Step 4: Viewing systemd status and logs for the custom service +#### Viewing systemd service status - Red Hat Enterprise Linux, CentOS Linux +```text +systemctl status onedrive-my-new-config +``` + +#### Viewing systemd service status - Others such as Arch, Ubuntu, Debian, OpenSuSE, Fedora +```text +systemctl --user status onedrive-my-new-config +``` + +#### Viewing journalctl systemd logs - Red Hat Enterprise Linux, CentOS Linux ```text journalctl --unit=onedrive-my-new-config -f ``` +#### Viewing journalctl systemd logs - Others such as Arch, Ubuntu, Debian, OpenSuSE, Fedora +```text +journalctl --user --unit=onedrive-my-new-config -f +``` + +### Step 5: (Optional) Run custom systemd service at boot without user login +In some cases it may be desirable for the systemd service to start without having to login as your 'user' + +All the systemd steps above that utilise the `--user` option, will run the systemd service as your particular user. As such, the systemd service will not start unless you actually login to your system. + +To avoid this issue, you need to reconfigure your 'user' account so that the systemd services you have created will startup without you having to login to your system: +```text +loginctl enable-linger +``` + +Example: +```text +alex@ubuntu-headless:~$ loginctl enable-linger alex +``` + Repeat these steps for each OneDrive new account that you wish to use. ## Configuring the client to use multiple OneDrive accounts / configurations using Docker