I'm trying to sort out a way to access an NFS share (ideally all privileges, but I'll settle for read only for now) from our application in Java. I've spent most of the day researching and the closest I came was the yanfs project (nee WebNFS) but it doesn't seem to have been updated since the aughties and it doesn't have any documentation either. I ran some low grade experiments with it but those were unsuccessful.
Because of the nature of our application, I can't pre-mount the volumes (there could be zero to many) and I would like to avoid calling sudo mount
inside the program if at all possible. Unfortunately this approach is the only semi-viable solution I can come up with. Any suggestions would be welcome.
Also: No modern NFS java client libraries? Really? That can't possibly be right.
Since time is of the essence, we're going to cheat a bit for now. So this is the solution I worked out in case anyone comes along later.
I looked into autofs like @dsh suggested. With Autofs I set up the /etc/auto.master
file to have the following line:
/mnt/fromNFS /usr/local/etc/auto.fromNFS --timeout=60
I then touched the /usr/local/etc/auto.fromNFS
and changed its ownership to the user and group that is to run the app.
Now I can anagrammatically modify the auto.fromFNS file to include lines for the given nfs share. When I then go to access that directory, it nicely gets mounted with no need to sudo
.
Its not ideal but it looks like it will get the job done for now.
Thanks to everyone for their suggestions.