Hello All,
We have been working on a way to map network drives for our users. I have looked at the examples that were posted on the MacMule site and tried to use that as a template for our environment. Unfortunately we ran into some issues right off the bat, such as AD not properly showing group memberships.
We decided to bypass this and attempt to put some logic into our own script so it would map users drives based on the logged in user. Depending on the first letter of your username, depends on which data volume you are on. Then there is a folder for the first letter of your username, and in there is your personal network storage. The other problem was mapping shared drives, but this seems to be working ok as these folders all reside on the same volume.
My problem is, the script works fine when being run from self service, but not if I assign it as a login hook. I am trying to figure out how I can get this to run at login, and a way (other than self service) to get this to operate whenever the user needs to remount their drives. After sleep, if connecting in via VPN, etc.
What would you recommend, and does anyone have any suggestions on my script? Thanks for any suggestions.
Joe
#!/bin/sh
echo "$USER = $USER"
checkGroupMembership() {
#if dsmemberutil checkmembership -U $USER -G $group | grep -iq "user is a member of the group"; then
if [[ $(dsmemberutil checkmembership -U "$USER" -G "$1") =~ "is a member" ]]; then
return 0
else
return 1
fi
}
# Group for personal storage for nonperson accounts
#group="storage-data-GENERIC-mapdrive"
# Group for personal storage for person accounts
#group="storage-data-${USER:0:1}-mapdrive"
# Mount Personal storage (G:) for person accounts
# XXX: Handle mounting Personal storage (G:) for nonperson accounts from smb://storage3.mydomain.com/DATA3/GENERIC/${USER}
case ${USER:0:1} in
[a-gA-G]*)
echo "DATA1 (a-gA-G) case reached"
# open "smb://storage1.mydomain.com/DATA1/${USER:0:1}/${USER}"
#if checkGroupMembership "storage-data-${USER:0:1}-mapdrive"; then
osascript -e "try" -e "mount volume "smb://storage1.mydomain.com/DATA1/${USER:0:1}/${USER}"" -e "on error" -e "end try"
#else
# echo "User "$USER" is not a member of Group "storage-data-${USER:0:1}-mapdrive""
#fi
;;
[h-mH-M]*)
echo "DATA2 (h-mH-M) case reached"
# open "smb://storage1.mydomain.com/DATA2/${USER:0:1}/${USER}"
osascript -e "try" -e "mount volume "smb://storage1.mydomain.com/DATA2/${USER:0:1}/${USER}"" -e "on error" -e "end try"
;;
[n-sN-S]*)
echo "DATA3 (n-sN-S) case reached"
# open "smb://storage1.mydomain.com/DATA3/${USER:0:1}/${USER}"
osascript -e "try" -e "mount volume "smb://storage1.mydomain.com/DATA3/${USER:0:1}/${USER}"" -e "on error" -e "end try"
;;
[t-zT-Z]*)
echo "DATA4 (t-zT-Z) case reached"
# open "smb://storage1.mydomain.com/DATA4/${USER:0:1}/${USER}"
osascript -e "try" -e "mount volume "smb://storage1.mydomain.com/DATA4/${USER:0:1}/${USER}"" -e "on error" -e "end try"
;;
*)
echo "Default case reached"
;;
esac
# Mount Shared storage (T:) for all accounts
echo "SHARED case reached"
# open "smb://storage1.mydomain.com/DATA4/${USER:0:1}/${USER}"
osascript -e "try" -e "mount volume "smb://sharepoint.mydomain.com/SHARED"" -e "on error" -e "end try"
exit 0