Dockutil on the new 2017 iMac

steve_cox
New Contributor

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.

1ed43e83c1584e15aa6b89e20ec09090

9 REPLIES 9

Wakko
Contributor II

@steve.cox
Try this out and see how it works. I've had great success doing this way.
77c4cf6e0e314794951f394f7e7fedec

StoneMagnet
Contributor III

@steve.cox & @Echevarria To properly display code in a Jamf Nation post, use three backticks (```) before and after your code block.

rqomsiya
Contributor III

Can you post the raw code? So it is copyable?

Thanks,
R.

Wakko
Contributor II

@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```

rqomsiya
Contributor III

@Echevarria How is this being triggered in your policy? Login hook?

djdavetrouble
Contributor III

Don't forget to use the code block feature when pasting code, or it will get mangled in the post.
267cee5a1abb458fbf33793ea399179d

Wakko
Contributor II

@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.

steve_cox
New Contributor

@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

steve_cox
New Contributor

My appologies to all who have contributed, dockutil is working fine there was a Configuration Profile overriding any changes that I tried to make.