Guide: OC 4.5.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 4.5.X and H-Drive Integration

Postby almyz125 » Fri Feb 22, 2013 5:13 am

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

OC 6.0.X tutorial here.
OC 5.0.X tutorial here.

Step one: OwnCloud prerequisites and OwnCloud

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

Once you install Debian
Run:

Code: Select all

apt-get update

The command above updates your apt cache.

Then run:

Code: Select all

apt-get install apache2 php5 php5-gd php-xml-parser php5-intl

This installs REQUIRED prerequisites for OwnCloud.

Optionally run:

Code: Select all

apt-get install php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl

This installs some more packages for OwnCloud, you don't absolutly need these for OwnCloud, but you will need the smbclient in the command above to mount the Windows file shares.

Next Run:

Code: Select all

echo 'deb http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_6.0/ /' >> /etc/apt/sources.list.d/owncloud.list

This adds the OwnCloud repository to your /etc/apt/sources.lst

Then Run:

Code: Select all

wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_6.0/Release.key
apt-key add - < Release.key

This adds the key required to download files from the Repository.

Then Run:

Code: Select all

apt-get update

Update your apt cache again.

Run:

Code: Select all

apt-get install owncloud

This command will install the latest stable release of owncloud.

At this point you have a working Owncloud install on your Debian box using Apache! Give yourself a pat on the back for not using Windows and IIS! :P Don't log into OwnCloud just yet! We wont be doing that until the end of the tutorial.

The steps above can be found Here and Here

Step two: Mount your existing Windows shares.

If you did not run the optional command in the first part
Run:

Code: Select all

apt-get install smbclient

This installs the files you need to connect to Windows shares.

You Must Run:

Code: Select all

apt-get install 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.
We will do this by using a the External Storage Plugin.

First make your Owncloud data directory outside of the webroot

Code: Select all

mkdir /data

Make data directory

Code: Select all

chmod -R 770 /data

Set permissions

Code: Select all

chown -R www-data:www-data /data

Give ownership to the www-data user.

Log into your Owncloud install and set the the user data directory to the folder you just created.
This can be done by clicking the advanced drop down button and enter the path there.
So put:

Code: Select all

/data

In that field.

This directory would normally contain each users files within a folder named after their username.
Example: /data/user1 Then deeper /data/user1/files. The /files folder under the username folder is the directory where the files would normally end up.

Our Setup is going to use the /files for the mount point within the external storage app.

Logged in as your admin accout:
  • Click on the settings button and click users.
  • Then create two test users we'll call them cloudstu and cloudemp.
  • When creating the users create a different group for each. In my case one called students and one called employee.

As your admin user:
  • Install the External Storage Support app from the apps page.
  • Go to Admin under Settings.
  • You'll now see a section for external storage support. We aren't going to use the web gui since its buggy.

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.

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/$user',  ),),
   ),
   'student' => array (
      '/$user/files' => array (  'class' => 'OC_Filestorage_Local',  'options' =>   array (    'datadir' => '/mnt/students/$user',  ),),
   ),
),
);
 ?>


Now when you log into Owncloud as either of the accounts that you've made your data will be going to your windows shares. If there was already some files in that users share then the data will show up if you've done everything right. Make sure you can write to the share from Owncloud. If you can't then somewhere along the line you did not set your permissions right.

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.

More info on the mount.php file can be found Here

Note!

This can be expanded upon by using the ldap plugin to add your users automatically from Active directory. As of now I have not come up with a way to determine the group of a user automatically and set it. If I do I will add it to the guide.

If anyone can expand on this or improve this method please post!
Last edited by almyz125 on Fri Apr 04, 2014 8:52 pm, edited 6 times in total.

cedwards
Newbie
Posts: 4
Joined: Sun Mar 10, 2013 5:53 am
ownCloud version: 4.5.7
Webserver: Apache
Database: MySQL
OS: Linux

Re: Guide: Use Active Directory "Home" drive to store OC fil

Postby cedwards » Tue Mar 12, 2013 5:48 am

Aweosme tutorial. It's helped me a lot.

Is it possible to mount /server/share/username instead of /server/share/username/files?

I want the first folder you see in OwnCloud, to be their homedrive.

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: Use Active Directory "Home" drive to store OC fil

Postby almyz125 » Tue Mar 12, 2013 6:34 am

The mount.php file can be used to take care of this if you look at my example you'll see that is mounts the users h drive in the /$user/files thus combining them.

cedwards
Newbie
Posts: 4
Joined: Sun Mar 10, 2013 5:53 am
ownCloud version: 4.5.7
Webserver: Apache
Database: MySQL
OS: Linux

Re: Guide: Use Active Directory "Home" drive to store OC fil

Postby cedwards » Tue Mar 12, 2013 6:59 am

Thanks for your prompt reply!


edit:
I just reread what you said!
Got it working now ;)

Thank you!

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: Use Active Directory "Home" drive to store OC fil

Postby almyz125 » Tue Mar 12, 2013 1:51 pm

cedwards wrote:Thanks for your prompt reply!


edit:
I just reread what you said!
Got it working now ;)

Thank you!


No problem! Glad to help.

psutton00
Beginner
Posts: 14
Joined: Tue Mar 12, 2013 2:45 pm
ownCloud version: 4.5.7
Webserver: nginx
Database: SQLite
OS: Linux
PHP version: 5

Re: Guide: Use Active Directory "Home" drive to store OC fil

Postby psutton00 » Thu Mar 14, 2013 12:44 pm

I am hoping ANYONE can help me. After successfully following your guide and incorporating active directory. I have come across a stumbling block. I am attempting to give access to more than one windows share to all users. Their home directory and at least one other share. I am attempting to do this by having two directories in owncloud. One leading to their home directory and one leading to the other share(s) How do I go about doing this?

I have mounted all shares successfully. I had to use cifs-utils instead of the smb-client and smbfs. But I am guessing that shouldn't make a difference. I have tried editing the mount.php in /var/www/owncloud/config without success. Is this even possible? I have my doubts. As far as I know there is only one OC_Filestorage_Local variable.

Thankyou. Any help would be greatly appreciated!

I'm running owncloud on Ubuntu Server 12.10. Using a LAMP setup.

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: Use Active Directory "Home" drive to store OC fil

Postby almyz125 » Thu Mar 14, 2013 5:28 pm

psutton00 wrote:I am hoping ANYONE can help me. After successfully following your guide and incorporating active directory. I have come across a stumbling block. I am attempting to give access to more than one windows share to all users. Their home directory and at least one other share. I am attempting to do this by having two directories in owncloud. One leading to their home directory and one leading to the other share(s) How do I go about doing this?

I have mounted all shares successfully. I had to use cifs-utils instead of the smb-client and smbfs. But I am guessing that shouldn't make a difference. I have tried editing the mount.php in /var/www/owncloud/config without success. Is this even possible? I have my doubts. As far as I know there is only one OC_Filestorage_Local variable.

Thankyou. Any help would be greatly appreciated!

I'm running owncloud on Ubuntu Server 12.10. Using a LAMP setup.


Could you be more specific, give me an example of your file shares? Its probably possible, you might have to use a fuse file system like mhddfs.

psutton00
Beginner
Posts: 14
Joined: Tue Mar 12, 2013 2:45 pm
ownCloud version: 4.5.7
Webserver: nginx
Database: SQLite
OS: Linux
PHP version: 5

Re: Guide: Use Active Directory "Home" drive to store OC fil

Postby psutton00 » Thu Mar 14, 2013 6:00 pm

Yes. The shares are hosted on Windows servers I'd guess they are SMB shares. One is a user share. The other simply contains data. I don't need to reference any users. I can handle the shares fine it's simply the fact that I don't know how to access more than one using the mount.php. For example; staff need to be able to see their "Home Folder" and the Digital Arts Shared folder. Possibly more. But I figure if I crack it with two shares I can crack it for 20. The problem with the mount.php in your guide is that it is group based. However user based share access would simply be ridiculous for us to implement as we have a large amount of staff and students. Over 2000! The moment I want to give access to share within the same group I have a problem due. I believe it's due to the lack of multiple variables capable of storing mounted share information.

I work for a school and we are trying to implement a cloud so we can use different devices. Possibly ending up with a BYOD system.

Just so you know I don't know what mhddfs is and/or it's purpose!?

Thankyou very much for your excellent guide and help!

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: Use Active Directory "Home" drive to store OC fil

Postby almyz125 » Thu Mar 14, 2013 6:28 pm

You and I are in very similar situations, I work at a university which has around 1,500 students (undergrad) plus faculty and staff. I originally developed this method to solve ONE of our issues, which is that our students home folders are located on a different server than our employees.

To get started solving your issue, try mounting both servers using cifs (used to mount samba shares, explained above.) in two differnt folders something like /mnt/homes /mnt/digital-arts.

then try a mount.php similar to this.

Code: Select all

<?php return array (

'group' => array (
   'digital-arts' => array (
      '/$user/files/digital-arts-share' => array (  'class' => 'OC_Filestorage_Local',  'options' =>   array (    'datadir' => '/mnt/digital-arts', 
        ),
     ),
   ),
),

'user' => array (
   'all' => array(
      '/$user/files/h-drive' => array (  'class' => 'OC_Filestorage_Local',  'options' =>   array (    'datadir' => '/mnt/homes/$user', 
         ),
      ),
   ),
),

);


This mount.php should mount the users home drive in /data/$user/files/h-drive for all users and should mount the digital-arts-share at /data/$user/files/digital-arts-share.

A few things to note, this will create a folder in the users owncloud directory called h-drive, if they want their files on their h-drive they have to store them in this folder, anything placed on the root of their user folder will be stored on the owncloud server it-self. If you want a user to have access to a department share then they should be put in a group that we can refer to in the mount.php file eg 'digital-arts' this then makes another folder inside their user folder called 'digital-arts-share'.

I haven't tested this out, let me know if any of that helps, and if it works for you.

psutton00
Beginner
Posts: 14
Joined: Tue Mar 12, 2013 2:45 pm
ownCloud version: 4.5.7
Webserver: nginx
Database: SQLite
OS: Linux
PHP version: 5

Re: Guide: Use Active Directory "Home" drive to store OC fil

Postby psutton00 » Thu Mar 14, 2013 9:53 pm

I will try this ASAP. I am either going to give it crack tomorrow or tonight. Depends on how sad I am :lol:

I am a placement student doing Computer Security at De Monfort University. Go back for my final year in September this year. I am hoping to get down and dirty with some serious PHP. I did not think of using using all users! But I like how this looks. It makes sense considering all users will be certainly want their "home directory". I just worry as to what I said in my previous post. I don't think by looks of things I will be able to mount much more than two shares per user. Unless I do the odd individual mount for unique users.

Thanks for your help. Whether I am successful or not, I will be back! YOU THE MAN! 8-)


  • Similar Topics
    Replies
    Views
    Last post

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 2 guests