Mount smb server 'tree'

Hi there, I have some smb file servers (about 10) that I want to mount in a folder structure by running a script.

To make it visual:

/Volumes/company/management         - smb://fileserver1/mgmnt
/Volumes/company/Video
/Volumes/company/Video/public       - smb://fileserver2/public_video
/Volumes/company/Video/internal     - smb://fileserver1/internal_video
/Volumes/company/projects
/Volumes/company/projects/A         - smb://fileserver3/A
/Volumes/company/projects/B         - smb://fileserver3/B

(Obviously, I got a list of folder path and corresponding server shares to start from.)


The user will have to log in with his/her/it's user credentials and it would make sense if the user only has to enter these details once when running the script.


The first step to automating is doing it manually. While doing so, I noticed that if I 'connect to server..' from within Finder I'm asked for credentials once: on my first file server. When I connect to another server, osx seems to try the credentials it already has and it can connect to the second server without asking for a password again. This also works from AppleScript with


tell app "finder" to mount volume "smb://fileserver1/shareA"
tell app "finder" to mount volume "smb://fileserver2/shareB"


Unfortunately this lacks mount destination.


The only way I found for setting the mount destination is from bash with variants of mount/mount_smbfs that require a username and password to be entered for each and every one of them:

mount_smbfs //user:pass@filerserver1/shareA /Volumes/company/folderA


Any idea how I can get the best of both worlds?


Thanks!

Posted on Apr 26, 2019 3:23 AM

Reply

Similar questions

19 replies

May 17, 2019 2:02 PM in response to rccharles

Thanks @etresoft, that is quite clear. It is also more or less the approach I'm currently on. I've got a bash script that uses a tiny piece of appleScript to 'tell finder to mount the share'. That way I don't run into the username/password issues, or at least get a finder box that asks for credentials, and I'm not stuck in AppleScript all the time.


When a folder is mounted, the bash script checks where in /Volumes/ exactly the mount has been created and symlinks (alias might have been an alternative) it to a central directory in ~/Desktop/CompanyServers/.


This 'CompanyServers' folder on the user's desktop, is a tree of folders and symlinks. I know for sure that the less tech-savvy users will open this folder and assume that everything in there is on the server. To give a concrete example: say I have an external user coming in for a couple of days and he has a video that is meant for everybody. Our current folder sturcture is as follows:

~/Desktop/CompanyServers/Video/
~/Desktop/CompanyServers/Video/Public -> /Volumes/share1/subfolder2
~/Desktop/CompanyServers/Video/Internal -> /Volumes/share3/subfolder4

and this user decides ~/Desktop/CompanyServers/Video is the perfect spot to copy their folder Everybody.

When the user copies the files to the .../Video folder, the user will have the idea everything ended up on the server as it is filed under the .../CompanyServers folder. Though in reality, the folder Everybody was only copied to a subfolder the user's Desktop.


The issue I'm facing is: how do I protect these folders from writing? I appologize for this misunderstanding @rccharles, it seems I've been a bit too brief in my previous reply. It's not a server permission issue, it's a local issue. These folders are owned by the user. So I can easily do a chmod 500 to restrict write access. Unfortunately, whenever Finder runs into this, it simply asks for elevated privileges with a popup for the username and password and writes to it anyways. This even happens when I 'chown root:root' the folder. Is there any way to block writing to a folder on the Desktop?


Thanks

May 17, 2019 3:55 PM in response to mdirickx

Ok, I understand their on there own machine and you want to simplify things for the user.



But they are not discouraged by:


mac $ pwd
/Users/mac
mac $ ls -ld videotest/
dr-x------  5 mac  staff   170B May 17 18:38 videotest//
mac $ ls -l videotest/
total 0
-rw-r--r--  1 mac   staff     0B Apr 19 19:25 echo
-r-x------  1 root  staff     0B May 17 18:35 one*
-r-x------  1 root  staff     0B May 17 18:35 two*
mac $ 

and there not discouraged by the subsequence message that they will not be able to see it again?



May 17, 2019 4:05 PM in response to rccharles

You could put a folder action on the folders you do not want them to add junk and ask them where to move the file to; should they not follow instructions. You can suggest the valid folders. for the move You could write apps for each of the folders and have them drop the files they want to save on the "correct" server and have the app copy the files to the server. This way the file will end up on the server or on the desktop. Of course if they want to look at the server ? double click is view or drop is copy. Of course, they could look around and see what is going on.


You want to assist the user from making an accidental mistake. You would need some other method for the malicious user.


No perfect world. I'd check out acl's and see if they have any more power.


R



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Mount smb server 'tree'

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.