You are here
JP - Thu, 2018/10/18 - 05:03
Hi Folks,
Just wondering if it is possible to create a template folder structure for each users home share.
Effectively when I add a user, a template folder structure will automatically build itself.
Example:
-user1
-folder1
-folder2
-------------------------
-user2
-folder1
-folder2
Any help would be great, cheers!
Forum:
Yes, can certainly be done.
Assuming that you use the fileserver appliance in it's default "stand alone" configuration, then Samba (i.e. Windows) users are mapped to Linux users. And Linux has a cool feature when the directories and files which appear in /etc/skel will be added to any newly created user accounts. So in that scenario, it'd be super simple. Just create your desired structure in /etc/skel and it'll get auto applied whenever you create a new user. TBH, I haven't tested it with empty directories, but I'd assuming that it'd work the same.
If you have your fileserver as a Windows AD domain member, then it's not quite so easy, as all the individual Samba/Windows users, actually run under a single Linux user account. Because of the nature of Linux, I'm certain that you could script something to create the required file structure when required, but TBH, how you would trigger that, I'm not so sure.
If you're in the second category, then it might be worth asking on one of the stack exchange sites, or on the Samba mailing list.
Please post and let me know how it goes.
Scenario #1
Mate, you are a legend! I'm doing it in stand alone mode currently. Once I get more familliar with this system I reckon I'll give it a crack and let you know how I go.
Cheers.
Awesome - glad to help! :)
Also I just updated my earlier post to clarify that this will only work for newly created users. Unfortunately if you've already created the new users, then this won't work.
However, you could create the folder hierarchy for existing users pretty easily with a script if you wanted (and this could be modified to work in scenario 2 as well). Assuming that all the Linux user home directories are in the default place (/home/USERNAME) then this should do it:
This won't care if the required directories already exist or not.
In scenario 2, you could probably just run that as a cron job. You'd also have to adjust the default user home base directory. OTTOMH, I'm not sure what it is, but once you work it out, adjust
/home/*
to be/full/path/to/user/homes/*
. I'm not necessarily saying that's the best way, but it's one way! :)No worries.
Yeah, I noticed that was the case.
It's a brand new server so I should be good for now, but I'll keep that script in mind for a later date.
Thanks.
Add new comment