Hello all,
So, in our environment we have a Mac lab used by elementary students (PreK-3), there's a single login for each class. Finding a way to have each of these user accounts to get a custom dock has been a nightmare (tired built in Jamf tools: policies and config profiles). Finally setup and am using Dockutil.
Here's my problem. It works sporadically/unpredictably when deployed as a policy via Jamf (scoped to a group of computers, set the run at login "once per user per computer" and limited to LDAP user. (One policy per limited to user, I found having one policy with several limited to users was problematic.)
Super odd thing is the script works fine when run via UNIX via ARD, when it runs as a policy it does not apply all items, it does recognize the logged in user.
I would be enormously grateful to anyone who can help me with this.
Below is the script:
```
#!/bin/bash
#We need to wait for the dock to actually start
until [[ $(pgrep Dock) ]]; do
wait
done
#Get the current logged in user that we'll be modifying
if [ ! -z "$3" ]; then
user=$3
else
user=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");')
fi
#Set variables
du="/usr/local/bin/dockutil"
userHome="/Users/$user"
#Function for applying dock configuration
createBaseDock()
{
#Remove all items for logged in user
$du --remove all --no-restart $userHome
#Adding base items to the dock
$du --add '/Applications/Google Chrome.app' --position 1 --no-restart $userHome
$du --add '/Applications/Safari.app' --position 2 --no-restart $userHome
$du --add '/Applications/Comic Life 3.app' --position 4 --no-restart $userHome
$du --add '/Applications/Doozla.app' --position 3 --no-restart $userHome
$du --add '/Applications/FableVision/Stationery Studio/Stationery Studio 1.2.app' --position 5 --no-restart $userHome
$du --add '/Applications/The Print Shop 2.app' --position 6 --no-restart $userHome
$du --add "/Applications/Thinkin' Things 1/Thinkin' Things 1.app" --position 7 --no-restart $userHome
}
#Function for finishing base dock
finishBaseDock()
{
#Add local downloads
$du --add '~/Downloads' --section others --position last --no-restart $userHome
killall Dock
}
case $user in
p|k)
echo "p or k found"
createBaseDock
finishBaseDock
;;
1)
echo "1 found"
createBaseDock
$du --add '/Applications/Google Earth.app' --position 8 --no-restart $userHome
$du --add '/Applications/Photo Booth.app' --position 9 --no-restart $userHome
finishBaseDock
;;
2)
echo "2 found"
createBaseDock
$du --add '/Applications/Google Earth.app' --position 8 --no-restart $userHome
$du --add '/Applications/Photo Booth.app' --position 9 --no-restart $userHome
$du --add '/Applications/Lego Digital Designer.app' --position 10 --no-restart $userHome
finishBaseDock
;;
3)
echo "3 found"
createBaseDock
$du --add '/Applications/Google Earth.app' --position 8 --no-restart $userHome
$du --add '/Applications/Photo Booth.app' --position 9 --no-restart $userHome
$du --add '/Applications/Lego Digital Designer.app' --position 10 --no-restart $userHome
$du --add '/Applications/Mavis Beacon Teaches Typing.app' --position 11 --no-restart $userHome
$du --add '/Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app' --position 12 --no-restart $userHome
finishBaseDock
;;
esac
exit 0
```








