WND Configuration Quick Guide

Installation

If you are using Ubuntu 20.04 as your OS, you will need to add this repository:
sudo add-apt-repository ppa:ondrej/php

First, you need to install the samba packages and libraries that are required for the Windows Network Drives app.

sudo apt-get update
sudo apt-get install -y smbclient php-smbclient coreutils libsmbclient

Next, you have to enable the Windows Network Drives app, either in the Web Interface or the command line:

WebUI

The Windows Network Drive app has to be downloaded from in the Market App. Navigate to the Market app, search for Windows Network Drives and install it.

Commandline

sudo -u www-data php occ market:install windows_network_drive

Configuration

WebUI

Enable external shares:

  • Navigate to admin → settings → storage (in the admin section)

  • Enable the external storage

  • Create a new share and choose Windows network Drives

Configure external share:

  • Folder Name: A name for the WND Share

  • Authentication: Choose Log-in credentials, save in database

  • Host: domain name or IP address

  • Share: name of the top share

  • Remote Subfolder: enter $user for every user to get a home drive

  • Permission Manager: leave empty to use the default one

  • Domain: domain name of your server

  • Available for: limit access to groups

  • Settings: (gear wheel) enable the options you need

If you plan to use ownCloud only in the Web Browser - your setup of the WND is complete.

If you plan to use a desktop client, you need to continue and configure the WND listener and WND process queue.

Commandline

Lastly, you need to setup the wnd listener and process queue to propagate the changes made directly on the storage of your share to the sync client.

This can be done in 2 ways:

  • you configure a new systemd service for the istener and setup a process queue cron job

  • you setup a cronjob for the wnd:listen command and process queue cron job

WND Listener Configuration

Create a service for systemd following the instructions below that checks the share for changes:

  • For each WND mount point distinguished by a SERVER - SHARE pair:

    • Place one copy of a file with following content under /etc/systemd/system/owncloud-wnd-listen-SERVER-SHARE.service

    • Replace the all upper case words SERVER, SHARE, USER and PASSWORD in both, the filename and in the contents below with their respective values.

    • Take care to also adjust the paths in WorkingDirectory and ExecStart according to your installation.

    • Password: Create a file readable only by the www-data and outside the directories handled by apache (let’s suppose in /tmp/mypass). The file must contain only the password for the share. In this example our file is: "/tmp/mypass". The listener will read the contents of the file and use them as the password for the account. This way, only root and the apache user should have access to the password.

    • "--password-trim" removes blank characters from the password file added by 3rdparty software or other services.

      [Unit]
      Description=ownCloud WND Listener for SERVER SHARE
      After=syslog.target
      After=network.target
      Requires=apache2.service
      [Service]
      User=www-data
      Group=www-data
      WorkingDirectory=/var/www/owncloud
      ExecStart=/usr/bin/php ./occ wnd:listen -vvv SERVER SHARE USER --password-file=/tmp/mypass --password-trim
      Type=simple
      StandardOutput=journal
      StandardError=journal
      SyslogIdentifier=%n
      KillMode=process
      RestartSec=3
      Restart=always
      [Install]
      WantedBy=multi-user.target
  • Run the following command, once for each created file:

    sudo systemctl enable owncloud-wnd-listen-SERVER-SHARE.service
    sudo systemctl start  owncloud-wnd-listen-SERVER-SHARE.service

WND Process Queue Configuration

Create or add a crontab file in /etc/cron.d/oc-wnd-process-queue.

  • Make a crontab entry to run a script iterating over all SERVER SHARE pairs with an appropriate occ wnd:process-queue command. The commands must be strictly sequential. This can be done by using flock -n and tuning the -c parameter of occ wnd:process-queue

* * * * *  sudo -u www-data /usr/bin/php /var/www/owncloud/occ wnd:process-queue <HOST> <SHARE>

Execution Serialization

Parallel runs of wnd:process-queue might lead to a user lockout. The reason for this, is that several wnd:process-queue might use the same wrong password because it hasn’t been updated by the time they fetch it.

It’s recommended to force the execution serialization of the wnd:process-queue command. You might want to use Anacron, which seems to have an option for this scenario, or wrap the command with flock.

If you need to serialize the execution of the wnd:process-queue, check the following example with flock

* * * * * flock -n /tmp/wnd001 occ wnd:process-queue server1 share1
* * * * * flock -n /tmp/wnd002 occ wnd:process-queue server1 share2
* * * * * flock -n /tmp/wnd003 occ wnd:process-queue server2 share3

Troubleshooting

  • process queue will not work if there is a backslash in the share path configured in webui.

If you encounter issues using Windows network drive, then try the following troubleshooting steps:

Check the connection to the share by using smbclient on the command line of the ownCloud server. Here is an example:

smbclient -U Username -L //Servername

Take the example of attempting to connect to the share named MyData using occ wnd:listen. Running the following command would work:

sudo -u www-data php occ wnd:listen MyHost MyData svc_owncloud password

The command is case sensitive, and it must match the information from the mount point configuration.

  • When the output of the occ process-queue .. command shows 0 Storages found, then this means, that there was no corresponding external storage configuration found, because:

    1. The casing between calling the process queue and the web interface does not exactly match.

    2. The authentication method is not correctly configured, it needs to be Log-in credentials, save in database