Skip to main content
Question

Dock Items

  • June 15, 2016
  • 44 replies
  • 137 views

Forum|alt.badge.img+7

Hey All,

We're in the process of moving from MCX to config profiles, but I'm having a problem when it comes to the dock. I used mcxToProfile to convert the dock plists (all of our school sites have varying items) which worked great with the exception of the network home.

Normally, when using the UNC path (from within the AD plugin) the users network home will appear on the dock next to any other login items we have. However, when using the custom config profile, the network home is no longer there. The network home will reappear once I remove the config profile, so is there a simple way to add this? What am I missing?

44 replies

Forum|alt.badge.img+8
  • Contributor
  • June 15, 2016

I was having a similar issue when creating a dock profile with Dock Master. It would apply the entire dock but the folders i had assigned to the right side of the dock. When asking Jamf about this they said it was a bug and that they were looking into it. might want to check with your TAM to see if thats the same issue. I could be completely off though.


Forum|alt.badge.img+7
  • Contributor
  • June 15, 2016

Hi @mike.pinto

For conencting shares I use Share Connect:
https://github.com/amsysuk/public_scripts/tree/master/shareConnect

For mounting users network homes I use MountSMB:
https://github.com/amsysuk/public_scripts/tree/master/mount_SMBHome

Both are robust and pretty much always mount the shares or the user folder. I'd disregard any other method in favour of these, you will keep your hair that way.

Thanks to @daz_wallace


Forum|alt.badge.img+7
  • Contributor
  • June 15, 2016

Also I've found Dockmaster is extremely useful for labs but not anywhere else other than say kiosks.

If you've heard of DockUtil you can combine it with a JSS policy that kicks in at login to generate your Dock for each user of the machine. They can change it after, and you can change their Dock offering in a modular way say if you can'e 1 suite of apps but the rest of the items in the Dock are ok to remain.

To keep your Dock locked down and unchangeable a config profile is the best way to go.

Check out Dockutil here. For Dockutil heres a snip of a script I use to replace Office 2011 icons with Office 2016 icons using the login trigger from a JSS policy. I can't remember where I got this from but it works. Theres also lots if discussions about Dockutil on JamfNation.

#!/bin/bash

################################################################################
# Dock Icons change - for current user on this computer #
################################################################################

/bin/sleep 10
# Replace office 2011 Dock icons
/usr/local/bin/dockutil --add '/Applications/Microsoft Word.app' --replacing 'Microsoft Word' --allhomes
/bin/sleep 10
/usr/local/bin/dockutil --add '/Applications/Microsoft Excel.app' --replacing 'Microsoft Excel' --allhomes
/bin/sleep 10
/usr/local/bin/dockutil --add '/Applications/Microsoft PowerPoint.app' --replacing 'Microsoft PowerPoint' --allhomes
/bin/sleep 10
/usr/local/bin/dockutil --add '/Applications/Microsoft Outlook.app' --replacing 'Microsoft Outlook' --allhomes
/bin/sleep 10
/usr/local/bin/dockutil --add '/Applications/Microsoft OneNote.app' --replacing 'Microsoft OneNote' --allhomes

Hope this helps.


Forum|alt.badge.img+7
  • Author
  • Contributor
  • June 20, 2016

Thanks for the quick responses, I appreciate it. I did try using Dock Master, but I could only get it working on local accounts and would not work on mobile. If there is a quick solution to this then that would be great.

@sancheeto I'll check it out, thanks!


apizz
Forum|alt.badge.img+15
  • Honored Contributor
  • June 20, 2016

We were using the User Template with a dock plist to deploy our docks, but recently switched to dockutil. Definitely like the ease with which we can script and deploy changes to everyone's docks after the fact if we need to. Albeit, the script to configure the Dock ends up being a little long with all the various bash variables.

Still, I'm pleased with our shift to dockutil.


apizz
Forum|alt.badge.img+15
  • Honored Contributor
  • June 20, 2016

Also, here's our template script for use with dockutil @mike.pinto . I added some customizations to create a shortcut to our users' Active Directory home folder in the "others" portion of the Dock and some admin-specific apps for our local admin user account.

#!/bin/bash

DOCKUTIL="/usr/local/bin/dockutil"
APPLICATIONS="/Applications"
DOWNLOADS="~/Downloads"
MOUNTHOME="/Applications/MountHomeFolder.app"
LAUNCHPAD="/Applications/Launchpad.app"
SAFARI="/Applications/Safari.app"
CHROME="/Applications/Google Chrome.app"
ITUNES="/Applications/iTunes.app"
OUTLOOK="/Applications/Microsoft Outlook.app"
WORD="/Applications/Microsoft Word.app"
PPT="/Applications/Microsoft PowerPoint.app"
EXL="/Applications/Microsoft Excel.app"
VLC="/Applications/VLC.app"
SLFSRVC="/Applications/Masters Self Service.app"
SYSPRFS="/Applications/System Preferences.app"
SYSINFO="/Applications/Utilities/System Information.app"
DSKUTIL="/Applications/Utilities/Disk Utility.app"
TERMINAL="/Applications/Utilities/Terminal.app"
CONSOLE="/Applications/Utilities/Console.app"
ACTIVITYMON="/Applications/Utilities/Activity Monitor.app"
NETUTIL="/System/Library/CoreServices/Applications/Network Utility.app"
IBOOKS="/Applications/iBooks.app"
MAPS="/Applications/Maps.app"
PHOTOS="/Applications/Photos.app"
PAGES="/Applications/Pages.app"
KEYNOTE="/Applications/Keynote.app"
NUMBERS="/Applications/Numbers.app"
USER=$(who | grep console | awk '{print $1}')
USERDOCK="/Users/$USER/Library/Preferences/com.apple.dock.plist"
ADMINDOCK="/Users/admin/Library/Preferences/com.apple.dock.plist"
ADHOME=$(dscl . -read /Users/$USER 
        | grep -e "HomeFolder" | head -n 1 
        | sed 's|SMBHome:||g' 
        | sed 's|dsAttrTypeNative:original_smb_home:||g' 
        | sed 's/^[\\]*//' 
        | sed 's:\\:/:g' 
        | sed 's/ ////g' 
        | tr -d '
' 
        | sed 's/ /%20/g')
LOG="/Library/Logs/CompanyLogFolder/DockSetup.log"
RECEIPT="/Users/$USER/Library/Logs/DockSetup"

writelog()
{
    echo "${1}" "${2}" "${3}" "${4}"
    echo $(date) "${1}" "${2}" "${3}" "${4}" >> $LOG
}

writelog "STARTING: Checking for receipt ..."

if [ -f $RECEIPT ]; then
    writelog "FOUND RECEIPT: DockSetup already completed for ${USER}.  Exiting script ..."
    exit
else
    writelog "No Receipt found.  Checking for dockutil ..."
fi

if [ ! -f $DOCKUTIL ]; then
    writelog "VERIFIED: dockutil NOT installed ... Attempting to install now ..."
    sudo jamf policy -event installdockutil
    if [ -f $DOCKUTIL ]; then
        writelog "INSTALL: dockutil install successful!  Continuing script ..."
    else
        writelog "INSTALL: dockutil install failed!  Exiting ..."
        exit 1
    fi
else
    writelog "VERIFIED: dockutil installed!  Continuing script ..."
fi

if [ -f "${USERDOCK}" ]; then
    writelog "VERIFIED: User ${USER} has a Dock!  Continuing script ..."
else
    writelog "Dock not yet configured.  Waiting ..."
    sleep 10
    if [ ! -f "${USERDOCK}" ]; then
        writelog "Dock still not configured.  Waiting ..."
        sleep 15
    else
        writelog "VERIFIED: User ${USER} has a Dock!  Continuing script ..."
    fi
fi

if [ "${USER}" == "admin" ]; then
    writelog "IDENTIFIED: User is local admin.  Setting custom admin Dock ..."
    sleep 15
    $DOCKUTIL --remove all --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$APPLICATIONS" --view grid --display folder --sort name --section others --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$SYSPRFS" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$SLFSRVC" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$SYSPRFS" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$NETUTIL" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$CONSOLE" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$ACTIVITYMON" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$TERMINAL" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$DSKUTIL" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$SYSINFO" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$CHROME" --position beginning --section apps --no-restart "$ADMINDOCK"
    $DOCKUTIL --add "$SAFARI" --position beginning --section apps --no-restart "$ADMINDOCK"
    writelog "Custom admin apps added to Dock"
else
    # Setup Base USFAC Dock
    writelog "Preparing to add applications to ${USER}s Dock ..."
    sleep 20
    writelog "Removing all existing apps from ${USER}s Dock ..."
    $DOCKUTIL --remove all --no-restart "$USERDOCK"
    writelog "Adding apps ..."
    $DOCKUTIL --add "$APPLICATIONS" --view grid --display folder --sort name --section others --no-restart "$USERDOCK"
    $DOCKUTIL --add "$SYSPRFS" --position beginning --section apps --no-restart "$USERDOCK"        
    $DOCKUTIL --add "$SLFSRVC" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$MOUNTHOME" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$VLC" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$NUMBERS" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$KEYNOTE" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$PAGES" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$EXL" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$PPT" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$WORD" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$ITUNES" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$CHROME" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$SAFARI" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$OUTLOOK" --position beginning --section apps --no-restart "$USERDOCK"
    $DOCKUTIL --add "$LAUNCHPAD" --position beginning --section apps --no-restart "$USERDOCK"
    writelog "Apps added to ${USER}s Dock!"
fi

# Add user's HOME folder to dock for easier access
if [ "${ADHOME}" == "" ]; then
    writelog "ADHOME Shortcut: User ${USER} does not have an SMBHome attribute. Skipping HOME folder Dock shortcut creation ..."
else
    writelog "FOUND: SMBHome identified for ${USER}"
    writelog "Creating HOMEFOLDER Dock shortcut for ${USER}"
    $DOCKUTIL --add "smb://${ADHOME}" --label "My HOMEFOLDER Folder" --before Applications --no-restart "$USERDOCK"
    writelog "CREATED: HOMEFOLDER folder Dock shortcut for ${USER}"
fi

# Fix ~/Downloads folder for user
writelog "Fixing ${USER}s ${DOWNLOADS} ..."
$DOCKUTIL --remove Downloads --no-restart "$USERDOCK"
$DOCKUTIL --add "$DOWNLOADS" --view grid --display folder --sort dateadded --after Applications "$USERDOCK"
writelog "Fixed ${DOWNLOADS} for ${USER}"



writelog "SUCCESS: Dock setup completed.  Printing completion receipt for ${USER} ..."
echo "COMPLETE" > $RECEIPT
writelog "DONE: DockSetup completed for ${USER}!"

exit

Forum|alt.badge.img+7
  • Author
  • Contributor
  • June 20, 2016

@aporlebeke I've been trying to get it working, but have been running into the same issue that I had with Dock Master in that it will only work on local accounts. Does this work for you with mobile accounts? I must be missing something.


apizz
Forum|alt.badge.img+15
  • Honored Contributor
  • June 20, 2016

Curious, @mike.pinto because we use mobile accounts and I've had no problems with the script. We use Active Directory.

Looking back at your earlier posts, I see you were using the UNC path. A lot of other users on here, myself included, have had issues with this setting enabled, so make sure that's turned off.

How are you running the script, as a particular user or straight from the JSS?


Forum|alt.badge.img+7
  • Author
  • Contributor
  • June 20, 2016

That's odd, @aporlebeke since we've never had a problem with the UNC path. I'll try turning it off and seeing what results I get though. It's just weird since it ignores the local dock plist and pulls the plist from /Library/Managed Preferences/currentuser/ instead. Is this the expected result when using mobile accounts?

I tried as both a policy and a login script.


apizz
Forum|alt.badge.img+15
  • Honored Contributor
  • June 21, 2016

@mike.pinto The UNC path setting issues IIRC is more to do with Active Directory environments.

I'm not as familiar with the nuances of mobile accounts as I should be, but I do know that when our users login to our machines it stores the mobile account locally in /Users.

Is it that the script doesn't create the Dock Plist at all in the mobile accounts' ~/Library/Preferences folder, or that the Managed Preferences/currentuser/ is overriding the dock configuration?

I'm curious as to the settings used when configuring your mobile accounts and if you any Managed Preference settings or Configuration Profiles on your JSS that could be overriding where your mobile accounts pull the com.apple.dock.plist from?.


Forum|alt.badge.img+7
  • Author
  • Contributor
  • June 22, 2016

@aporlebeke This is an AD environment and luckily have not really seen many issues using the UNC path setting.

That's what I don't understand since our mobile accounts are stored in the same place (/Users). It does create the plist in ~/Library/Preferences but the plist in Managed Preferences is taking precedence.

I have removed all configuration profiles along with the UNC path and still have the same issue.

EDIT: It appears there was an attribute in AD that was causing this issue (apple-mcxsettings).


apizz
Forum|alt.badge.img+15
  • Honored Contributor
  • June 22, 2016

@mike.pinto Glad to hear you found the culprit!


Forum|alt.badge.img+20
  • Contributor
  • June 22, 2016

I finally got dockutil to work but from my experience so far using it in 10.11 it will not remove Maps, Photos, iBooks from the dock.

I have a -remove all to start my dock process but those 3 items still appear

i do explicit removes of those 3 items and they still appear

The JSS dock policy creation is all Flaky, especially if the trigger is Login.

A lot of stuff that should be easily configured doesn't consistently work, I wish JAMF would step it up and fix these issues.


stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • June 22, 2016

@tcandela What I have found is that when using the --no-restart flag with dockutil, it is necessary to sleep the script for a few seconds between removes. So a simple sleep 2 between each one should suffice.

I also remove everything and start over. My complete dock script that I run via Self Service on a new user's machine is on my GitHub here and here:

#!/bin/sh

# Name: fixDock.sh
# Purpose:  to set the initial dock configuration for new users
# Date:  28 February 2014
# Updated: 22 Jun 2016
#   - changed how home folder is derived
# Author:  Steve Wood (swood@integer.com)

# Set Global Variables
# set the user folder to work on
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
myUserHome=$(dscl . read /Users/$loggedInUser NFSHomeDirectory | awk '{print $NF}')

shortModel=`system_profiler SPHardwareDataType | grep 'Model Name:' | awk '{ print $3 }'`
# set the path to dockutil
du='<path to where you store dockutil>'

$du --remove all $myUserHome
$du --add "/Applications/Self Service.app" $myUserHome
$du --add "/Applications/Launchpad.app" $myUserHome
$du --add "/Applications/System Preferences.app" $myUserHome
$du --add "/Applications/Firefox.app" $myUserHome
$du --add "/Applications/Google Chrome.app" $myUserHome
$du --add "/Applications/Safari.app" $myUserHome
$du --add "/Applications/Microsoft Office 2011/Microsoft Excel.app" $myUserHome
$du --add "/Applications/Microsoft Office 2011/Microsoft Word.app" $myUserHome
$du --add "/Applications/Microsoft Office 2011/Microsoft PowerPoint.app" $myUserHome

if [[ -d "/Applications/Universal Type Client.app" ]]; then
    $du --add "/Applications/Universal Type Client.app" $myUserHome
fi

$du --add "/Applications/Adobe Illustrator CC 2014/Adobe Illustrator.app" $myUserHome
$du --add "/Applications/Adobe InDesign CC 2014/Adobe InDesign CC 2014.app" $myUserHome
$du --add "/Applications/Adobe Photoshop CC 2014/Adobe Photoshop CC 2014.app" $myUserHome
$du --add "/Applications/Adobe Acrobat XI Pro/Adobe Acrobat Pro.app" $myUserHome

if [[ $shortModel == "MacBook" ]]; then
    $du --add "/Applications/Cisco/Cisco AnyConnect Secure Mobility Client.app" $myUserHome
fi

$du --add '~/Downloads' --view grid --display folder $myUserHome
$du --add '/Applications' --view grid --display folder $myUserHome

You can also find a discussion about running dockutil at login not firing properly on 10.11 unless you wait for the OS to "settle down". That discussion is here:

DockUtil doesn't work when run through LaunchAgent


Forum|alt.badge.img+20
  • Contributor
  • June 23, 2016

@stevewood no matter where I put Sleep 10 or remove the --no-restart those 3 dock items (iBooks, Maps, Photos) do not want to go away. I just have one --remove all and the rest is --add with --no-restart for each but the last one. Here is a sample part of the dockutil script i made. Afterwards When i go to the terminal and run dockutil --remove 'Maps' etc.. for the 3 dock items, they dissapear

sleep 20

LoggedInUser=$3
LoggedInUserHome="/Users/$3"
UserPlist=$LoggedInUserHome/Library/Preferences/com.apple.dock.plist

echo "Logged in user is = $LoggedInUser" 
echo "Logged in user's home = $LoggedInUserHome"
echo "UserPlist =  $UserPlist"

# /path/to/dockutil.py --add /Applications/Self Service.app --position 2 --allhomes
# /path/to/dockutil.py --move 'App Store' --position 3 --allhomes
# /path/to/dockutil.py --add /Applications/Google Chrome.app --position 4 --allhomes
# /path/to/dockutil.py --remove 'Safari' --allhomes
# /path/to/dockutil.py --remove 'Mail' --allhomes


######## REMOVE FROM DOCK
/usr/local/bin/dockutil --remove all $UserPlist
sleep 10
# /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
######## ADD TO DOCK
/usr/local/bin/dockutil --add /Applications/Launchpad.app --position 1 --no-restart $UserPlist
/usr/local/bin/dockutil --add /Applications/Self Service.app --position 2 --no-restart $UserPlist
/usr/local/bin/dockutil --add /Applications/Safari.app --position 3 --no-restart $UserPlist
/usr/local/bin/dockutil --add /Applications/Google Chrome.app --position 4 --no-restart $UserPlist

Forum|alt.badge.img+20
  • Contributor
  • June 23, 2016

@stevewood at the end of the script when i explicitly add --remove for those 3 dock items, here is what the JSS log says

Script result: Logged in user is = test5
Logged in user's home = /Users/test5
UserPlist = /Users/test5/Library/Preferences/com.apple.dock.plist
item /Applications/Maps.app was not found in /Users/test5/Library/Preferences/com.apple.dock.plist
item /Applications/Photos.app was not found in /Users/test5/Library/Preferences/com.apple.dock.plist
item /Applications/iBooks.app was not found in /Users/test5/Library/Preferences/com.apple.dock.plist


stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • June 23, 2016

@tcandela I copied your script into my JSS, setup a new policy, and then ran this against a test user logging into one of my VMs. I had the same results you had, those three apps stayed in the dock.

I then changed how I determined the logged in user and home folder to be my method:

loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
myUserHome=$(dscl . read /Users/$loggedInUser NFSHomeDirectory | awk '{print $NF}')

And changed the dockutil lines to use $myUserHome as the variable. Using this method, I was able to get those three apps to disappear and the 4 apps added to the dock.

I would change your PLIST line to just be the home folder location. IIRC you do not need to specify down to the dock plist file, just the user's home folder.


Forum|alt.badge.img+20
  • Contributor
  • June 23, 2016

@stevewood no matter what, I still get the same results. Those 3 dock items stay.

LoggedInUser=$3
LoggedInUserHome="/Users/$3"
# UserPlist=$LoggedInUserHome/Library/Preferences/com.apple.dock.plist

#loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
#myUserHome=$(dscl . read /Users/$loggedInUser NFSHomeDirectory | awk '{print $NF}')

echo "Logged in user is = $LoggedInUser" 
echo "Logged in user's home = $LoggedInUserHome"
# echo "UserPlist =  $UserPlist"

######## REMOVE FROM DOCK
/usr/local/bin/dockutil --remove all $LoggedInUserHome
sleep 5

######## ADD TO DOCK
/usr/local/bin/dockutil --add /Applications/Launchpad.app --position 2 --no-restart $LoggedInUserHome
/usr/local/bin/dockutil --add /Applications/Self Service.app --position 3 --no-restart $LoggedInUserHome
/usr/local/bin/dockutil --add /Applications/Safari.app --position 4 --no-restart $LoggedInUserHome
/usr/local/bin/dockutil --add /Applications/Google Chrome.app --position 5 --no-restart $LoggedInUserHome
/usr/local/bin/dockutil --add /Applications/Firefox.app --position 6 --no-restart $LoggedInUserHome
# /usr/local/bin/dockutil --add /Applications/IBM/SPSS/Statistics/24/SPSSStatistics.app --label 'SPSS24' --position 5 --no-restart $LoggedInUserHome
/usr/local/bin/dockutil --add /Applications/Microsoft Excel.app --position 7 --no-restart $LoggedInUserHome
/usr/local/bin/dockutil --add /Applications/Microsoft PowerPoint.app --position 8 --no-restart $LoggedInUserHome
/usr/local/bin/dockutil --add /Applications/Microsoft Word.app --position 9 --no-restart $LoggedInUserHome
/usr/local/bin/dockutil --add /Applications/Adobe Acrobat XI Pro/Adobe Acrobat Pro.app --position 10 --no-restart $LoggedInUserHome

/usr/local/bin/dockutil --add '~/Downloads' --view grid --display folder $LoggedInUserHome

exit $?

Forum|alt.badge.img+10
  • New Contributor
  • June 23, 2016

I couldn't get Dockutil 2.0.2 or 2.0.3 to work with 10.10.x with any reliability at all. So we've started testing in our dev 9.92 with outset (because login triggers don't work) and 2.0.3 and 10.11.5 and so far testing is very positive.


Forum|alt.badge.img+20
  • Contributor
  • June 23, 2016

@stevewood when i use your logged in user code i get the following in the policy log

Script exit code: 1
Script result: Logged in user is = root
Logged in user's home = /var/root
/var/root/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist
[message repeats 10 times]
Error running script: return code was 1.


apizz
Forum|alt.badge.img+15
  • Honored Contributor
  • June 24, 2016

@tcandela Those 3 dock items are part of Dockfixup, which puts those three apps as part of the Dock. Not sure why Apple has it setup this way, but to get around this I make sure to have the script run as part of a login policy but put a sleep 10/15 before any dock removal or dock additions with dockutil in our script occurs.

Since making this addition I haven't had any issues with our dockutil setup policy successfully removing everything (including iBooks, Maps, and Photos) from the Dock.

As for the logged in user result, I would expect your result to be root if that were your management account and your dockutil was being run from your JSS withe loggedInUser variable = $3. You're saying even when you change your loggedinuser variable to be /bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }' you get this error?


Forum|alt.badge.img+20
  • Contributor
  • June 24, 2016

@aporlebeke @stevewood I have the script also running at Login

when I use the 2 lines of code below, I get the error (when using $myUserHome at the end of each dockutil line). But I'm logging in - for example Bob

loggedInUser=/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'
myUserHome=$(dscl . read /Users/$loggedInUser NFSHomeDirectory | awk '{print $NF}')

Script exit code: 1
Script result: Logged in user is = root
Logged in user's home = /var/root
/var/root/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist
[message repeats 10 times]
Error running script: return code was 1.

When I change it back to

LoggedInUser=$3
LoggedInUserHome="/Users/$3"

and use $LoggedInUserHome at the end of each Dockutil line, it works, but those 3 dock items always appear.

I have a Sleep 20 before my /usr/local/bin/dockutil --remove all $LoggedInUserHome
and a sleep 5 after. Then all my --add begin with no sleep in between adds.

@aporlebeke are you doing the bulk --remove all ? or individual application --remove ? are you doing a --no-restart for each add? then sleep after each add ?


stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • June 24, 2016

@tcandela can you try pasting this exact script into your JSS and trying it? I ran this 6 times on 6 different users in a VM, and each time all icons were removed and the 4 icons were added back in:

#!/bin/bash
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
myUserHome=$(dscl . read /Users/$loggedInUser NFSHomeDirectory | awk '{print $NF}')

/usr/local/bin/dockutil --remove all $myUserHome
/usr/local/bin/dockutil --add /Applications/Launchpad.app --position 1 --no-restart $myUserHome
/usr/local/bin/dockutil --add /Applications/Self Service.app --position 2 --no-restart $myUserHome
/usr/local/bin/dockutil --add /Applications/Safari.app --position 3 --no-restart $myUserHome
/usr/local/bin/dockutil --add /Applications/Google Chrome.app --position 4 $myUserHome

What results do you get?


Forum|alt.badge.img+20
  • Contributor
  • June 24, 2016

@stevewood @aporlebeke here is my complete script. no matter what logged in user code is used, the 3 dock items are always there.

when I substitute the logged in user code with the once specified by @stevewood I get this in the policy results (and the dock does not change, it's the default dock)
Script exit code: 0
Script result: Logged in user is = root
Logged in user's home = /var/root
/var/root/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist
[message repeats 10 times]

#!/bin/sh

# 6/21/2016
# El Capitan dock with Office 2016

loggedInUser=$3
loggedInUserHome="/Users/$3"
# UserPlist=$LoggedInUserHome/Library/Preferences/com.apple.dock.plist

echo "Logged in user is = $loggedInUser" 
echo "Logged in user's home = $loggedInUserHome"
# echo "UserPlist =  $UserPlist"

# loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
# loggedInUserHome=$(dscl . read /Users/$loggedInUser NFSHomeDirectory | awk '{print $NF}')


######## REMOVE FROM DOCK
# /usr/local/bin/dockutil --remove all $UserPlist
sleep 15
/usr/local/bin/dockutil --remove all $loggedInUserHome
sleep 5
# /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

######## ADD TO DOCK
/usr/local/bin/dockutil --add /Applications/Launchpad.app --position 2 --no-restart $loggedInUserHome
sleep 2
/usr/local/bin/dockutil --add /Applications/Self Service.app --position 3 --no-restart $loggedInUserHome
sleep 2
/usr/local/bin/dockutil --add /Applications/Safari.app --position 4 --no-restart $loggedInUserHome
sleep 2
/usr/local/bin/dockutil --add /Applications/Google Chrome.app --position 5 --no-restart $loggedInUserHome
sleep 2
/usr/local/bin/dockutil --add /Applications/Firefox.app --position 6 --no-restart $loggedInUserHome
sleep 2
# /usr/local/bin/dockutil --add /Applications/IBM/SPSS/Statistics/24/SPSSStatistics.app --label 'SPSS24' --position 5 --no-restart $LoggedInUserHome
/usr/local/bin/dockutil --add /Applications/Microsoft Excel.app --position 7 --no-restart $loggedInUserHome
sleep 2
/usr/local/bin/dockutil --add /Applications/Microsoft PowerPoint.app --position 8 --no-restart $loggedInUserHome
sleep 2
/usr/local/bin/dockutil --add /Applications/Microsoft Word.app --position 9 --no-restart $loggedInUserHome
sleep 2
/usr/local/bin/dockutil --add /Applications/Adobe Acrobat XI Pro/Adobe Acrobat Pro.app --position 10 --no-restart $loggedInUserHome
sleep 2
/usr/local/bin/dockutil --add '~/Downloads' --view grid --display folder $loggedInUserHome
sleep 2

# if [[ -d "/Applications/Universal Type Client.app" ]]; then
#    /usr/local/bin/dockutil --add "/Applications/Universal Type Client.app" $loggedInUserHome
# fi

exit $?

stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • June 24, 2016

@tcandela Well, I took what you posted and put it into my JSS completely as is and had no problem. I ran it several times in a VM and each time the three apps were removed and icons for all of the items you have listed showed up properly. This was on a 10.11 VM.

The only thing I can think that we haven't asked is what version of dockutil are you running? It's the only thing I can think that could be causing the issue.

Sorry I couldn't help you come up with an answer.