Mount multiple SMB shares at log in to desktop?

mpittcasd
Contributor

I'm trying to work out a script that will mount SMB shares and have them available on the desktop for the users. I searched around and did come upon a few posts that helped get me started, but I'm not sure where it's getting stuck now.

My script looks like this:

#!/bin/sh
defaults write com.apple.finder ShowMountedServersOnDesktop -bool True

mkdir -p /Users/$3/Desktop/Public
mkdir -p /Users/$3/Desktop/Home

mount -t smbfs //fileserver/staff/$3 /Users/$3/Desktop/home
mount -t smbfs //fileserver/Public /Users/$3/Desktop/public


exit

When I create a policy with this script for login, it doesn't give any errors in the log, but it only mounts up to the Staff share and appears on the desktop and the public share doesn't appear on the desktop. I converted it to an AppleScript which worked ok, sometimes it would only create the folders on the first run and then mount them on the second, but I am not sure how to get the Applescript to be deployed at logon through JSS and what I would need to modify for it to run with the logged in account.

I did see the website that shows how to add shares and printers based on the user group membership in AD, but I'm trying to keep it as simple as possible right now.

Thanks in advance.

2 REPLIES 2

jarednichols
Honored Contributor

You may instead want to make your mount points in /Volumes. Items mounted to /Volumes should show on the Desktop anyway. Not saying that's the problem but it would simply things. You could also try using the jamf binary to mount instead as well.

mpittcasd
Contributor

This is the error I'm getting now using sudo -u $3 jamf mount etc

/usr/sbin/jamf is version 8.6 Executing Policy Mount Home Folder Staff... Mounting afp://casdmac.chambersburg.localnet/CasperShare to /Volumes/CasperShare... Mounting smb://casdjamf.chambersburg.k12.pa.us/CasperShare to /Volumes/CasperShare... Running script MountHomeDriveStaff.sh... Script exit code: 1 Script result: Mounting smb://10.210.0.13/staff/mike.pittenger to /Volumes/staff/mike.pittenger... There was an error mounting the file server smb://10.210.0.13/staff/mike.pittenger. Will attempt again. Mounting smb://10.210.0.13/staff/mike.pittenger to /Volumes/staff/mike.pittenger... There was an error mounting the file server smb://10.210.0.13/staff/mike.pittenger. Giving up. Mounting smb://10.210.0.13/Public to /Volumes/Public 1... There was an error mounting the file server smb://10.210.0.13/Public. Will attempt again. Mounting smb://10.210.0.13/Public to /Volumes/Public 1... There was an error mounting the file server smb://10.210.0.13/Public. Giving up. Unmounting file server...

When I try with mount -t smbfs I get this error:

mount_smbfs: mount error: /Volumes/Home: File exists mount_smbfs: mount error: /Volumes/Public: File exists

Either way the Staff share is being mounted in Volumes and asks for a user name and password at login, but Public still doesn't get mounted. Is there something special I need to do since both shares are on the same server?

I did see your script when you tried to set shares to the dock, and I tried parts of it but couldn't get anything to work. Is there a way I can have root run the commands so there aren't permission errors, but mount the share based on the user's information without them needing to enter their password?