Friday, September 14, 2018

Nextcloud, VirtualBox and Shared Folders

Update 10/1/2019 - Getting rc.local to work

I've had trouble getting rc.local to work on VMs with newer versions of ubuntu.  My best efforts are to install samaba, smbclient, run through this, then to actually execute rc.local (running rc.local seems to be critical to get it to run on startup).

Original Post -

This might not be how you're supposed to do it, but it's what worked for me.

Install ubuntu server

Install VirtualBox guest additions

Install Nextcloud

Setup your shared folder of choice in VirtualBox.  I'm not going to talk about doing that, it's pretty straight forward.  I checked automount, though that doesn't seem to help.

I made a directory within /var/snap/nextcloud/common/nextcloud/data/ called share.  You might have to sudo su to do it.

Mount your shared folder to that directory:

  1. sudo mount -t vboxsf share /var/snap/nextcloud/common/nextcloud/data/share/



Auto mounting at startup
  1. Edit /etc/rc.local
    sudo -H nano /etc/rc.local
    
  2. Before exit 0 type:
    mount.vboxsf share /var/snap/nextcloud/common/nextcloud/data/share/ vboxsf
  3. Save and exit, please and thank you.
If you restart your VM, that folder should now be mounted persistently.

If you want to see that folder in Nextcloud, you need to enable External Storage Support in Apps, then in settings, direct the path to the Local share directory you created above, /var/snap/nextcloud/common/nextcloud/data/share/ in my case.

Looks like the Nextcloud community knows that samba doesn't work with the snap installer, however I couldn't successfully install Nextcloud without snap.  It's discussed here, I'm not sure what the downside is to adding shares in your data directory other than accidentally writing files directly to /var/snap/nextcloud/common/nextcloud/data/share/ , instead of to your shared folder.  Maybe a security risk?  I'm not sure.

But I don't really want a huge VM taking up gigs of space, and I'd like to get to the shared files directly, without using the web UI sometimes.  AND I can leave a tiny VM running on my server's boot SSD, rather than having it on a spinning disk, that may or may not be spun up at any given point (would probably even stop it from spinning down).

I got SSL running with my own certs too, based on this.

I used SSL For Free and DNS verification to authenticate the subdomain I'm running this on.

I renamed the files to be: certificate.crt to cert.pem,   ca_bundle.crt to chain.pem, and  privkey.pem to privkey.pem.

I ran sudo nextcloud.enable-https custom -s cert.pem privkey.pem chain.pem and got an error, but it made a directory that I need.

Then I coppied my three files into /var/snap/nextcloud/current/certs/custom/

Than reran sudo nextcloud.enable-https custom -s cert.pem privkey.pem chain.pem

BINGO!!!

This is my next project, except hosted locally:


and