DockMaster .pkg no longer working

rfloody
New Contributor

Hi All,

 

I'm fairly new to jamf and Mac Management and I have an issue that recently just happened and I've struggled to find an answer. My predecessor used Dockmaster to setup our dock icons to our deployment through a .pkg. Recently with 12.3 it's no longer working and it errors out. I haven't found anyone talking about it anywhere online so I've been stumped on why it's no longer working. Does anyone have a fix or workaround to get it working again? Currently it's installed as a package and even when making the package over again it still errors out immediately. From the little information I could find I saw a change log for DockUtil that updated something for 12.3. Is there something I need to change? I'm not familiar with DockUtil at all so if I need to figure that out to get it working again, is there any resources I can lookup so I can learn it as I'm not to great with command line stuff just yet. 

Thank you kindly!

16 REPLIES 16

emily
Valued Contributor III
Valued Contributor III

I admit I'm not familiar with DockMaster but I think it's just a profile? So it might be an issue with the .pkg being deployed. The first thing that comes to mind is to check and see if there are any scripts in the pkg that require python (which was removed from macOS 12.3).

sdagley
Esteemed Contributor II

@rfloody Looking at the source for Dock Master (specifically https://github.com/Error-freeIT/Dock-Master/blob/master/Dock%20Master/FileOperations.swift) shows that it uses Python to determine the logged in user. That will fail in macOS Monterey 12.3 or later. You might want to look into another tool for modifying Dock configurations, such as the newly updated dockutil , which doesn't require Python.

Karianea
New Contributor

i accidentally installed a software called "dockmaster". I was able to delete it but it seems to be messing with the performance of my macbook pro. And I can not seem to find any information about this software online nor can i find the previous cache files that it is still running in the background. Anyone have any advice on how to fix this?

 

www.prepaidgiftbalance.com

jefff
Contributor II

FYI, Dock Master also has a web-based tool for creating dock profiles and adding dock items. Scripts generated from the website use bash.

Dock Master - A Superior Profile Maker for Managing the Dock

rfloody
New Contributor

Unfortunately this is how the packages have been created using the site and this is what isn't working. They fail during the install due to Python being in the script determine the logged in user based off what sdagley mentioned. Wasn't sure if there was a way around this. When looking at the site further I see I can download it as a mobile config but I would need to sign it with a cert and deploy it out and that's kinda outside of my knowledge at the moment. Would there be a way to alter the script to make it work or can I do something as simple as having Python installed before the Dock pkg installs?

jefff
Contributor II

If you're using a cloud-based instance of Jamf Pro, you can use its internal CA to create a codesigning cert, sign the downloaded profile with Hancock, upload it to Jamf Pro and install your dock items as a profile. The drawback to that will be that the user can't modify the dock.

I just used the "create a package" option in the Dock Master web app and it produced a .tar file that contained 4 folders, 2 bash scripts and a plist with the dock specifications. I'm not sure what to do with those, either. Dock Master is not a turnkey solution anymore. 🙁

 

emily
Valued Contributor III
Valued Contributor III

Can you share the script here? If it’s just calling python to detect the logged-in user there are definitely alternatives.

https://scriptingosx.com/2020/02/getting-the-current-user-in-macos-update/ 

rfloody
New Contributor
#!/bin/bash

# Apply dock to existing user accounts.
APPLY_DOCK_TO_EXISTING_USERS=true

### NOTHING BELOW THIS LINE NEEDS TO CHANGE ###

# A dock plist placed in the User Template directory is applied to new user accounts.
USER_TEMPLATE_DOCK_PLIST="/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist"

# Currently logged in user.
CURRENTLY_LOGGED_IN_USER=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')

if [[ "$APPLY_DOCK_TO_EXISTING_USERS" == "true" ]]
then
    # Output local home directory path (/Users/username).
    for USER_HOME in /Users/*
    do
        # Extract account name (a.k.a. username) from home directory path.
        ACCOUNT_NAME=$(/usr/bin/basename "${USER_HOME}")

        # If account name is not "Shared".
        if [[ "$ACCOUNT_NAME" != "Shared" ]]
        then
            USER_DOCK_PLIST="${USER_HOME}/Library/Preferences/com.apple.dock.plist"

            # If the account already contains a dock plist.
            if [[ -f "$USER_DOCK_PLIST" ]]
            then
                echo "Removing existing user dock plist."
                /usr/bin/defaults delete "$USER_DOCK_PLIST"
           fi

            echo "Copying the latest dock plist into place."
            cp "$USER_TEMPLATE_DOCK_PLIST" "$USER_DOCK_PLIST"

            echo "Updating permissions to match user (${ACCOUNT_NAME})."
            /usr/sbin/chown -R "$ACCOUNT_NAME" "$USER_DOCK_PLIST"

            # Reboot the dock if a user is currently logged in.
            if [[ "$CURRENTLY_LOGGED_IN_USER" == "$ACCOUNT_NAME" ]]
            then
                # Update cached dock plist.
                /usr/bin/sudo -u "$ACCOUNT_NAME" /usr/bin/defaults read "$USER_DOCK_PLIST"
                # Relaunch the dock process.
                /usr/bin/killall Dock
            fi
        fi
    done
fi

This is the code from the PostInstall script from the created package

emily
Valued Contributor III
Valued Contributor III

Yeah the issue is that CURRENTLY_LOGGED_IN_USER line because it's calling python to find the user. You should be able to replace that whole line with something like this:

CURRENTLY_LOGGED_IN_USER=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )

 

rfloody
New Contributor

Thanks @emily for taking the time to help me with this. Unfortunately it's still failing. I ran the script through CodeRunner and this appears at the end. 

Copying the latest dock plist into place.
cp: /Users/support/Library/Preferences/com.apple.dock.plist: Permission denied
Updating permissions to match user (support).
chown: /Users/support/Library/Preferences/com.apple.dock.plist: Permission denied

My account is a domain account and the support account is a local admin account. Not sure if that makes a difference?

emily
Valued Contributor III
Valued Contributor III

Does CodeRunner run as root? Because your pkg will if it's being deployed via Jamf Pro policy. 

rfloody
New Contributor

Hi Emily,

I ran it as a policy in software center and I get an error pretty much immediately. Thats when I ran it in CodeRunner to see if it was getting any kind of error. Just to confirm the postinstall script should now look like this.

#!/bin/bash

# Apply dock to existing user accounts.
APPLY_DOCK_TO_EXISTING_USERS=true

### NOTHING BELOW THIS LINE NEEDS TO CHANGE ###

# A dock plist placed in the User Template directory is applied to new user accounts.
USER_TEMPLATE_DOCK_PLIST="/System/Library/User Template/English.lproj/Library/Preferences/com.apple.dock.plist"

# Currently logged in user.
CURRENTLY_LOGGED_IN_USER=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )

if [[ "$APPLY_DOCK_TO_EXISTING_USERS" == "true" ]]
then
    # Output local home directory path (/Users/username).
    for USER_HOME in /Users/*
    do
        # Extract account name (a.k.a. username) from home directory path.
        ACCOUNT_NAME=$(/usr/bin/basename "${USER_HOME}")

        # If account name is not "Shared".
        if [[ "$ACCOUNT_NAME" != "Shared" ]]
        then
            USER_DOCK_PLIST="${USER_HOME}/Library/Preferences/com.apple.dock.plist"

            # If the account already contains a dock plist.
            if [[ -f "$USER_DOCK_PLIST" ]]
            then
                echo "Removing existing user dock plist."
                /usr/bin/defaults delete "$USER_DOCK_PLIST"
           fi

            echo "Copying the latest dock plist into place."
            cp "$USER_TEMPLATE_DOCK_PLIST" "$USER_DOCK_PLIST"

            echo "Updating permissions to match user (${ACCOUNT_NAME})."
            /usr/sbin/chown -R "$ACCOUNT_NAME" "$USER_DOCK_PLIST"

            # Reboot the dock if a user is currently logged in.
            if [[ "$CURRENTLY_LOGGED_IN_USER" == "$ACCOUNT_NAME" ]]
            then
                # Update cached dock plist.
                /usr/bin/sudo -u "$ACCOUNT_NAME" /usr/bin/defaults read "$USER_DOCK_PLIST"
                # Relaunch the dock process.
                /usr/bin/killall Dock
            fi
        fi
    done
fi

Just to confirm there is another script that creates the package when you download it called makepackage.command. From what I understand this creates the package and injects the postinstall script into it.

#!/bin/bash

# Name of the package.
NAME="officedock"

# Once installed the identifier is used as the filename for a receipt files in /var/db/receipts/.
IDENTIFIER="au.com.errorfreeit.dockmaster.${NAME}"

# Package version.
VERSION="1.0"

# The User Template directory is applied to new user accounts. The dock plist placed in this directory will be copied into new accounts.
INSTALL_LOCATION="/System/Library/User Template/English.lproj/Library/Preferences/"

# Change into the same directory as this script.
cd "$(/usr/bin/dirname "$0")"

# Store the path containing this script.
SCRIPT_PATH="$(pwd)"

# Build the package.
/usr/bin/pkgbuild \
    --root "${SCRIPT_PATH}/payload/" \
    --install-location "$INSTALL_LOCATION" \
    --scripts "$SCRIPT_PATH/scripts/" \
    --identifier "$IDENTIFIER" \
    --version "$VERSION" \
    "${SCRIPT_PATH}/package/${NAME}-${VERSION}.pkg"

Also just in case the error in jamf is this, doesn't give much info though.

[STEP 1 of 4]
Executing Policy Configure Dock
[STEP 2 of 4]
Downloading officedock-1.0.pkg...
Downloading https://casper-suite.brynmawr.edu/jamfshare/Packages/officedock-1.0.pkg...
Verifying package integrity...
Installing officedock-1.0.pkg...
Installation failed. The installer reported: installer: Package name is officedock-1.0
installer: Installing at base path /
installer: The install failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An unexpected error occurred while moving files to the final destination.)
[STEP 3 of 4]
[STEP 4 of 4]

 

Hi @rfloody 

DockMaster is also trying to make changes to the /System/Library/User Template/ in those scripts.

If you remove the /System from the paths relating to the User Template (leaving /Library/User Template/...) in the makepackage.command and postinstall scripts in addition to @emily's replacement for the python code to find the current user it appears to work, at least from my initial testing.  Honestly I am surprised that this was working on Monterey at all as there was a change back when the system volume became read only in Catalina:

https://derflounder.wordpress.com/2019/10/14/the-macos-user-template-directories-have-a-new-filesyst...

Hope this helps!

Update to this:  It seems to work correctly on existing users, but with new users, something is happening during the first login process that is adding Maps, Photos, News, Podcasts and Apple TV to the dock.  If I run the package again after user creation, the dock appears as expected.  I'm thinking about the best way to address this (We ran into the same issue on laptops in our loaner pool after they were updated) 

Are you having the policy run on enrollment complete? I have mine set to run on Recurring Check-In and scoped to a smart group with criteria being that the computer has all the apps I want to place in the dock. That way the policy won't run until the user is created and apps are installed. I also made the modification @emily suggested and it seems to work on my 12.4 test machine I'm running workflows on, thanks for that.

Thanks for this. I was having an issue where the user Dock was merging with my packaged one. I changed my policy to Recurring Check-In like you suggested and now the policy takes full effect.