Skip to content

NRM NextCloud

Johan Nylander edited this page Sep 27, 2024 · 10 revisions

Linux

  • Last modified: fre sep 27, 2024 12:57
  • Sign: JN
  • Tested on: Xubuntu 22.04
  • Solved: Yes

NRM have a "cloud" solution for sharing files - https://nrmcloud.nrm.se/. This is a local instance of Nextcloud.

You can easily login and work with the service using a web browser (tested using Chrome, Chromium, Firefox). One limitation when using the web interface is the maximum file size allowed to upload. This limit (unknown at the time of writing) is set by the web server, and can potentially be changed by NRM-IT.

There is also a Nextcloud command line client for Linux. This client should not pose any limits for file sizes.

Install Nextcloud desktop and command line client

For Ubuntu Linux (tested 17 June 2024):

$ sudo add-apt-repository ppa:nextcloud-devs/client
$ sudo apt update
$ sudo apt install -y nextcloud-client nextcloud-desktop

(See https://docs.nextcloud.com/desktop/latest/advancedusage.html#nextcloud-command-line-client)

Syncing between local and remote

One example of syncing files between a local folder ($HOME/nrmcloud/) and a folder on the NRM cloud (/tmp). Note that in this example, the cloud-folder tmp is located directly under the root of the user's cloud-file area ("All files" in the web browser). Note also that files will be synced. That is, after the command, the file content of the two folders should be identical (both sending and downloading as required).

$ nextcloudcmd \
      --user NRMUSER  \
      --password NRMPASSWORD  \
      --path /tmp \
      $HOME/nrmcloud
      https://nrmcloud.nrm.se

For more examples, see https://docs.nextcloud.com/desktop/latest/advancedusage.html#nextcloud-command-line-client.

As a note, there are also other software that can communicate with Nexcloud files. One interesting (untested by JN) is https://lightaffaire.com/code/cloud/cloud-cli

Sharing files

Currently, I recommend using the web-interface for sharing files. See instructions here: https://nextcloud.com/blog/sharing-in-nextcloud/.

For command-line sharing, cloud-cli (https://lightaffaire.com/code/cloud/cloud-cli) may be an option. Or perhaps nec (https://github.com/gnojus/nec), or nc_py_api (https://github.com/cloud-py-api/nc_py_api).

Generate public URL using nec

This example requires "nextcloud-desktop" (nextcloud) and "nextcloud-client" (nextcloudcmd) to be installed. I did that through the PPA (above). I also installed nec by downloading a binary from their releases (following instructions in https://github.com/gnojus/nec).

First, you need to designate a local and a remote folder that are going to be synced.

Local:

$ mkdir ~/nrmcloud

Remote:

$ nextcloud

This will start a "desktop service". Find the Nextcloud icon and select "Settings". There you can add details on which folder on https://nrmcloud.nrm.se you wish to sync with your local folder ("Add Folder Sync Connection").

Then, assume that you have a folder on your remote Nextcloud server named "synced". If you wish to share a file foo.tgz with a public read URL, copy the file to ~/nrmcloud, sync, and run nec!

$ cp foo.tgz ~/nrmcloud

$ nec share ~/nrmcloud/foo.tgz
https://nrmcloud.nrm.se/s/HaPin095YZvDIIg

Note: if you keep the Nextcloud desktop service running, folders are synced automatically if you add new files. If the service is not running, you can sync manually from command line before running nec. For example

$ nextcloudcmd --path synced ~/nrmcloud https://[email protected]

Download tip

If you managed to upload a file to your user space on nrmcloud.nrm.se, and managed to create a link for sharing, below is one method to easily download the desired file to a computer.

Assume the file name is shared.tgz, and the public link provided by NRM-Nextcloud is https://nrmcloud.nrm.se/s/HaPin095YZvDIIg, then to download, add the string download in the end to the URL to get direct access to the file:

$ curl -JLO "https://nrmcloud.nrm.se/s/HaPin095YZvDIIg/download"
$ wget --content-disposition "https://nrmcloud.nrm.se/s/HaPin095YZvDIIg/download"

Mount your NrmCloud partition from command line

You may communicate with your Nextcloud partition by means of WebDAV. This will give you read and write access to your files, but for handling link sharing etc, I recommend the using the web interface. Below is a description on what I did to access the drive (requires sudo privileges).

Install davfs2

$ sudo apt install davfs2

Add your user to group davfs2

$ sudo usermod -a -G davfs2 "$USER"
$ su - $USER # or log out, log in

Reconfigure davfs2 mount permissions (to allow mounting by all users)

$ sudo dpkg-reconfigure davfs2
# and select Yes

Create local mount point

 $ mkdir -p ~/Nrmcloud

Mount (see Notes below)

$ sudo mount -t davfs -o noexec,rw,uid=$USER,gid=$USER \
    https://nrmcloud.nrm.se/remote.php/webdav/ \
    /home/$USER/Nrmcloud

Unmount

$ sudo umount ~/Nrmcloud

Notes

When mounting the way described above, you will be prompted for your NRMUSERNAME, and your NRMPASSWORD. You may circumvent the need for manually having to type this, as well as automatically mount the NextCloud partition, by editing your /etc/fstab as well as saving your credentials in a ~/.davfs2/secrets file. More documentation can be found on https://docs.nextcloud.com/server/20/user_manual/en/files/access_webdav.html.