kcrawford / dockutil

command line tool for managing dock items
http://patternbuffer.wordpress.com
Apache License 2.0
1.36k stars 131 forks source link

Dockutil 3.02 issue with Monterey 12.6 and beyond #141

Open Trikster-Online opened 1 year ago

Trikster-Online commented 1 year ago

I have setup Dockutil on three different labs and everything has been working as intended for all users (admin and non-admin). I recently updated the computers to either 12.6 or 12.6.1 and the dock is throwing an error:

micro@mac-testbox ~ % sudo /Library/Scripts/test.sh Error: /Users/micro/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist Usage: dockutil [] [ ...] See 'dockutil --help' for more information. adding /Applications/Self Service.app /Library/Scripts/test.sh: line 16: 958 Illegal instruction: 4 $DOCKUTIL --add '/Applications/Self Service.app' --no-restart

I am getting this for every item in the dock.

This is what my script looks like...

`#!/bin/bash

Running checkSetupDone function to determine if the rest of this script needs to run.

Yes, if $HOME/Library/Preferences/com.ARC.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.ARC.docksetup.plist ] ; then
    exit 0
fi

}

configureDefaultDock() {

DOCKUTIL=/usr/local/bin/dockutil

$DOCKUTIL --remove all --no-restart

sleep 3

$DOCKUTIL --add '/Applications/Self Service.app' --no-restart

$DOCKUTIL --add '/System/Applications/Launchpad.app' --no-restart

$DOCKUTIL --add '/Applications/Reset My Keychain.app' --no-restart

$DOCKUTIL --add '/Applications/Skype for Business.app' --no-restart

$DOCKUTIL --add '/Applications/zoom.us.app' --no-restart

$DOCKUTIL --add '/Applications/Safari.app' --no-restart

$DOCKUTIL --add '/Applications/Firefox.app' --no-restart

$DOCKUTIL --add '/Applications/Google Chrome.app' --no-restart

$DOCKUTIL --add '/Applications/Microsoft Excel.app' --no-restart

$DOCKUTIL --add '/Applications/Microsoft PowerPoint.app' --no-restart

$DOCKUTIL --add '/Applications/Microsoft Word.app' --no-restart

$DOCKUTIL --add '/Applications/Microsoft Outlook.app' --no-restart

$DOCKUTIL --add '/Applications' --view grid --display folder --sort name

touch $HOME/Library/Preferences/com.ARC.docksetup.plist

}

dockAdjustments() {

defaults write com.apple.dock tilesize -int 40 defaults write com.apple.dock magnification -bool true

}

killall cfprefsd killall Dock checkSetupDone configureDefaultDock dockAdjustments

killall Dock

exit 0`

I am at a loss as what to look at next. Like I said at the beginning, it was working just fine until the update. (the dockAdjustments didn't work, but I knew that). I did notice that after I upgraded the OS, I did have to reinstall dockutil as it was no longer there.

mvught commented 1 year ago

Use This:

`#!/bin/bash

checkSetupDone() { if [ -f "$HOME"/Library/Preferences/com.ARC.docksetup.plist ] ; then exit 0 fi }

configureDefaultDock() { DOCKUTIL=/usr/local/bin/dockutil $DOCKUTIL --remove all --no-restart sleep 3

$DOCKUTIL --add '/Applications/Self Service.app' --no-restart $DOCKUTIL --add '/System/Applications/Launchpad.app' --no-restart $DOCKUTIL --add '/Applications/Reset My Keychain.app' --no-restart $DOCKUTIL --add '/Applications/Skype for Business.app' --no-restart $DOCKUTIL --add '/Applications/zoom.us.app' --no-restart $DOCKUTIL --add '/Applications/Safari.app' --no-restart $DOCKUTIL --add '/Applications/Firefox.app' --no-restart $DOCKUTIL --add '/Applications/Google Chrome.app' --no-restart $DOCKUTIL --add '/Applications/Microsoft Excel.app' --no-restart $DOCKUTIL --add '/Applications/Microsoft PowerPoint.app' --no-restart $DOCKUTIL --add '/Applications/Microsoft Word.app' --no-restart $DOCKUTIL --add '/Applications/Microsoft Outlook.app' --no-restart $DOCKUTIL --add '/Applications' --view grid --display folder --sort name touch "$HOME"/Library/Preferences/com.ARC.docksetup.plist }

dockAdjustments() { defaults write com.apple.dock tilesize -int 40 defaults write com.apple.dock magnification -bool true }

killall cfprefsd killall Dock checkSetupDone configureDefaultDock dockAdjustments

killall Dock

exit 0`

Regards Thijs

Trikster-Online commented 1 year ago

Looking at yours, I don't see any changes to mine other than you removed my commented stuff at the beginning.

mvught commented 1 year ago

I have tested it here and it works just fine so what is your problem?

Trikster-Online commented 1 year ago

This is the error that I am getting when it runs

micro@mac-testbox ~ % sudo /Library/Scripts/test.sh Error: /Users/micro/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist Usage: dockutil [] [ ...] See 'dockutil --help' for more information. adding /Applications/Self Service.app /Library/Scripts/test.sh: line 16: 958 Illegal instruction: 4 $DOCKUTIL --add '/Applications/Self Service.app' --no-restart

I am getting this for every item in the dock.

mvught commented 1 year ago

Ok run this script: Test.txt

Let me know if this fixed it

mvught commented 1 year ago

And?

Trikster-Online commented 1 year ago

I'm sorry, I didn't see your script. I will give that a try on Friday. Thank you for your assistance.

DeployNull commented 1 year ago

Thank you @mvught for your script! 😀

Your script helped me to troubleshoot and resolve a similar issue with a dockutil script that we deploy from Jamf Pro, that for some reason have started to fail updating the Dock on some Mac devices, not all.

I'm leaving my comment here, in case someone else is in a similar troubleshooting mode 🔎

The current script I had, have worked out fine on Intel- and Apple Silicon-based Mac devices when doing user-initiated enrollments (UIE) in Jamf Pro.

For automatic device enrollments (ADE) the story seem to be different and I'm not sure when under macOS Monterey it started to be an issue for us under the ADE scenario.

At least the issue is present on both Intel VMs and physical Apple Silicons devices when doing ADE enrollments under both Monterey 12.6.1 and Ventura 13.0. If those machines instead performs UIE under either Monterey 12.6.1 or Ventura 13.0, the Dock is updated successfully 🤔

It boils down to below key differences if I'm using the same variable names from your script, as a reference. For it to be successful under the ADE scenario in Jamf Pro.

UIE scenario: Passing variable $userHome as argument to dockutil binary works under UIE scenario under Monterey 12.6.1. and Ventura 13.0 and the Dock gets updated. ${dockutil}" --add "$app" --no-restart ${userHome} # Does not work under ADE scenario

ADE scenario: It seems to be key both passing the full path to com.apple.dock.plist in ${dockutil}" --add "$app" --no-restart ${plist} as you do and wrapping it in the runAsUser() function to successfully update the Dock under the ADE scenario.

DeployNull commented 1 year ago

@Trikster-Online Under what scenario and/or MDM solution are you testing? Please see my response to @mvught. Hopefully it is of assistance. Cheers!

Trikster-Online commented 1 year ago

@Trikster-Online Under what scenario and/or MDM solution are you testing? Please see my response to @mvught. Hopefully it is of assistance. Cheers!

I use ADE 99% of the time. Would love to see how your script is written out for that scenario.

blainea-ca commented 1 year ago

Thanks @mvught for the script and @DeployNull for the additional info. This too solved my issues with dockutil macOS Ventura (13.1) by running as the user and passing the path to the plist file.

mvught commented 1 year ago

Case closed, nice to hear that it worked 👌