Guide: OC 5.0.X and H-Drive Integration

Tutorials on ownCloud administration
Forum rules
The forums were migrated over to https://central.owncloud.org which is based on the forum software Discourse. The forums here is put into read-only mode starting from today.

More background information about this move and the reasoning behind it is available in this blogpost:

https://daniel.molkentin.net/2016/07/20 ... d-central/
almyz125
Beginner
Posts: 26
Joined: Thu Feb 21, 2013 1:43 am
ownCloud version: 5.0.5
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.3.3

Guide: OC 5.0.X and H-Drive Integration

Postby almyz125 » Tue May 28, 2013 8:49 pm

Things you'll NEED: OwnCloud running on a Linux box and Windows shares!

OC 6.0.X tutorial here.
OC 4.5.X tutorial here.

Note:
Confirmed to work on OC 5.0.0 - 5.0.10
This guide is for Debian 6.
Assume that I am logged in as root the entire time.

Step one: OwnCloud prerequisites and OwnCloud

Install OC Using this Guide.
If you need to download OC use the download link on owncloud.org.

Step two: Mount your existing Windows shares.

Code: Select all

apt-get install smbclient smbfs


This installs the support for smb file systems.

Next, lets mount the shares!

Lets assume I have three shares on two different servers, one located at \\server1\students a second located at \\server2\staff and a third at \\server2\faculty. Also lets assume that the each users files are found one folder below the share root and thats where the users home drive points, like this \\server1\student\user1 and \\server2\staff\staff1 ect... Okay lets move on.

Run:

Code: Select all

mkdir -p /mnt/students

This will make the folder that we are going to use for our mount point, if you have more than one share make a folder in /mnt for each one. In my case: /mnt/students /mnt/staff /mnt/faculty

Run:

Code: Select all

nano /root/.smbcredentials

This makes a file to store our smb credentials credentials in.

While in Nano write two lines:

Code: Select all

username=smbusername
password=smbpassword

Where I have smbusername enter a username that has r/w privileges on the share and the password for that account where i wrote smbpassword.
Save nano by hitting ctrl+o then exit with ctrl+x

Next Run:

Code: Select all

chmod 700 /root/.smbcredentials

This sets the permissions we need on the password file.

Run:

Code: Select all

cp /etc/fstab /root/fstab.bak

This backs up the file that we are about to edit.

Run:

Code: Select all

nano /etc/fstab

We need to add out mounts and smb paths.

Add the following line for each of your mounts. Its might look like more than one line but It is only one!

Code: Select all

//server1/share    /mnt/students       cifs    credentials=/root/.smbcredentials,_netdev,uid=www-data,file_mode=0777,dir_mode=0777 0 0

Save with ctrl_+o and exit with ctrl+x.

Then Run:

Code: Select all

mount -a

This should mount your smb shares to the folders that you've specified.

Run:

Code: Select all

cd /mnt/students; ls -l

You should see a list of all the files and folders on your Windows share! :)
Repeat this step for all of newly mounted shares to ensure they've mounted properly.

You can find more information on mounting Windows Samba share HERE and HERE

Step Three: Combine the mounted shares.

Here I we will use the SMB shares we have mounted at /mnt/students and /mnt/employee for that data directory for two different types of users.

Now here is where things get fun.

Run:

Code: Select all

cd /var/www/owncloud/lib/files/

Code: Select all

cp filesystem.php filesystem.php.bak


From here I suggest you use a text editor like notepad ++ on windows or gedit in linux.
Open filesystem.php with a text editor.

Find:

Code: Select all

$parser = new \OC\ArrayParser();

Note: was around line 221 for me.

Paste This:

Code: Select all

$uname = '';
$uname = \OC_User::getDisplayName($user);

Above

Code: Select all

$parser = new \OC\ArrayParser();

but below

Code: Select all

}


So it should look something like:

Code: Select all

public static function initMountPoints($user = '') {
      if ($user == '') {
         $user = \OC_User::getUser();
      }
      $uname = '';
      $uname = \OC_User::getDisplayName($user);
      $parser = new \OC\ArrayParser();

      $root = \OC_User::getHome($user);


Next Find:

Code: Select all

$option = self::setUserVars($user, $option);

around line 264 and Paste:

Code: Select all

$option = self::setUNameVars($uname, $option);

in a new line below.

It should look something like:

Code: Select all

foreach ($options as &$option) {
   $option = self::setUserVars($user, $option);
   $option = self::setUNameVars($uname, $option);
}


Find:

Code: Select all

private static function setUserVars($user, $input) {
      return str_replace('$user', $user, $input);
   }
and paste:

Code: Select all

private static function setUNameVars($user, $input) {
   return str_replace('$uname', $user, $input);
   }
below the chunk of code you searched for.

It should look like:

Code: Select all

private static function setUserVars($user, $input) {
      return str_replace('$user', $user, $input);
   }
   private static function setUNameVars($user, $input) {
   return str_replace('$uname', $user, $input);
   }


Save the file as filesystem.php and place it back in /var/www/owncloud/lib/files/

You're done with the hard part :)

Run:

Code: Select all

cp /var/www/owncloud/config/mount.php /root/mount.php.bak

This will backup our mounts file. If it does not exist yet, move on to the next step.

EDIT:
The next step can be used with the mount.json file located in /path/to/data/mount.json
In fact you should be using the mount.json file instead of the mount.php file.

Run:

Code: Select all

nano /var/www/owncloud/config/mount.php

Then replace the contents of this file with the code below, make sure to edit the share names and mount points.

Code: Select all

<?php return array (

'group' => array (
   'employee' => array (
      '/$user/files' => array (  'class' => 'OC_Filestorage_Local',  'options' =>   array (    'datadir' => '/mnt/employee/$uname',  ),),
   ),
   'student' => array (
      '/$user/files' => array (  'class' => 'OC_Filestorage_Local',  'options' =>   array (    'datadir' => '/mnt/students/$uname',  ),),
   ),
),
);
 ?>


Finally install the external storage plugin located on the apps page.

If it works your Done! OwnCloud is now directing files to different remote shares based on a users group! 8-)
This is useful for Institutions that already have "Home" drives and don't want to loose the data that is already in place. This simply makes Owncloud another entry point for the "Home" drive.
Last edited by almyz125 on Fri Apr 04, 2014 8:52 pm, edited 2 times in total.

haribo
Newbie
Posts: 2
Joined: Tue Aug 06, 2013 11:06 pm
ownCloud version: 5.0.7
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5

Re: Guide: OC 5.0.X and H-Drive Integration

Postby haribo » Tue Aug 06, 2013 11:10 pm

Hi almyz,

Thanks for the awesome guide! I almost have a working solution based on the above but I'm stuck at actually getting the user share mounted.

If I use mount.php then external storage is mounted (logged in with an admin account, green dot)

If I use mount.json no external storage shows as being mounted - is there any chance you could post a sample of what should be in the mount.json based on the rest of the guide?

Should both mount.php and mount.json work with OC 5.0.7?

Thanks a lot!!

James

RealRancor
ownCloud master
Posts: 17381
Joined: Sat May 26, 2012 3:00 pm
ownCloud version: 9.0.2
Webserver: nginx
Database: MySQL
OS: Linux
PHP version: 7.0.x

Re: Guide: OC 5.0.X and H-Drive Integration

Postby RealRancor » Wed Aug 07, 2013 7:54 am

Hi,

haribo wrote:Should both mount.php and mount.json work with OC 5.0.7?


according to a statement of a dev both should still work but the mount.json is recommended from the security point of view.
*gone*

haribo
Newbie
Posts: 2
Joined: Tue Aug 06, 2013 11:06 pm
ownCloud version: 5.0.7
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5

Re: Guide: OC 5.0.X and H-Drive Integration

Postby haribo » Mon Aug 12, 2013 7:17 pm

Thanks Rancor - I'll start with a fresh install and see if I can make it work!

offerlam
Helpful Elf
Posts: 109
Joined: Thu Jul 25, 2013 2:45 pm
ownCloud version: 5.0.9
Webserver: Apache
Database: MySQL
OS: Linux

Re: Guide: OC 5.0.X and H-Drive Integration

Postby offerlam » Tue Oct 08, 2013 7:33 am

Hi there...

Fantastic guide...

got a couple of question...

How will this show in real life in the users interface?

Normally when you add a SMB stor to a owncloud account it will show as a folder that the user needs to double click in order to see the content..

Im looking for a way in owncloud so that the files view in the users owncloud IS the homefolder. In other words the users doesn't have to double click a folder name in order to enter his or hers home folder.. owncloud files view IS the homefolder ...

I hope i made myself clear?

Is that what your solution provides?

THANKS

Casper
Owner of Ding IT in Denmark
www.dingit.dk
IT-Consultant and hosting buisness

Truth and wisdom comes to all who dare ask

trihta
Newbie
Posts: 1
Joined: Thu Nov 14, 2013 10:53 pm
ownCloud version: 5.0.3
Webserver: Apache
Database: MySQL
OS: Linux

Re: Guide: OC 5.0.X and H-Drive Integration

Postby trihta » Thu Nov 14, 2013 11:01 pm

@offerlam - That's exactly what this solution provides.

I must also say, that this is awesome solution and guide.
But now I have problem regarding NTFS ACL. Whenever I upload file using owncloud the file doesn't inherit home folder permissions. It gets only System and Administrators group, but not the user, to whom the home folder belongs.
"Service account" that is used to mount home folder share on ubuntu is member of administrators group on file server.
File server is Win 2k8R2.

Any idea how to resolve that issue?

peterho
Newbie
Posts: 2
Joined: Thu Jan 02, 2014 6:57 am
ownCloud version: 6.0.0a

Re: Guide: OC 5.0.X and H-Drive Integration

Postby peterho » Thu Jan 02, 2014 8:53 am

trihta or almyz125,
any news on the service account issue? I'm about to trial your fix on v6 and I'm keen to make sure the permissions on user folders are retained for new folders and files created through OC.

Any help would be greatfully received...

Peter

lanks
Newbie
Posts: 1
Joined: Thu Feb 13, 2014 5:43 pm
ownCloud version: 6.0.0a
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.3.10

Re: Guide: OC 5.0.X and H-Drive Integration

Postby lanks » Thu Feb 13, 2014 5:47 pm

What NTFS permissions are on the user's folder vs on the files uploaded by ownCloud?

jcodinaown
Newbie
Posts: 2
Joined: Sat Mar 01, 2014 8:30 pm
ownCloud version: 6.0.1
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: unknown

Re: Guide: OC 5.0.X and H-Drive Integration

Postby jcodinaown » Sat Mar 01, 2014 8:33 pm

The folder files in /var/www/owncloud/lib/files/ does no longer exist in 6.0.1. Instead, the content of /var/www/owncloud/lib is now:

autoloader.php base.php l10n private public

Any guidance on where to do the last changes?

almyz125
Beginner
Posts: 26
Joined: Thu Feb 21, 2013 1:43 am
ownCloud version: 5.0.5
Webserver: Apache
Database: MySQL
OS: Linux
PHP version: 5.3.3

Re: Guide: OC 5.0.X and H-Drive Integration

Postby almyz125 » Tue Mar 04, 2014 9:31 pm

jcodinaown wrote:The folder files in /var/www/owncloud/lib/files/ does no longer exist in 6.0.1. Instead, the content of /var/www/owncloud/lib is now:

autoloader.php base.php l10n private public

Any guidance on where to do the last changes?


I have not yet looked at OwnCloud 6. I will work something out and post a guide.


  • Similar Topics
    Replies
    Views
    Last post

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 1 guest