Owncloud Set External Storage as Default Root Folder

In setting up Owncloud, I wanted to set up the root folder for each user to be their actual profile folder on their Windows machine instead of storing it on the owncloud server. This has a couple benefits and some potential pitfalls as well, and I'll go over those here.

 

The constraints I am working under are this: The client has a Terminal Server environment and they want to be able to sync files to their mobile devices. They also have zero budget and very little bandwidth.

 

With that in mind, I set up a local VM with Debian for Owncloud and only gave it 10gb of disk space. There is a little bit of space left on their VM host, but not much and this fit within that space (memory, cpu and disk space.)

 

Once owncloud was set up and configured to do LDAP authentication to the AD server, I went in and manually logged in each user so that their data folders were created.

 

Then I enabled the external storage app and allowed users to create their own external SMB shares. Now this part is fairly tedious and if I have to do it again, I'll write a program to do it for me, but I added a share for each user. The share looks something like this:

 

Share name: Profile
Share username: domain\username
Share password: (the password)
Share server: 10.10.10.10 (ip address of the server with my profile share on it)
Share name: username (I had already set up a profile share for each user)

 

Whew! What a pain, but now that it's done there's one more tweak to make. I did not have enough disk space to double all the files. That is, I could store them once in the file server profile drive, but I could not afford to store them a second time on the Owncloud server. So, I need to disable storage on the Owncloud server altogether and make sure all the files are stored on the Windows server profile for each user.

 

So, go to the owncloud server (on mine, I have the data folder set up as /owncloud) and go into each user folder and find a file called mount.json. This file looks a little something like this:

 

{
    "user": {
        "emcconkey": {
            "\/emcconkey\/files\/Profile": {
                "class": "\\OC\\Files\\Storage\\SMB",
                "options": {
                    "host": "10.10.10.10",
                    "user": "domain\\emcconkey",
                    "password": "",
                    "share": "emcconkey",
                    "root": "",
                    "password_encrypted": "WW91IHRob3VnaHQgdGhpcyB3YXMgYSBwYXNzd29yZD8gSGEhIQ=="
                },
                "priority": 100
            }
        }
    }
}

The line we're interested in is the third one, it has this: "\/emcconkey\/files\/Profile"

 

That's the location of the folder in the Owncloud interface. We want to change it to this: "\/emcconkey\/files\/"

 

So now the full file looks like:

 

{
    "user": {
        "emcconkey": {
            "\/emcconkey\/files\/": {
                "class": "\\OC\\Files\\Storage\\SMB",
                "options": {
                    "host": "10.10.10.10",
                    "user": "domain\\emcconkey",
                    "password": "",
                    "share": "emcconkey",
                    "root": "",
                    "password_encrypted": "WW91IHRob3VnaHQgdGhpcyB3YXMgYSBwYXNzd29yZD8gSGEhIQ=="
                },
                "priority": 100
            }
        }
    }
}

Now when the user logs in, the SMB mapped folder is now the root. I wiped the sample data that Owncloud dumped into each data folder just for cleanliness sake and now we're done.

 

After setting up SSL and reconfiguring the firewall, mobile clients can connect to pull down data they need, but the Terminal Server and the Owncloud server on the LAN are now doing the following: Nothing.

 

That's it, the Terminal Server doesn't have to run the Owncloud client to sync up the data and the Owncloud server doesn't have to house a second copy of all the files on the LAN. Also, the files don't get uploaded to the internet (until someone syncs up with a mobile client) and so bandwidth is saved as much as possible. And that's the advantage of the system; you save disk and CPU cycles as well as bandwidth.

 

Now to the disadvantages I mentioned earlier. If the server that's sharing the profiles is offline, nobody can sync anything from their mobile clients. In fact, they can't even log into the web page to view their Owncloud account. It just crashes and shows a blank page in the browser. Similarly, when a user changes their password - the same thing happens, but only for that user. They cannot sync and they cannot access their files. The only way around it is to manually remove the mount.json file for that user and go through the process again.

 

It's a pain, but there are a few ways around it if you were so inclined:

 

1) Write a php page that allows you to re-enter the user's password and it re-write's the mount.json file for that user. Secure it properly, and you have a way that you can reset things for users.

 

2) Write a php page that does the above, and also build a simple windows program that runs on login to detect when a user's password changes and prompts them to enter it again and so it then posts the data to the custom php page and reset it for them.

 

3) Use an enterpise-grade system that doesn't require you to resort to such hackery.

 

Good luck, and let me know in the comments if you try it.



Back to Article Index

blog comments powered by Disqus