Posted on 03-03-2016 09:31 AM
Looking for an "easy" way to auto mount user specified network shares at login. We currently have Users & Groups locked down in system preferences. Having users set their auto mounts via script and launch agent is complicated and overkill. Any easier options i can distribute instructions for users?
Posted on 03-03-2016 09:59 AM
I didn't write this script but forgot who on JamfNation posted it so I can't give credit. I am using the below on a login trigger with the $4, $5, and $6 variables populated in the policy. I adjust the scoping based on who needs to mount the volumes.
I am currently using:
#!/bin/sh
currentUser=$(ls -l /dev/console | awk '{ print $3 }')
echo "Current User: $currentUser"
UID1=$(id -u $currentUser)
echo "UID: $UID1"
protocol="$4" # This is the protocol to connect with (afp | smb)
echo "Protocol: $4"
serverName="$5" # This is the address of the server, e.g. my.fileserver.com
echo "Server: $5"
shareName="$6" # This is the name of the share to mount
echo "Sharename: $6"
if [[ "$UID1" -lt 1000 ]]; then
echo "$currentUser is a local user. This script will now quit"
exit 1
fi
if [[ "$UID1" -ge 1000 ]]; then
echo "User $currentUser is an Active Directory account"
# Mount the drive
mount_script=`/usr/bin/osascript <<EOF
tell application "Finder"
activate
mount volume "$protocol://${serverName}/${shareName}/"
end tell
EOF`
fi