Skip to main content

Updating the OneDrive Client Service on Linux for Office 365 Integration

This guide provides detailed steps for updating the onedrive client on a Linux system. This client allows seamless integration between Linux and Microsoft Office 365, providing continuous synchronization of your OneDrive files. By following this guide, you’ll learn how to update the OneDrive client and manage it as a systemd user service that runs in monitor mode.

Prerequisites

  1. Existing OneDrive Client Installation: This guide assumes that the onedrive client is already installed on your system.
  2. D Compiler: The OneDrive client requires a D compiler, such as ldc2.
  3. Admin (sudo) Access: You’ll need sudo privileges to install or update system-wide software.
  4. Internet Connection: Required for downloading and installing updates.

Step 1: Verify the Current Version of OneDrive

Before updating, check the version of your currently installed OneDrive client. Run:

onedrive --version

If onedrive is located in /usr/local/bin, use the full path to verify:

/usr/local/bin/onedrive --version

Note the current version number, as it will help confirm that the update was successful.

Step 2: Stop the Existing OneDrive Service

If the OneDrive client is running as a systemd user service, stop it before updating to prevent conflicts.

  1. Check the Service Status:

    systemctl --user status onedrive
    
  2. Stop the Service:

    systemctl --user stop onedrive
    
  3. Disable the Service Temporarily: This prevents the service from starting automatically during the update process.

    systemctl --user disable onedrive
    

Step 3: Download and Install the Latest Version of the OneDrive Client

  1. Remove the Existing Binary: To avoid conflicts, remove the old version of onedrive from /usr/local/bin or /usr/bin:

    sudo rm /usr/local/bin/onedrive
    
  2. Install Prerequisites: Install required dependencies, including the D compiler and development libraries.

    sudo apt update
    sudo apt install -y libcurl4-openssl-dev libsqlite3-dev libnotify-dev ldc
    
  3. Download the Latest Version: Clone the official OneDrive client repository from GitHub.

    git clone https://github.com/abraunegg/onedrive.git
    cd onedrive
    
  4. Build and Install: Configure, compile, and install the client. This step may take a few minutes.

    ./configure
    make
    sudo make install
    
  5. Verify the New Version: Check that the updated version is installed correctly.

    onedrive --version
    

Step 4: Configure the OneDrive Systemd User Service

To run onedrive in monitor mode continuously, we’ll set up a systemd user service. This ensures that onedrive starts automatically in the background and restarts if it stops.

  1. Create or Edit the Systemd Service File: Place the service file in ~/.config/systemd/user/onedrive.service. This ensures it runs as a user service without requiring root privileges.

    mkdir -p ~/.config/systemd/user
    nano ~/.config/systemd/user/onedrive.service
    

    Paste the following configuration:

    [Unit]
    Description=OneDrive Free Client
    Documentation=https://github.com/abraunegg/onedrive
    After=network-online.target
    
    [Service]
    ExecStart=/usr/local/bin/onedrive --monitor
    Restart=on-failure
    RestartSec=3
    
    [Install]
    WantedBy=default.target
    
    • ExecStart: Runs onedrive in --monitor mode to continuously sync changes.
    • Restart: Ensures the service restarts if it fails.
    • WantedBy: Sets the service to start automatically for the current user.
  2. Reload the Systemd Daemon: After modifying service files, reload the systemd daemon to recognize changes.

    systemctl --user daemon-reload
    
  3. Enable and Start the Service: Enable and start the onedrive service to run it in the background.

    systemctl --user enable onedrive
    systemctl --user start onedrive
    
  4. Check the Service Status: Verify that the service is running in monitor mode.

    systemctl --user status onedrive
    

    The status output should indicate that onedrive is active and running in monitor mode. You’ll see real-time logging output from the OneDrive client.

Step 5: Test the Updated OneDrive Client

To confirm that the updated client is working as expected:

  1. Manual Sync Test: You can run a manual sync to check for any synchronization issues.

    onedrive --synchronize
    
  2. Automatic Monitoring: The --monitor mode will automatically sync changes between your OneDrive cloud and your local folder. Test this by creating, modifying, or deleting files in your OneDrive folder and confirming that the changes sync correctly.

  3. View Logs: To view logs of recent sync events, use the following command:

    journalctl --user -u onedrive.service -f
    

    This command will show real-time logs of OneDrive activity.

Troubleshooting Common Issues

  • Service Not Starting: Ensure that the service file path is correct and that ExecStart points to the correct onedrive binary location.
  • Permission Denied Errors: If permissions are causing issues, ensure that you have the correct ownership and permissions for the OneDrive sync folder.
  • No Network Connection: Ensure that onedrive is set to start after the network is online by including After=network-online.target in the service file.

Updating in the Future

For future updates, simply repeat Step 3 to download and install the latest version. You won’t need to reconfigure the systemd service unless there are changes to the service file requirements.

Summary

This guide provides a complete solution for setting up and updating the onedrive client on Linux to sync with Office 365. With this setup:

  • The OneDrive client runs continuously in monitor mode.
  • It synchronizes automatically on boot.
  • You can manage the service with systemctl --user commands.

This configuration provides a reliable and seamless experience for Linux users integrating with Microsoft Office 365’s OneDrive, allowing files to sync effortlessly in the background.