WND Configuration Quick Guide

Introduction

This is a quick guide for installing and configuring the Windows Network Drive (WND) app.

Prerequisites

To successfully use the Windows Network Drive app, you must meet the prerequisites which can be found in the Server Preparation for Ubuntu 20.04. In particular, these are the sections required which address smbclient ( Clean Ubuntu 20.04 Installation) and libsmbclient-php ( libsmbclient-php Library).

Installation

Install the WND app either via the Web Interface or the command line:

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

  • Post installing enable it via Settings  Admin  Apps.

Command line
sudo -u www-data ./occ market:install windows_network_drive
sudo -u www-data ./occ app:enable windows_network_drive

Configuration

WebUI

Enable external shares:

  • Navigate to Settings  Admin  Storage

  • 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 listener 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:

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

    • Place one copy of a file with the content from below under /etc/systemd/system/owncloud-wnd-listen-SERVER-SHARE.service
      To do so, enter the following command and replace <name> with owncloud-wnd-listen-SERVER-SHARE. For more details see Editing Unit Files.

      sudo systemctl edit --force --full <name>.service

      Reload the deamon to make it available:

      sudo systemctl daemon-reload
    • 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 user 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 in directive ExecStart removes blank characters from the password file added by 3rdparty software or other services.

  • Content template for owncloud-wnd-listen-SERVER-SHARE

    [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=/opt/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

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

  • The process queue will not work if the share name in the webui is configured starting with a forward slash /.

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 ./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