1

I'm wondering if anyone knows of a nice way to partially duplicate (hard link) files between two directory structures?

My current fall back is a script invoked by cron.

As background:

I ask since I have two groups who both need to access a body of files in a directory structure served via HTTP using Tomcat. A privileged group may access all the files and a less privileged group may only access a "public" subset. These sets are not aligned to particular directories but the different class of file can be identified by their naming convention (but not extension).

Therefore my current idea is to serve two separate directories, one containing only private (possibly password protected) and the other containing public. Then to run some periodic process whereby I create hardlinks from the public files so they appear in the private directories for the convienence of the privileged users. I choose to link in that direction since it's more important that the file is available immediately for the unprivileged users. (priv = admin, unpriv = regular user)

I hope that makes sense. I'll try to clarify if anyone has any questions.

Tom Duckering
  • 235
  • 1
  • 13

2 Answers2

1

I would use symbolic links.

You could use this Bash script:

#!/bin/bash
ln -s $1 $2/$(basename $1)

with something like these two commands:

find unpriv_criteria -exec ./linkscript {} /unpriv/dir \; 
find priv_criteria -exec ./linkscript {} /priv/dir \;
Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
  • Why do you recommend soft links? I was prefering hardlinks since I won't have to configure Tomcat to follow soft links. In addition it would afford me the luxury of being able to remove files from the public directory without removing it from the private directory. Hope that makes sense? – Tom Duckering Jan 14 '10 at 06:43
  • Here is a discussion of hard and symbolic links: http://serverfault.com/questions/10543/what-is-the-difference-between-a-soft-symbolic-link-and-a-hard-link – Dennis Williamson Jan 14 '10 at 09:18
  • Thanks for the link. I know the difference and the pros/cons but was wondering why you explicitly recommended using soft links. – Tom Duckering Jan 14 '10 at 09:27
0

Something like what Dennis proposed would work in a cron job or similar.

If this were linux, I would point you at inotify which would allow you to eliminate the cron job and latency from hardlinks reflecting the original directory.

This doesn't appear to exist under Solaris, however.

If the hardlinks are not too critical, a cron job will probably do just fine.

prestomation
  • 586
  • 3
  • 8