Docker + Nextcloud + External storage

  • Hello,

    For several days now, I've been reading and trying a lot to install a Nextcloud server on my Pi2B. Unfortunately, I have not been able to find a clear tutorial for this installation, as I am quite a newbie. For instance, most of the posts/docs ask to chown data folder or to perform some other commands which are not allowed in LibreElec, from what I understand.

    So what I would like is to install Docker (done) then Nextcloud (done) on my Pi, but I can't manage on using my external hard drive (plugged to the Pi via USB and automatically mounted on "/media/My Book") as my Nextcloud data folder. I understand there are some operations to perform before launching the Nextcloud web interface ? Not sure...

    Could someone help me with that operation?

    Thank you.

    Regards

  • It's fairly simple:

    Install the Linuxserver.io repository

    Addons --> Install from Repository --> LibreELEC Add-ons --> Add-on repository --> LinuxServer.io's Docker Add-on.

    Install Nextcloud.

    Addons --> Install from Repository --> Linuxserver.io Docker Add-ons --> Services -- Nextcloud.

    Wait for install to finish and then reboot

    Change default data folder.

    Add-ons --> My Add-ons --> Nextcloud --> Configure --> Map /data

  • I did exactly what Iridium suggests, except the last step (mapping /data folder) because I understand I should begin with adding a "-v ..." parameter to the nextcloud container. Am I right?

    Moreover, considering my hard drive is named "My Book" - with a space inside the name - how do you suggest I should write the /data folder parameter? Should I write "/media/My Book/nextcloud" or "/media/My\ Book/nextcloud" or something else?

    Thank you.

  • You shouldn't need to do anything.

    Click on the "data" bit in the settings and just browse up a few levels till "root" then down to your hard drive. Probably /var/media/My Book or just /media/My Book.

    Otherwise add in additional settings -v "/var/media/My Book" <-- note double quotes. Also check capitalisation.

  • Ok, that's what I've done, now when I go to my Pi IP, I get the page asking for information to finish the installation (Great!)

    I type in some admin user name and password. Then I select a MySQL database (I would like to use some advanced features). But there is something I don't undrrstand: should this database be created before the installation (then I would enter this database information) or will this assistant create a database (based on the information I provide here) ?

    I confess I firstly considered the latter option, but got an error message: "SQLSTATE[HY000] [2002] No such file or directory". If I have to create a database, could you please help me in doing so?

    Thanks again.

  • Ok, that's what I've done, now when I go to my Pi IP, I get the page asking for information to finish the installation (Great!)

    I type in some admin user name and password. Then I select a MySQL database (I would like to use some advanced features). But there is something I don't undrrstand: should this database be created before the installation (then I would enter this database information) or will this assistant create a database (based on the information I provide here) ?

    I confess I firstly considered the latter option, but got an error message: "SQLSTATE[HY000] [2002] No such file or directory". If I have to create a database, could you please help me in doing so?

    Thanks again.

    In the earlier versions, entering the root user and pass for mysql would allow nextcloud to create its own user and database, but the latest version has a bug and fails to do so. You need to create the user and database first, and then enter those into nextcloud wizard

  • OK. that's useful and it explains why I can find various methods on the web. But then, how do I create the database? Once again, I've found multiple ways to do so (SSH or not) and don't know which one I should follow.

    Thanks

    Edit:

    Here is what I've tried so far:

    On Kodi, install MariaDB container from LinuxServer.io deposit)

    Chose a root password for MariaDB on Kodi GUI

    Wait for the container to be created (checked with "docker ps" command)

    On Nextcloud web interface now:

    Enter some Nextcloud credentials (administrator user name and password)

    Chose MariaDB as database type

    - User: root

    - Password: the one I chose before on Kodi GUI

    - Database name: nc

    - Database host: mariadb:3306

    Now I get this error message: "SQLSTATE[HY000] [1045] Access denied for user 'oc_root'@'docker.linuxserver.nextcloud.lsio' (using password: YES)"

    Edited once, last by Alomon: Details of trial (February 3, 2020 at 9:18 AM).

  • That's what I meant by using the root password no longer working for nextcloud.

    I'll get a PR in to allow mariadb to create a user defined db, user and pass on first start. But until then, you'll have to manually create those. You can do the following to get access to mysql cli in mariadb: "docker exec -it docker.linuxserver.mariadb mysql -u root -p"

    It will ask for the root pass, then let you in.

  • OK, I'm in! Now I've tried different things that still don't work, so I still need help. I used this tutorial: [NextCloud] NextCloud 12.0 installation with MariaDB and PHP 7.1

    When in mariadb CLI, I create the database: CREATE DATABASE nextcloud;

    Then the user: CREATE USER my-name@my-server-ip IDENTIFIED BY 'my-password';

    Then grant privileges: GRANT ALL PRIVILEGES ON nextcloud.* to my-name@my-server-ip IDENTIFIED BY 'my-password'; and FLUSH PRIVILEGES;

    Back to Nextcloud web interface, I enter all these information:

    - Nextcloud credentials: my-name and my-password (same as in SQL commands)

    For Mariadb:

    - User: root

    - Password: the one I chose before on Kodi GUI

    - Database name: nextcloud

    - Database host: mariadb:3306

    I still get an error (SQLSTATE[HY000] [1045] Access denied for user 'oc_my-name'@'docker.linuxserver.nextcloud.lsio' (using password: YES))

    Where am I wrong?

    Thanks

  • Alomon just pushed an update to the mariadb addon. You can now enter database name, user and pass into its settings and it will create the database. Keep in mind that it only works during initial set up (not when there is existing data). So you would have to uninstall the addon and delete all data (nuke any existing database), then reinstall and enter the info into settings.

  • Great, thanks. After reinstalling mariadb add-on and entering the information on the GUI, do I still have something to do via SSH (privileges and so on) or should I just install Nectcloud with these information ?

    Edit:

    I've tried to enter some credentials for Nextcloud admin account. Then, in MariaDB parameter, I copied the information I already entered on Kodi GUI. But now I get a "504 Gateway Time-out" error. Does it ring a bell?

    Edit 2:

    OK, I just waited for a moment and refreshed the page, the previous error disappeared. But I get another one: "Your data directory is readable by other users...". I understand it might have something to do with my external storage (USB, NTFS). I selected my /data folder on Nextcloud parameters box (on Libreelec), but shouldn't I change something in fstab?

    Edited 2 times, last by Alomon (February 3, 2020 at 8:32 PM).

  • I wouldn't recommend ntfs with linux. Too many potential compatibility issues.

    I don't know how you set up your mount, but if nextcloud sees it, you should be good.

  • Alomon just pushed an update to the mariadb addon. You can now enter database name, user and pass into its settings

    I'm just not sure about one thing: in Nextcloud wizard, after selecting MariaDB, which user details should I enter? Root or the one I entered on MariaDB Kodi GUI? And should I use one of them as Nextcloud admin account credentials?

    Thanks

    (My HDD is now formatted as exFAT)

    Edit: found out, disregard my message.

    Edited 2 times, last by Alomon (February 4, 2020 at 8:07 PM).

  • Hello,

    Now, when I validate the wizard, I still get the "504 gateway time out" error. Then I go back to my IP, but the wizard is still displaying! I would expect to get a connection form...

    If I try again to create my admin account, the wizard tells me the username already exists, which suggests that the account is created but I still don't have the opportunity to connect with it.

    I tried to start from scratch and do this again, I got the same behavior...

    Any idea?

    Thanks

    Edit:

    Ahah, now after just waiting for a while and refreshing the page, this error is back: "Your data directory is readable by other users..."

    I can't understand it :(

    Edited once, last by Alomon (February 5, 2020 at 8:56 AM).

  • [...]

    Ahah, now after just waiting for a while and refreshing the page, this error is back: "Your data directory is readable by other users..."

    I can't understand it :(

    The Nextcloud data directory must have 0770 (rwxrwx---) permisions as shown in that same error page you got. What it doesn't say there is that the data directory also must be owned by nobody.users (65534.100) so Netxcloud would be able to access it.

    By default Libreelec (udevil) automounts the usb storage as 777 (rwxrwxrwx) root.root but Nextcloud runs as user nobody.

    The external storage is automounted with udevil and whose config file is /etc/udevil/udevil.conf that is located in the read only part of the file system and doesn't seem to be possible to override the default_options_ntfs to change the user and group it automounts the hdd with.

    default_options_ntfs      = nosuid, noexec, nodev, noatime, big_writes, fmask=0133, uid=$UID, gid=$GID, utf8

    to:

    default_options_ntfs      = nosuid, noexec, nodev, noatime, big_writes, fmask=0133, uid=65534, gid=100, utf8

    You could try to disable that permission check at boot in:

    /storage/.kodi/userdata/addon_data/docker.linuxserver.nextcloud/config/www/nextcloud/config/config.php with:

    'check_data_directory_permissions' => false,

    but that won't work because of the fmask=0133 that makes all files readonly for non-root users.

    Anyway I've not tried changing udevil.conf and I'm not sure if this would be enough for Nextcloud to have the whole data directory in an NTFS (or exFAT) drive since neither support unix type permisions. Also won't recommend messing with udevil config unless you know what you are doing.

    The other (dirty) option to try would be to unmount and remount the device with the required permissions. A background script launched from /storage/.config/autostart.sh could periodically check if these are correct and unmount and remount when required, but again not sure if will work with NTFS or exFAT..

    Alternatively you also can easily share an NTFS formatted disk in Nextcloud just sharing it via the own Libreelec samba server and adding it via the external storage app, with a similar result to using the -v /var/media/My\ Book:/My\ Book parameter in the addon's additional config page but still the users folders will be kept inside the container's original data directory, which may not be what you want.

    Edited 2 times, last by librero (February 6, 2020 at 1:29 AM).