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.
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
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]
@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.
when i do a terminal command from the actual test computer , it works
dockutil --remove 'Notes'
dockutil --add /Application/Notes.app
@stevewood how could that be if the policy is running on user login ??
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
@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 ?
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
@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
@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
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.
@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.
@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 $?
@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
.
@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
@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.
@stevewelgoss yep, variable mess up
its working. Dockutil is working !!!!. Using TRIGGER of LOGIN and all so far so good.
thanks all
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
version 2.0.2 makes no difference.
I guess i'll just deal with MAPS, PHOTOS, IBOOKS appearing even
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
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 .