Trying to get some dock management scripts that will trash the logged in users dock at logout and put back in the stock dock via some dockutil commands. The following runs fine via Casper Remote but not as a logout trigger in a policy:
#!/bin/bash
# Set the currently logged in user variable
LoggedInUser=`who | grep console | awk '{print $1}'`
PlistLocation="/Users/$LoggedInUser/Library/Preferences/com.apple.dock.plist";
# Remove all items from the dock
/usr/local/bin/dockutil --remove all "${PlistLocation}" --no-restart;
# Add the dock items in the following order
/usr/local/bin/dockutil --add '/Applications/Launchpad.app' --replacing "Launchpad" --section apps "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add '/Applications/Safari.app' --replacing "Safari" --section apps "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add '/Applications/Photo Booth.app' --replacing "Photo Booth" --section apps "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add '/Applications/iTunes.app' --section apps "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add '/Applications/Microsoft Office 2011/Microsoft Word.app' --section apps "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add '/Applications/Comic Life.app' --section apps "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add '/Applications/GarageBand.app' --section apps "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add '/Applications/iMovie.app' --section apps "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add '/Applications/Self Service.app' --section apps "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add /Applications --view grid --display folder --section others "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add /Users/$LoggedInUser/Downloads --view grid --display folder --section others "${PlistLocation}" --no-restart;
/usr/local/bin/dockutil --add /Users/$LoggedInUser/Documents --view grid --display folder --section others "${PlistLocation}" --no-restart;
This is the log in the JSS after the policy fails:
Script result: /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist /Users//Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist
Seems like the LoggedInUser variable isn't populating properly via policy. Thoughts?
Thanks,
John