Posted on 06-14-2017 11:15 AM
I am wondering how everyone is handling mapping home folders in Yosemite and up. Previously the school used a custom Package that would run a script to mount student home folders. This broke after upgrading to Sierra.
Currently I have the option "Use UNC path from Active Directory to derive network home location" enabled. This puts the globe in the Dock and when they click on the globe, it will mount their Home folder on the Desktop. There are 2 issues with this currently. First, it mounts the root path of their home folder, so instead of mapping fileserverstudentsjsmith, it is mapping fileserver. I found a script to just hide this mount so that isn't as big of a deal. Second, every time the Macbook is restarted, the mount is missing from the Desktop and the student has to click the globe again and then it will reconnect and show up on the Desktop. Is there a way to just make that mount once and re-connect every time the student logs in rather than them having to click the globe and then go to the drive?
Posted on 06-14-2017 02:12 PM
I use a script Casper on a login trigger that reads the location from AD and then mounts the drive with an applescript call. The other common way is to have a launch agent that does the same thing.
Posted on 06-15-2017 10:20 AM
Can you share the script with me by chance? Just so I can get idea of how to do this.
Posted on 06-15-2017 03:17 PM
Sure.
If you don't pass it any share path it defaults to the users home drive.
I normally run a seperate policy for each share to be mapped and use the policy scoping to determine who it should run for.
Feel free to use as you please.
If you search around there are a few other ways to do this as well, I just like keeping it all within Casper personally especially as you can also make it available in Self Service to allow people to remount any lost ones or after waking the machine from being at home.
#!/bin/bash
#2017 Version Samuel Look
#All care no responsibility
#Mounts the requested share if it doesn't already exist if left blank it will attempt to mount AD SMBhome
#Accepts shares in the form smb://server/share
#Intended to be run as a Login policy from Casper on AD bound machines only and has only been tested in this context.
##### Start seperate process #####
(
##### SUBROUTINES #####
Share_Path_Valid() {
if [[ -z "$Share_Path" ]]; then
Machine_Domain=$(dscl /Active Directory/ -read . SubNodes | awk '{print $2}')
Share_Path="$(dscl "/Active Directory/$Machine_Domain/All Domains" -read /Users/$Current_User SMBHome | awk '!/is not valid/' | sed -e 's/SMBHome: /smb:/g' -e 's/\///g')"
fi
if [[ "$Share_Path" ]]; then
logger "Sharemount:$Share_Name Path check PASS $Share_Path"
return 0
else
logger "Sharemount:$Share_Name Path check FAIL"
return 1
fi
}
#####
User_Ready() {
Loop_End=$((SECONDS + 60))
Current_User=$(stat -f%Su /dev/console | awk '!/root/')
while [[ -z "$Current_User" ]] && [[ $SECONDS -lt $Loop_End ]]; do
sleep 10
Current_User=$(stat -f%Su /dev/console | awk '!/root/')
done
if [[ "$Current_User" ]]; then
logger "Sharemount:$Share_Name User check PASS $Current_User"
return 0
else
logger "Sharemount:$Share_Name User check FAIL"
return 1
fi
}
#####
Finder_Ready() {
Loop_End=$((SECONDS + 60))
while [[ -z "$(ps -c -u $Current_User | awk /CoreServicesUIAgent/)" ]] && [[ $SECONDS -lt $Loop_End ]]; do
sleep 10
done
if [[ "$(ps -c -u $Current_User | awk /Finder/)" ]]; then
logger "Sharemount:$Share_Name Finder check PASS"
return 0
else
logger "Sharemount:$Share_Name Finder check FAIL"
return 1
fi
}
#####
Not_Mounted() {
if [[ -z "$(mount | awk '/'$Current_User'/ && //'$Share_Name' /')" ]]; then
logger "Sharemount:$Share_Name Mount check PASS $Share_Name"
return 0
else
logger "Sharemount:$Share_Name Mount check FAIL already mounted"
return 1
fi
}
#####
Mount_Drive() {
True_Path=$(echo $Share_Path | sed 's//////'$Current_User'@/g')
logger "Sharemount:$Share_Name Attempting to mount $True_Path"
sudo -u $Current_User osascript -e 'mount volume "'$True_Path'"'
}
##### START #####
Share_Path=$4
Share_Name="$(echo $Share_Path | awk -F"/" '{print $NF}')"
if User_Ready && Finder_Ready && Share_Path_Valid && Not_Mounted; then
sleep 4
Mount_Drive
else
logger "Sharemount:$Share_Name Conditions not met to attempt drive mounting $Share_Path"
fi
##### End seperate process #####
) &
##### FIN #####
Posted on 06-16-2017 01:26 AM
We use a launchagent and script:
I packaged these 2 files:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
<dict>
<key>Label</key>
<string>login_test</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Library/Mount Users Home Folder.scpt</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
set loggedInUser to do shell script "whoami"
set accountType to do shell script "dscl . -read /Users/" & loggedInUser & " | grep UniqueID | cut -c 11-"
set nodeName to do shell script "dscl . -read /Users/" & loggedInUser & " | awk '/^OriginalNodeName:/,/^Password:/' | head -2 | tail -1 | cut -c 2-"
set ADGroups to do shell script "dscl " & quoted form of nodeName & " -read /Users/" & loggedInUser & " | awk '/^dsAttrTypeNative:memberOf:/,/^dsAttrTypeNative:msExchHomeServerName:/'"
set ADHome to do shell script "dscl " & quoted form of nodeName & " -read /Users/" & loggedInUser & "| grep SMBHome: | cut -c 10- | sed 's/\///g' "
if accountType is less than 1000 then
tell me to quit
end if
try
mount volume "smb:" & ADHome
on error
end try
Upload package to JAMPro , create a policy for deployment.
Done
Posted on 09-09-2020 10:01 PM
@kerouak Hey mate can you able to explain how do you create package ? did you bundled up launch agent and the script into one Package through composer ?
Posted on 09-10-2020 04:51 AM
@Mudalige
Well, I use something different, but, yeah, you could bundle it all up in 1 using composer.
G'Luck
Posted on 09-10-2020 04:00 PM
@kerouak Thanks mate. I will try