Posted on 08-04-2017 04:08 AM
Hi all, first post after using Casper for almost 12 months.
Having a problem with dockutil version 2.0.5 on a new iMac 2017 running 10.12.6 casper version 9.96, the same script runs perfectly on older iMacs but on the new one the only item that seems to work is the "killall Dock" command.
This is a cut down version of what we want on the dock, just using it for testing.
Posted on 08-04-2017 10:20 AM
@steve.cox
Try this out and see how it works. I've had great success doing this way.
Posted on 08-04-2017 10:25 AM
@steve.cox & @Echevarria To properly display code in a Jamf Nation post, use three backticks (```) before and after your code block.
Posted on 08-04-2017 10:26 AM
Can you post the raw code? So it is copyable?
Thanks,
R.
Posted on 08-04-2017 11:53 AM
@StoneMagnet thanks, I was rushing to a meeting so I just threw that up really quick.
Here you go.
```#!/bin/sh
loggedInUser=/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'
loggedInUserHome="/Users/$loggedInUser"
configureDefaultDock() {
echo "Logged in user is $loggedInUser"
echo "Logged in user's home $loggedInUserHome"
if [ -e /usr/local/bin/dockutil ]; then dockutilVersion=$(/usr/local/bin/dockutil --version)
echo "dockutil version: $dockutilVersion"
echo "Clearing Dock..."
/usr/local/bin/dockutil --remove all --no-restart "$loggedInUserHome"
echo "Adding Launchpad..." /usr/local/bin/dockutil --add '/Applications/Launchpad.app' --no-restart --position 1 $loggedInUserHome echo "Adding Google Chrome..." /usr/local/bin/dockutil --add '/Applications/Google Chrome.app' --no-restart --position 2 $loggedInUserHome echo "Adding Slack..." /usr/local/bin/dockutil --add '/Applications/Slack.app' --no-restart --position 3 $loggedInUserHome echo "Adding Box Notes..." /usr/local/bin/dockutil --add '/Applications/Box Notes.app' --no-restart --position 4 $loggedInUserHome echo "Adding Casper Self-Service..." /usr/local/bin/dockutil --add '/Applications/Casper Self Service.app' --no-restart --position 5 $loggedInUserHome echo "Adding System Preferences..." /usr/local/bin/dockutil --add '/Applications/System Preferences.app' --no-restart --position 6 $loggedInUserHome echo "Adding Downloads..." /usr/local/bin/dockutil --add '~/Downloads' --no-restart --position 7 $loggedInUserHome
touch "$loggedInUserHome"/Library/Preferences/com.company.docksetup.plist
else echo "dockutil not installed, skipping initial dock setup..."
fi
}
configureDefaultDock
killall Dock
exit 0```
Posted on 08-04-2017 03:16 PM
@Echevarria How is this being triggered in your policy? Login hook?
Posted on 08-07-2017 08:35 AM
Don't forget to use the code block feature when pasting code, or it will get mangled in the post.
Posted on 08-07-2017 09:03 AM
@rqomsiya I have this running as part of the setup process (imaging). I also have another policy that runs peruser. This way if a new account is created on the machine, the user will get the standard dock. I have it run at login.
Posted on 08-09-2017 02:20 AM
@Echevarria I have tried that script and am getting this error
Script result: /Library/Application Support/JAMF/tmp/P112 Dock copy: line 3: -l: command not found
if I take out the -l I get
Script result: /Library/Application Support/JAMF/tmp/P112 Dock copy: line 3: /dev/console: Permission denied
Posted on 08-09-2017 06:20 AM
My appologies to all who have contributed, dockutil is working fine there was a Configuration Profile overriding any changes that I tried to make.