Dockutil not working on first login

CapU
Contributor III

Good Morning or Afternoon

I am using Dockutil for my lab computers. Here is a portion of my dockutil script

#!/bin/bash
sudo -u $3 /usr/local/sbin/dockutil --remove 'Mail' --allhomes
sudo -u $3 /usr/local/sbin/dockutil --remove 'Launchpad' --allhomes
sudo -u $3 /usr/local/sbin/dockutil --remove 'Maps' --allhomes
sudo -u $3 /usr/local/sbin/dockutil --remove 'Reminders' --allhomes
sudo -u $3 /usr/local/sbin/dockutil --remove 'iBooks' --allhomes
sudo -u $3 /usr/local/sbin/dockutil --remove 'FaceTime' --allhomes
sudo -u $3 /usr/local/sbin/dockutil --remove 'App Store' --allhomes
sudo -u $3 /usr/local/sbin/dockutil --remove 'iTunes' --allhomes
sudo -u $3 /usr/local/sbin/dockutil --remove 'Messages' --allhomes
sudo -u $3 /usr/local/sbin/dockutil --remove 'Contacts' --allhomes
/bin/sleep 5
sudo -u $3 /usr/local/sbin/dockutil --add /Applications/Firefox.app --after 'Calendar' --allhomes /bin/sleep 5
sudo -u $3 /usr/local/sbin/dockutil --add /Applications/Google Chrome.app --after 'Firefox' --allhomes /bin/sleep 5
sudo -u $3 /usr/local/sbin/dockutil --add /Applications/Microsoft Word.app --after 'Google Chrome'

When a user logs in for the first time, They get icons added to the dock. Log out log back in the dock may be a little smaller with some of the apps removed. Log out log back in, now almost all of the app I want removed are except maybe Mail or Launchpad. What could I be doing wrong?

Thanks in advance.

15 REPLIES 15

CapU
Contributor III

I rebooted the machines. Seems to be working

Look
Valued Contributor III

You may find it comes back as the machines slow down, I had to put a delay at the front of my scripts for it to work properly on first login.

stevevalle
Contributor III

We run a script on lab machines at every login to ensure the dock is "default" for all students throughout the semester.

I found that a delay at the start of the script was required.

#!/bin/sh
/usr/local/bin/dockutil --remove all --no-restart
sleep 2

/usr/local/bin/dockutil --add '/Applications/Firefox.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Safari.app' --no-restart
/usr/local/bin/dockutil --add '/Applications/Adobe Acrobat DC/Adobe Acrobat.app' --no-restart
etc etc etc...
...
...

killall cfprefsd
killall Dock

russeller
Contributor III

I ran into a similar problem and tried a delay, but didn't have consistent results in my environment. I made a loop that checked the dock and if the app was missing it would add it. Here is the check component:

dockutil --list --homeloc /Users/$logged_in_user_here | grep "$app_name_here" | sed $'s/	.*//'

If it isn't in the dock, then I have the 'for loop' add it. The sed part at the end grabs the name before the tab character. Typical dockutil list output looks like this:

Google Chrome   file:///Applications/Google%20Chrome.app/

The space between 'Google Chrome' and 'file:///...' is a tab. I thought this was interesting and I love to share fun facts: The $ by sed is because bash will process escapes, such as , inside $' ' before passing it as an arg to sed. Great stackoverflow here about it.

Eigger
Contributor III

Not sure if you guys already heard or tried this Dock Master

http://errorfreeit.com.au/blog/2015/4/28/dock-master

I found this a LOT easier to deploy, very consistent so far ever since we used it. No scripting needed.

Please vote on this Feature Request to implement the same technique on JSS
Feature Request 4799

Look
Valued Contributor III

@Eigger Dock Master works quite well, however it makes the dock immutable I believe, so good in a classroom, less useful for staff machines for example where people want to chop and change their docks (but you might still want to create a default one for them).
I agree though an enforced dock is certainly something that would be nice to have directly in Casper.

skinford
Contributor III

@stevevalle Good Morning!

I'm just curious how you do run the script at every login. I set it up the way I thought it should work but with no success at all, I'm truly doing something wrong.

Any tip would be greatly appreciated. Have a very great day today!

millersc
Valued Contributor

@skinford More folks are turning to Outset for login hooks.

stevevalle
Contributor III

@skinford Hi

I have an ongoing policy set to run at login, scoped to all lab computers (smart group). The policy runs the script.

Once lab computers check in with the JSS, they get our "default" dock!

2698001f0c874b74a6f0e4e1b828f9dd

Hope this helps.

cbrewer
Valued Contributor II

I've found Dock management much more reliable when "Perform login hook actions in background" is turned off. This way all Dock changes are done prior to the user environment being processed.d7be72c0995a4d248723cdd769eee325

stevevalle
Contributor III

Good to know @cbrewer !

We have been having issues with some login policies are sometimes not running at login.

Will uncheck this and test :)

Edit: Unchecking this doesn't work well with our DEP policies, as the user needs to be fully logged in to receive the splash screen, prompts to input data and so on!

Look
Valued Contributor III

Interesting I found I had to wait for the user environment to be loaded before messing with the dock, I do this by divorcing the process away and having it wait until it detects the finder before doing the dock. It's a bit ugly as the dock flashes once but it works!
I actually found running login policies in the background improved things simply because the Finder became available 5 to 10 seconds earlier, likewise for a number of other policies I have that wait as well.

Mudalige
New Contributor III

I'm running dockutil on my school environment. However, network users such as students is not getting their dock apps even though there is script running ( Launch Agent ) when user log in. Sometimes, Students have to restart the computer for few times to get the dock setup. Does anybody have a script that works well for dockutil ? Would be much appreciated , if can share with me.

Mudalige
New Contributor III

!/bin/bash

configureDefaultDock() {

DOCKUTIL=/usr/local/bin/dockutil Sleep 2

$DOCKUTIL --remove all --allhomes

$DOCKUTIL --add '/Applications/Safari.app' --allhomes

$DOCKUTIL --add '/Applications/OneDrive.app' --allhomes

$DOCKUTIL --add '/Applications/Microsoft Word.app' --allhomes

$DOCKUTIL --add '/Applications/Microsoft Outlook.app' --allhomes

$DOCKUTIL --add '/Applications/Microsoft PowerPoint.app' --allhomes

$DOCKUTIL --add '/Applications/Google Chrome.app' --allhomes

$DOCKUTIL --add '/Applications/Adobe Dreamweaver 2020/Adobe Dreamweaver 2020.app' --allhomes

$DOCKUTIL --add '/Applications/Adobe Illustrator 2020/Adobe Illustrator.app' --allhomes

$DOCKUTIL --add '/Applications/Adobe Photoshop 2020/Adobe Photoshop 2020.app' --allhomes

$DOCKUTIL --add '/Applications/Adobe Lightroom CC/Adobe Lightroom.app' --allhomes

$DOCKUTIL --add '/Applications/Adobe Premiere Pro 2020/Adobe Premiere Pro 2020.app' --allhomes

$DOCKUTIL --add 'smb://8071FS03/Transfer' --allhomes

$DOCKUTIL --add '/Applications' --allhomes

$DOCKUTIL --add '~/Downloads' --allhomes

}

configureDefaultDock

exit 0

Mudalige
New Contributor III

Above script is the one that I'm using currently