How to make a variable symlink ? (or something similar)
Solution 1
For those people viewing this more recently, I've written a small FUSE filesystem called HomeFS that forwards calls to a directory relative to the calling users' home directories.
That is, if you have a user Tyler and a user Sarah with a HomeFS mountpoint at /usr/share/bigsoft/config
and a relative directory of .config/bigsoft
, when Tyler does ls /usr/share/bigsoft
he will see the contents of /home/tyler/.config/bigsoft
and Sarah will see the contents of /home/sarah/.config/bigsoft
.
Primarily, this is to work around proprietary software which insists its variable files be in some 'install directory', like how some Windows software tends to work.
Solution 2
This depends on whether the app config can process commands or interpolate shell variables.
The bash login shell sets the environment variable LOGNAME in a login shell.
You could use /svn/${LOGNAME}/ in the config, if the application interpolates shell variables in config. Then you can share common config with each user referring to her own path.
If the application does not interpolates shell variables in config, then you can create a symlink for each user making generic reference to /svn path and use the generic name in the shared config.
who
will list the current username.
If you want to write a script that each user executes once upon setup to create a symlink.
ln -s /svn/$(who) /svn/anyuser
Then share common config referring to /svn/anyuser (pick a generic name that suits you)
Beware the noob user unaware of links use and removes it (you've just been promoted to admin :)
Solution 3
GFS or OCFS can be used to achieve your goal. Both file-systems can present the same mountpoint with different contents based on various things. Both are meant to be used as cluster file-systems and have that ability to present the same directory with different content for different architectures.
The question that arises to me if this is worth the effort. I am sure you can solve this with other tricks (maybe an executable automount-map?).
Solution 4
So you want each user to see different thing in the file system. Unix isn't really designed that way (VMS and Plan9 makes it easier).
The only method I know, is using chroot(), but then you mask everything not in the hierarchy where you switched, symbolic link will stay in your hierarchy, and hard one aren't helpful with directories. It should be possible to use a FUSE file system to mirror the true root while providing the view you want. You'd then chroot to that position. If you don't find an existing one suiting you, you could write one...
Related videos on Youtube
Offirmo
Updated on September 18, 2022Comments
-
Offirmo over 1 year
How can I make a variable symlink that would point to a different location according to the current user? Is it possible? Should I use something else instead? A mount point? How?
Here is the problem in case you come across a different solution:
Here at work we are a team developing on Unix with SVN. We all use the same development machine (remotely). So we have checkouts in different places (not /home but a specific dir mounted on another disk, let's say /svn/[userlogin]/).
We use scripts and tools. Some special tools have a complex configuration and project file that includes the path of the source files. This is error prone and we lose a lot of time because of bad config or 'projects' that need to be recreated all the time. I would like to share this complex configuration and the project files across all developers.
But for such files to be shared while working on different checkouts, I must either:
- correct on-the-fly the paths stored in config/project to adapt them to the current user
- make a "magic" fixed path that symlink/mount/point points to a different place according to the user (so same project file but pointing to different source)
Before that we used clearcase, which was mounting a view of the same path for everyone (let's say /vob), each developer seeing his or her own view. That was convenient.
How can I do a similar thing? Can you think of another solution? Thanks.
-- Edit --
I was thinking of Eclipse IDE. I want to share some workspace settings, the project and the run/debug configurations. Eclipse (+plugin) settings consist of 50+ small files, so editing them is out of question.
With clearcase it was easy thanks to the fixed "/vob" path which, for each terminal, was automatically pointing to the "view" we choose.
I would like something similar. I want a /svn/mysource which, for each terminal, point to the user current checkout, which is in a user-dependent path.
-
Alen Milakovic over 12 yearsI'm unclear why every user needs to have the paths point to a different place. Can't they share the same files? If not, it should be possible to set things up so that the paths differ only in minor respects, i.e.
/srv/username/...
. They one could easily script the config paths user environment variables like the usernameUSER
. -
Offirmo over 12 years@FaheemMitha edited the question to precise that we are using the same machine (remotely)
-
Alen Milakovic over 12 yearsYou can't easily have a fixed path which points to a different place for each user. Can you elaborate on how Eclipse views this? Does it expect a fixed path, or can it be persuaded to look at some environment variable? If so, you could configure such an env variable accordingly.
-
Offirmo over 12 yearsThanks but I edited the question to precise that we are all using the same machine, hence the problem.
-
bsd over 12 yearswithout describing what type of scripts(bash, python, perl) and which applications you're using, you're making it difficult for someone to offer helpful advice. Regardless of how many machines are being used, it's a linux box and all users login using individual usernames, yes?