Posted on 06-20-2016 10:54 AM
I copied (select line 1 to last line 678 and copy) the dockutil.py from here
https://github.com/kcrawford/dockutil/blob/master/scripts/dockutil
put it in textwrangler, called int dockutil.py and placed it in /usr/local/bin (El Capitan), dragged it into Composer and made a .pkg. (did i need to change any permissions before dragging it into composer?)
made a policy to install it. It was placed correctly on a test computer
made a #/bin/sh to include my dockutil add/remove/move dock items code
the policy runs to change the dock items, and i get
Script result: /Library/Application Support/JAMF/tmp/LabDock.sh: line 19: /usr/local/bin/dockutil.py: Permission denied /Library/Application Support/JAMF/tmp/LabDock.sh: line 20: /usr/local/bin/dockutil.py: Permission denied /Library/Application Support/JAMF/tmp/LabDock.sh: line 21: /usr/local/bin/dockutil.py: Permission denied /Library/Application Support/JAMF/tmp/LabDock.sh: line 22: /usr/local/bin/dockutil.py: Permission denied /Library/Application Support/JAMF/tmp/LabDock.sh: line 23: /usr/local/bin/dockutil.py: Permission denied /Library/Application Support/JAMF/tmp/LabDock.sh: line 24: /usr/local/bin/dockutil.py: Permission denied /Library/Application Support/JAMF/tmp/LabDock.sh: line 25: /usr/local/bin/dockutil.py: Permission denied /Library/Application Support/JAMF/tmp/LabDock.sh: line 26: /usr/local/bin/dockutil.py: Permission denied /Library/Application Support/JAMF/tmp/LabDock.sh: line 27: /usr/local/bin/dockutil.py: Permission denied /Library/Application Support/JAMF/tmp/LabDock.sh: line 28: /usr/local/bin/dockutil.py: Permission denied
here is my LabDock.sh
#!/bin/sh
sleep 15
######## REMOVE FROM DOCK
/usr/local/bin/dockutil.py --remove 'Mail' --no-restart
/usr/local/bin/dockutil.py --remove 'Contacts' --no-restart
/usr/local/bin/dockutil.py --remove 'Calendar' --no-restart
/usr/local/bin/dockutil.py --remove 'Notes' --no-restart
/usr/local/bin/dockutil.py --remove 'Reminders' --no-restart
/usr/local/bin/dockutil.py --remove 'Maps' --no-restart
/usr/local/bin/dockutil.py --remove 'Photos' --no-restart
/usr/local/bin/dockutil.py --remove 'Messages' --no-restart
/usr/local/bin/dockutil.py --remove 'FaceTime' --no-restart
/usr/local/bin/dockutil.py --remove 'iTunes' --no-restart
/usr/local/bin/dockutil.py --remove 'iBooks' --no-restart
/usr/local/bin/dockutil.py --remove 'App Store' --no-restart
/usr/local/bin/dockutil.py --remove 'System Preferences' --no-restart
######## MOVE IN DOCK
/usr/local/bin/dockutil.py --move 'Safari' --position 3 --no-restart
######## ADD TO DOCK
/usr/local/bin/dockutil.py --add /Applications/Google Chrome.app --position 4 --no-restart
/usr/local/bin/dockutil.py --add /Applications/Firefox.app --position 5 --no-restart
/usr/local/bin/dockutil.py --add /Applications/IBM/SPSS/Statistics/24/SPSSStatistics.app --label 'SPSS24' --position 6 --no-restart
/usr/local/bin/dockutil.py --add /Applications/Microsoft Excel.app --position 7 --no-restart
/usr/local/bin/dockutil.py --add /Applications/Microsoft PowerPoint.app --position 8 --no-restart
/usr/local/bin/dockutil.py --add /Applications/Microsoft Word.app --position 9 --no-restart
exit $?
Solved! Go to Solution.
Posted on 06-20-2016 11:42 AM
@tcandela If you're trying to run this against a user, you need to identify the user's home folder, or use the --allhomes
switch for dockutil
to be able to work on all home folders on the system.
By not designating which home folder to work on, dockutil
is attempting to modify the root user's home folder, which does not exist.
Posted on 06-21-2016 07:06 AM
@tcandela can you post the updated script? Your dockutil
lines should look like this:
$du --add "/Applications/Self Service.app" $myUser
Where $myUser
is the path to the user's home folder. Doesn't necessarily have to go all the way to their Preferences folder, just to their home folder: /Users/swood for example.
Posted on 06-20-2016 11:09 AM
Yes, the permission on a script should be that they are 'eXecutable' : the X bit should be on for the /usr/local/bin/dockutil.py file (chmod a+x will do)
check with ls -l, the output should be like this: (note the X after rw or after r-)
ls -l /usr/local/bin/dockutil.py
-rwxr-xr-x 1 root wheel .... dockutil.py
If you did not do that before making the package, that is probably the error.
Your error does not relate to the script posted, since the line 20 is empty, so cannot give an error. (or the error is from line 20 inside /usr/local/bin/dockutil.py , but that is a comment) but I expect you left out some comments lines in the script you posted.
Posted on 06-20-2016 11:25 AM
i just went into the GitHub and did Download.zip for the dockutil, I was able to pull the dockutil-2.0.3.pkg from it. I'm gonna throw that in a policy and see what happens.
the script is actually cut off Line 19 is actually starts at /usr/local/bin/dockutil.py --remove 'Mail' --no-restart
Posted on 06-20-2016 11:39 AM
i ran the dockutil-2.0.3.pkg and see it in /usr/local/bin/dockutil
changed the script to say /usr/local/bin/dockutil(left out .py extension) --remove 'Mail' --no--restart
now this is what i get.
Script result: /var/root/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist
/var/root/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist
[message repeats 18 times]
Posted on 06-20-2016 11:42 AM
@tcandela If you're trying to run this against a user, you need to identify the user's home folder, or use the --allhomes
switch for dockutil
to be able to work on all home folders on the system.
By not designating which home folder to work on, dockutil
is attempting to modify the root user's home folder, which does not exist.
Posted on 06-20-2016 11:50 AM
when i do a terminal command from the actual test computer , it works
dockutil --remove 'Notes'
dockutil --add /Application/Notes.app
Posted on 06-20-2016 11:59 AM
@stevewood how could that be if the policy is running on user login ??
Posted on 06-20-2016 12:13 PM
I have given up using dockutil. I couldn't get any consitant results, most of the time a new user on a system got the default Dock and not the one I wanted them to. In the end I just used the Dock items and have been successful and happy
Posted on 06-20-2016 12:26 PM
@CapU I am also using the JSS Dock items for poilcies but I find that the LOGIN TRIGGER does not work/inconsistent (items not removed that i want removed, items i want added not added) so currently have the Dock policy run on LOGOUT. Next time they login to that computer the dock will be setup.
I wish the LOGIN TRIGGER worked though. So here i am testing out this Dockutil crap
what TRIGGER are you running yours at ?
Posted on 06-20-2016 01:34 PM
I used it in combination with outset, and had to killall the Finder/Dock to see the actual settings applied...
Not really a nice solution, but workable for the limited stuff I wanted to do.
See the outset wiki for details
Posted on 06-20-2016 04:57 PM
@CapU version 2.0.3 was recently released to try and address some of the first login issues. If you set it to be a logon script it waits until the plist is there before editing it. Been pretty reliable for me.
@tcandela you can probably do the same thing. Set it up so that it runs on login for every user. By default it runs on the current user, --allhomes does it for existing users only - so no luck if users are added afterwards. I'm pretty sure the best way to do that is to put it somewhere in the /System/Library/User Template/English.lproj folder... but I'm not entirely sure. I really only modify dock for users that I specify
Posted on 06-20-2016 05:04 PM
@tcandela this is the script I use for each of my users. I use the --remove all --no-restart prior to setting the dock how I like it.
#!/bin/bash
# Running checkSetupDone function to determine if the rest of this script needs to run.
# Yes, if $HOME/Library/Preferences/com.company.docksetup.plist file does not exist.
# Otherwise, assume this setup script has already run for this user and does not
# need to run again.
checkSetupDone() {
if [ -f $HOME/Library/Preferences/com.company.docksetup.plist ] ; then
exit 0
fi
}
configureDefaultDock() {
DOCKUTIL=/usr/local/bin/dockutil
$DOCKUTIL --remove all --no-restart
$DOCKUTIL --add '/Applications/Launchpad.app' --no-restart
$DOCKUTIL --add '/Applications/Safari.app' --no-restart
$DOCKUTIL --add '/Applications/Self Service.app' --no-restart
$DOCKUTIL --add '/Applications/Mission Control.app' --no-restart
$DOCKUTIL --add '/Applications/Microsoft Word.app' --no-restart
$DOCKUTIL --add '/Applications/Microsoft Outlook.app' --no-restart
$DOCKUTIL --add '/Applications/Microsoft PowerPoint.app' --no-restart
$DOCKUTIL --add '/Applications/Microsoft Excel.app' --no-restart
$DOCKUTIL --add '/Applications/Microsoft Lync.app' --no-restart
$DOCKUTIL --add '/Applications/Cisco/Cisco AnyConnect Secure Mobility Client.app' --no-restart
$DOCKUTIL --add '/Applications' --no-restart
$DOCKUTIL --add '~/Downloads'
touch $HOME/Library/Preferences/com.company.docksetup.plist
}
checkSetupDone
configureDefaultDock
exit 0
Posted on 06-21-2016 06:48 AM
I have mine set at trigger login but keep getting the error (see below) in the policy log
( as you can see i have an echo that names the user and the users home directory) so why is it looking in /var/root/Library/Preferences instead of Users/testuser/Library/Preferences ??
Executing Policy TEST Dockutil LAB Add Dock Items
Running script LabDock.sh...
Script exit code: 1
Script result: Logged in user is testuser
Logged in user's home /Users/testuser/Library/Preferences/
/var/root/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist
[message repeats 19 times]
Error running script: return code was 1.
Posted on 06-21-2016 07:06 AM
@tcandela can you post the updated script? Your dockutil
lines should look like this:
$du --add "/Applications/Self Service.app" $myUser
Where $myUser
is the path to the user's home folder. Doesn't necessarily have to go all the way to their Preferences folder, just to their home folder: /Users/swood for example.
Posted on 06-21-2016 07:40 AM
@stevewood yep, I have tried what you just mentioned and it looks to be working.
What does --homeloc do in the dockutil
LoggedInUser=$3
LoggedInUserHome="/Users/$3"
UserPlist=$LoggedInUserHome/Library/Preferences/com.apple.dock.plist
/usr/local/bin/dockutil --remove 'Mail' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'Contacts' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'Calendar' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'Notes'--no-restart $UserPlist
/usr/local/bin/dockutil --remove 'Reminders' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'Maps' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'Photos' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'Messages' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'FaceTime' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'iTunes' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'iBooks' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'App Store' --no-restart $UserPlist
/usr/local/bin/dockutil --remove 'System Preferences' --no-restart $UserPlist
######## MOVE IN DOCK
/usr/local/bin/dockutil --move 'Safari' --position 3 --no-restart $UserPlist
######## ADD TO DOCK
/usr/local/bin/dockutil --add /Applications/Google Chrome.app --position 4 --no-restart $UserPlist
/usr/local/bin/dockutil --add /Applications/Firefox.app --position 5 --no-restart $UserPlist
/usr/local/bin/dockutil --add /Applications/IBM/SPSS/Statistics/24/SPSSStatistics.app --label 'SPSS24' --position 6 --no-restart $UserPlist
/usr/local/bin/dockutil --add /Applications/Microsoft Excel.app --position 7 --no-restart $UserPlist
/usr/local/bin/dockutil --add /Applications/Microsoft PowerPoint.app --position 8 --no-restart $UserPlist
/usr/local/bin/dockutil --add /Applications/Microsoft Word.app --position 9 $UserPlist
# }
# checkSetupDone
# configureDefaultDock
exit $?
Posted on 06-21-2016 07:46 AM
@tcandela so your script is now working and not throwing the error you had? Good.
According to the dockutil
help, --homeloc
does:
overrides the default /Users location for home directories
So, if you have home folders that are not in /Users you can indicate the path with --homeloc
. I'm assuming that it works in concert with --allhomes
.
Posted on 06-21-2016 08:41 AM
@stevewood yep, its working, no error. If a dock item is not there and it tries to remove it, the JSS policy log will mention it.
is the FINDER dock item counted as position 1 ??
if --remove all --no-restart $UserPlist command is run FINDER is still in the docks first position (fine with me). How do i get the downloads folder back ?
this does not work: /usr/local/bin/dockutil --add '~/Downloads' --view grid --display folder &UserPlist
Posted on 06-21-2016 08:46 AM
@tcandela unless that was a mis-spelling in the post, your variable is wrong for the Download folder:
/usr/local/bin/dockutil --add '~/Downloads' --view grid --display folder &UserPlist
Should be:
/usr/local/bin/dockutil --add '~/Downloads' --view grid --display folder $UserPlist
That's exactly how I have it in ours and it works.
As far as Finder, I believe it is position 0, technically, which means it cannot be moved or anything placed to the left of it. I just issued a position 1 call and it placed the icon to the right of Finder.
Posted on 06-21-2016 09:17 AM
@stevewelgoss yep, variable mess up
its working. Dockutil is working !!!!. Using TRIGGER of LOGIN and all so far so good.
thanks all
Posted on 06-21-2016 09:50 AM
only issue i see is, MAPS, PHOTOS, IBOOKS are appearing even though i have
$DOCKUTIL --remove all --no-restart
at the top of my dockutil script.
Even if i specifically add these lines after the --remove all, they still appear /usr/local/bin/dockutil --remove 'Maps' --no-restart $UserPlist /usr/local/bin/dockutil --remove 'iBooks' --no-restart $UserPlist /usr/local/bin/dockutil --remove 'Photos' --no-restart $UserPlist
Posted on 06-27-2016 06:38 AM
version 2.0.2 makes no difference.
I guess i'll just deal with MAPS, PHOTOS, IBOOKS appearing even
Posted on 06-27-2016 10:46 AM
Maps, Photos and iBooks appears on the dock because of the com.apple.dockfixup.plist
found under
/System/Library/CoreServices/Dock.app/Contents/Resources
. Some people have removed the keys in the plist that are adding those items to all new docks, but when SIP is enabled, you won't have the ability to modify this plist.
You should check out this post: https://jamfnation.jamfsoftware.com/discussion.html?id=17276 about SIP and dockfixup see if it can help.
Edit: words
Posted on 06-27-2016 03:18 PM
for LAB macs i am using Dock Master (http://errorfreeit.com.au/blog/2015/4/28/dock-master). Upload the .mobileconfig in a configuration profile and the Lab computers are set .