Dockutil and script

MST
Contributor

Experts, I am new to the Casper and struggling second day with dock util on 10.10.OS. Since that functionality was removed in JAMF casper work around like custom script with dockutil 2.0.2 needs to be enabled.

!/bin/bash

sudo dockutil --remove 'Launchpad' --allhomes
sudo dockutil --remove 'Mail' --allhomes
sudo dockutil --remove 'Contacts' --allhomes
sudo dockutil --remove 'Calendar' --allhomes
sudo dockutil --remove 'Notes' --allhomes
sudo dockutil --remove 'Maps' --allhomes
sudo dockutil --remove 'FaceTime' --allhomes
sudo dockutil --remove 'Photo Booth' --allhomes
sudo dockutil --remove 'iPhoto' --allhomes
sudo dockutil --remove 'Pages' --allhomes
sudo dockutil --remove 'Numbers' --allhomes
sudo dockutil --remove 'Keynote' --allhomes
sudo dockutil --remove 'iBooks' --allhomes
sudo dockutil --add /Applications/Firefox.app --after 'Safari' --allhomes
sudo dockutil --add /Applications/Google Chrome.app --after 'Firefox' --allhomes
sudo dockutil --add /Applications/Final Cut Pro.app --after 'Google Chrome' --allhomes
sudo dockutil --add /Applications/Adobe Photoshop CC 2014/Adobe Photoshop CC 2014.app --after 'Final Cut Pro' --allhomes
sudo dockutil --add /Applications/Cyberduck.app --after 'Adobe Photoshop CC 2014' --allhomes
sudo dockutil --add /Applications/Filezilla.app --after 'Cyberduck' --allhomes
sudo dockutil --add /Applications/Microsoft Office 2011/Microsoft Word.app --before 'iTunes' --allhomes
sudo dockutil --add /Applications/Microsoft Office 2011/Microsoft Excel.app --before 'iTunes' --allhomes
sudo dockutil --add /Applications/Microsoft Office 2011/Microsoft Powerpoint.app --before 'iTunes' --allhomes
sudo dockutil --add /Applications/Microsoft Office 2011/Microsoft Outlook.app --before 'iTunes' --allhomes
sudo dockutil --add /Applications/Skype.app --before 'iTunes'--allhomes
sudo dockutil --remove 'Downloads' --allhomes
sudo dockutil --add '~/Downloads' --view list --display folder --allhomes

script is easy, but I have this:

Script exit code: 1 Script result: sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found
sudo: /usr/sbin/dockutil: command not found

is anyone has something easy that will just work for simple dock items? Thank You

P.S I have tried other scripts as well with no luck. DOCKUTIL 2.0.2 is already installed on testing MAC.

3 ACCEPTED SOLUTIONS

tim_rees
Contributor

Hi MST,

Here is my full solution for you, that enforces my dock everytime, without fail!

  1. As mentioned, I created my dock profile on http://errorfreeit.com.au/blog/2015/4/28/dock-master and downloaded it to my machine.

  2. I then created a package with Composer (Packages, or packagemaker would also work!) to put the profile on the machine, I have a /Library/schoolname folder for all of our working files. (You can get the installer to install the profile as part of its process, I wanted to use the JSS to run the script, so I could see any errors in the JSS)

  3. I created a policy that installs the package, and runs the following script to install the policy:

#!/bin/sh
/usr/bin/profiles -I -F /location/of/studentdock.mobileconfig
exit 0

There is only 1 negative to this process, if you want to change the dock, you have to create a complete new file on the website, and make a new package, but as the FAQ on the site says. the profile identifier is identical, so when the script is run, it will replace the old one.

In the end, as long as the site never disappears, it has solved my solution!

Tim

View solution in original post

MST
Contributor

Hi Tim,

You mentioned "...and downloaded it to my machine." should I put just anywhere or specific location?

Also I am confused with the part using composer for creating profile. i am using casper composer ....

View solution in original post

MST
Contributor

Hi,

I have figured it out with help of this site:

https://jamfnation.jamfsoftware.com/discussion.html?id=6024

pretty much the same steps and now it works,

Thank YOU very much all of you for a big help. Thanks.

View solution in original post

21 REPLIES 21

lee_smith
Contributor

@MST I am new to Casper as well. I just got off the phone with JAMF support. They will be sending me some information over shortly. I have looked at dockutil and feel very overwhelmed.

I have Elementary School Lab with about 21 computers. The Lab Teacher has requested the dock be locked with certain icons. If you find an easy solution please provide an update.

Lee

lee_smith
Contributor

@MST Here is a workflow to lock down the dock. I am still working on the customization part.

Create JSS Policy 1) JSS > Management Tab > Policies > Create Policy 2) Name Policy: Lock Dock 3) Triggered by Login, Once per computer, Scope Policy to Desired Computers 4) Execution Frequency > Once per Computer or Once per Month 5) Go to "Advanced Tab" in Policy (place command under Files & Processes Section in Run Command):
defaults write /Library/Preferences/com.apple.dock contents-immutable -bool true

davidacland
Honored Contributor II

Hi,

The dockutil error looks like the binary isn't installed on the target computers. You will need to get dockutil into /usr/sbin before you can run the script to call it.

As a slightly different route, when we want to lock a Dock with a certain set of apps, we normally use a custom configuration profile. The basic steps are:

  1. In a temporary user account, configure the Dock how you want
  2. Copy the dock preference file to the desktop with cp /Users/nameoftempaccount/Library/Preferences/com.apple.dock.plist /Users/nameoftempaccount/Desktop
  3. Convert the file to xml with plutil -convert xml1 /Users/nameoftempaccount/Desktop/com.apple.dock.plist
  4. Use mcxToProfile to create a custom profile with /path/to/mcxToProfile.py --plist /Users/nameoftempaccount/Desktop/com.apple.dock.plist --identifier Dock
  5. Upload the .mobileconfig file into the JSS and scope to devices

stevewood
Honored Contributor II
Honored Contributor II

@MST The problem you are running into is that dockutil is not installed on that machine. Or at least it is not in the location that you are telling Casper it is at:

Script exit code: 1 Script result: sudo: /usr/sbin/dockutil: command not found

You need to make sure that a) dockutil is installed on the machine, and b) your script has the proper path.

The first is remedied by installing dockutil on those machines that need it. You can do this by getting the latest copy of dockutil (available here), and then using Composer or Packages or your favorite packaging method, to package up dockutil so that it installs into the location of your choice. Once packaged, create a policy that then installs dockutil on all of your machines.

Once you've remedied the installation of dockutil, then you can update your script to indicate the location of dockutil. Or, you could install dockutil right into the /usr/sbin/ folder on your machines so that you do not have to edit your script at all.

Hope that helps you out some.

cwaldrip
Valued Contributor

The script can't find dockutil.

A safer way to write your script is instead of...

dockutil --remove 'Downloads' --allhomes

Use this...

/usr/sbin/dockutil --remove 'Downloads' --allhomes

Or whatever the path is to where you're installing the dockutil binary.

Also, you shouldn't need 'sudo' in your script. Scripts are run with root privileges when executed by Casper (during imaging, a policy, a remote push, etc). So the 'sudo' is redundant.

calumhunter
Valued Contributor

Just an FYI

you should install dockutil into /usr/local/sbin

sbin generally requires super user privs bin any user can run

/usr/sbin and /usr/bin are reserved for the operating system binaries

3rd party binaries should be installed in /usr/local/sbin or /usr/local/bin

El Capitan will make this more of an issue as with SIP enabled by default you can not modify the contents of /usr/sbin or /usr/bin

MST
Contributor

whow Guys - you rock! You are a way better than JAMF support. :) I have to customize a dock for around 300 laptops. I will get back to you shortly. Honestly, I am surprised by help offered on this forum. THANK YOU SO MUCH all of You Gentlemen. -Adam

stevewood
Honored Contributor II
Honored Contributor II

@MST one thing to remember is that dockutil is a third party piece of software. So JAMF support not being able to assist with that is understandable. If the issue you were having were specifically something to do with a part of the Casper Suite, then they would definitely be able to help.

MST
Contributor

Hi davidacland,

actually, the last line

Use mcxToProfile to create a custom profile with /path/to/mcxToProfile.py --plist /Users/nameoftempaccount/Desktop/com.apple.dock.plist --identifier Dock

says: syntax error near unexpected token :'newline' line 4 .....

davidacland
Honored Contributor II

Hi @MST, that sounds like an error in the python script.

might be worth re-downloading it from Github in case its corrupted.

The only options you need with the command are --plist and --Identifier

tim_rees
Contributor

Hi MST,

I'm not sure if you are trying to make a dock that can then be edited by your users, or one that is static (ie for a lab machine), if it is the later I found http://errorfreeit.com.au/blog/2015/4/28/dock-master was really really helpful! I think it is mentioned in another discussion.

MST
Contributor

Hello Experts,

Thank You davidacland for your help;however, the idea with mcxToProfile.py did not work giving me some errors. I will be back to it when I slow downs with projects. For now what works for me is:

!/bin/sh

LoggedInUser=$3
LoggedInUserHome="/Users/$3"

checkSetupDone() {

if [ -f $LoggedInUserHome/Library/Preferences/com.company.docksetup.plist ] ; then echo "Dock has been created already for this user, skipping..." exit 0 fi

}

configureDefaultDock() {

plist=$LoggedInUserHome/Library/Preferences/com.apple.dock.plist

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

DOCKUTIL=/usr/local/bin/dockutil

#sudo $DOCKUTIL --remove all --no-restart $LoggedInUserHome sudo $DOCKUTIL --remove all --no-restart $plist

echo "Removing Maps..." $DOCKUTIL --remove '/Applications/Maps.app' --no-restart $LoggedInUserHome echo "Removing Photos..." $DOCKUTIL --remove '/Applications/Photos.app' --no-restart $LoggedInUserHome echo "Removing Maps..." $DOCKUTIL --remove '/Applications/iBooks.app' --no-restart $LoggedInUserHome echo "Remove Safari..." $DOCKUTIL --remove '/Applications/Safari.app' --no-restart $LoggedInUserHome

echo "Adding NEWA..." $DOCKUTIL --add '/Applications/NWEA Lockdown Browser.app' --no-restart $LoggedInUserHome echo "Adding Chrome..." $DOCKUTIL --add '/Applications/Google Chrome.app' --no-restart $LoggedInUserHome echo "Adding Minecraft Luncher..." $DOCKUTIL --add '/Applications/MinecraftEDU.app' --no-restart $LoggedInUserHome echo "Adding Launchpad..." $DOCKUTIL --add '/Applications/Launchpad.app' --no-restart $LoggedInUserHome

touch $LoggedInUserHome/Library/Preferences/com.company.docksetup.plist

else echo "dockutil not installed, skipping initial dock setup..." fi

}
checkSetupDone
configureDefaultDock
exit 0

However, if the user does not exist, that script creates the dock util fine. If the user exists it skips creating the new one. I was trying to play with this script to delete all item in the dock;however, no luck. I am using AD accounts to login, perfectly the script should reset each dock items to default one and create one standard for each AD user (does not matter if previously logged in or no). Please advice how can I reset the dock items. Thank You

I have a policy set up for each login per user with before run script priority.

MST
Contributor

thanks tim.rees, no the user should not be able to modify the dock

tim_rees
Contributor

Hi MST,

Here is my full solution for you, that enforces my dock everytime, without fail!

  1. As mentioned, I created my dock profile on http://errorfreeit.com.au/blog/2015/4/28/dock-master and downloaded it to my machine.

  2. I then created a package with Composer (Packages, or packagemaker would also work!) to put the profile on the machine, I have a /Library/schoolname folder for all of our working files. (You can get the installer to install the profile as part of its process, I wanted to use the JSS to run the script, so I could see any errors in the JSS)

  3. I created a policy that installs the package, and runs the following script to install the policy:

#!/bin/sh
/usr/bin/profiles -I -F /location/of/studentdock.mobileconfig
exit 0

There is only 1 negative to this process, if you want to change the dock, you have to create a complete new file on the website, and make a new package, but as the FAQ on the site says. the profile identifier is identical, so when the script is run, it will replace the old one.

In the end, as long as the site never disappears, it has solved my solution!

Tim

MST
Contributor

Hi Tim,

You mentioned "...and downloaded it to my machine." should I put just anywhere or specific location?

Also I am confused with the part using composer for creating profile. i am using casper composer ....

MST
Contributor

Hi,

I have figured it out with help of this site:

https://jamfnation.jamfsoftware.com/discussion.html?id=6024

pretty much the same steps and now it works,

Thank YOU very much all of you for a big help. Thanks.

iamsumanaddya
New Contributor II

Can you please share the correct link? This above mentioned link is not working.

tim_rees
Contributor

Hi MST,

Thats the article I first used!! :-) I'm happy you found it! Sorry about missing that step in the middle!

Really happy to hear it works!

Tim

MST
Contributor

Experts,

Looks like I have back to the composer of this and redo the dock util with link to chrome to specific web site.

I am trying to recall if I have to put that in the link http://errorfreeit.com.au/blog/2015/4/28/dock-master

gskibum
Contributor III

@MST

If you're still putting dockutil in /usr/sbin/ it will fail because of SIP in El Capitan.

I moved mine to /Library/Application Support/JAMF/bin

dferrara
Contributor II

@MST @gskibum You can also use /usr/local/bin, which works great.