Posted on 06-15-2016 07:00 AM
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?
Posted on 06-15-2016 07:04 AM
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.
Posted on 06-15-2016 07:07 AM
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
Posted on 06-15-2016 07:38 AM
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.
Posted on 06-20-2016 10:12 AM
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!
Posted on 06-20-2016 10:36 AM
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.
Posted on 06-20-2016 10:44 AM
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
Posted on 06-20-2016 12:32 PM
@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.
Posted on 06-20-2016 01:34 PM
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?
Posted on 06-20-2016 03:12 PM
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.
Posted on 06-21-2016 04:48 AM
@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?.
Posted on 06-22-2016 05:01 AM
@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).
Posted on 06-22-2016 05:13 AM
@mike.pinto Glad to hear you found the culprit!
Posted on 06-22-2016 06:52 AM
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.
Posted on 06-22-2016 07:49 AM
@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:
Posted on 06-23-2016 07:01 AM
@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
Posted on 06-23-2016 07:20 AM
@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
Posted on 06-23-2016 08:54 AM
@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.
Posted on 06-23-2016 12:05 PM
@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 $?
Posted on 06-23-2016 12:16 PM
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.
Posted on 06-23-2016 12:18 PM
@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.
Posted on 06-23-2016 09:17 PM
@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?
Posted on 06-24-2016 06:32 AM
@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 ?
Posted on 06-24-2016 08:15 AM
@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?
Posted on 06-24-2016 09:32 AM
@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 $?
Posted on 06-24-2016 12:20 PM
@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.
Posted on 06-24-2016 12:59 PM
A couple of ideas...
sleep 15
up before you set your variables. Sounds like there are some odd timing things going on, and the variables are getting set incorrectly, so maybe worth a shot.loggedInUser=`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 + "
");'`
loggedInUserHome="/Users/$loggedInUser"
I've been using that method for a while successfully, see here: obligatory Der Flounder or MacMule link found in all good JAMF Nation threads
Posted on 06-24-2016 01:00 PM
@stevewood I am using dockutil version 2.0.3 what version are you using ?
I was able to get a dockutil2_0_3.pkg from https://github.com/kcrawford/dockutil
i chose 'clone or download' and got the zip, unzipped it, and somehow was able to get the .pkg out of it. I use that .pkg to install on computers.
I can't seem to replicate how i got the .pkg out of the .zip
Version 2.0.3 notes says ; Wait for dock to be setup by Apple before modifying (useful for first login scripts). My script has a 15 second sleep before the --remove all
Posted on 06-24-2016 01:16 PM
@tcandela 2.0.2 here, but I seriously doubt that is the difference. I'll see if I can scratch some time to try that out.
Posted on 06-24-2016 01:20 PM
@stevewood not sure how i was able to get the 2_0_3.pkg out of it but I did. I cannot seem to duplicate whatever i did.
I'll try 2.0.2
i got if from here https://jamfnation.jamfsoftware.com/viewProduct.html?id=203&view=info
Posted on 06-24-2016 01:25 PM
There are releases that are pre pkg'd.
Posted on 06-24-2016 01:30 PM
@tcandela it is just a Python script, so creating the PKG yourself wouldn't be too difficult. Just save it to your hard drive and then use Packages or Composer or whatever packaging method you want, to create a PKG file of the Python script and then deploy that.
As far as getting 2.0.2, the only way would be for someone to get you a copy, I believe. If you want to send me an email (swood at integer dot com) I can send the 2.0.2 version to you. I don't want to post it here.
Posted on 06-24-2016 02:22 PM
@stevewood i got 2.0.2 dragged it from /usr/local/bin and dragged it into composer and did a build pkg.
I am going to deploy 2.0.2 on a test computer and see if it reacts different than 2.0.3 with those 3 dock items that will not go away for me.
@millersc i don't see a prepackage of 2.0.2
Posted on 06-24-2016 02:31 PM
@Josh.Smith I originally had sleep 15 before the variables, I had the same results. I am gonna try dockutil version 2.0.2
Posted on 06-24-2016 03:43 PM
@tcandela Check your bash variables. You have the UserPlist variable lines hashed out which directly point to the Dock plist (I assume from previous attempts so you can test other things), which is correct.
But then you use loggedInUserHome which only defines your user's user folder, not the full path to the user's Dock PLIST you want to change.
It seems to me that using $3 to get the loggedin user is your problem and on top of that your $loggedinUserHome is just that, not the full path to the Dock PLIST.
Posted on 06-25-2016 07:11 AM
@aporlebeke i've tried both ways, with the $loggedInUserHome and the $UserPlist, i get the same results
@stevewood says creating a variable to just the home folder will suffice. I've tried both ways anyways and still get the same results.
thats why you see so many # commenting out lines
I am going to test out dockutil 2.0.2 currently this is happening with 2.0.3
Posted on 08-16-2016 07:56 AM
tcandela,
I am having the same issue. Did you resolve this? Doesn't matter which way i grab the user/home varible. This isn't happening on my laptops though. Only the desktops. The only difference between the two is mobile account vs. just force local home.
Posted on 08-16-2016 01:26 PM
@TexasITAdmin no resolution so far. I still have the same three dock items appear at the end. I've tried dockutil 2.0.2 and 2.0.3 and get the same results. Version 2.0.4 is out but it looks like the changes will not make a difference.
better than nothing
Posted on 12-20-2016 12:18 PM
@aporlebeke. I'm new to Casper and DockUtil.
I'm trying to create a customized dock for our Public Lab Users. I borrowed your script and made a few edits for our setup. Thanks for sharing, it really helped me out a lot, and works as advertised.
The one thing I'm having a hard time with is the delay in which the customized dock builds after a user logs in. I have commented out the 'sleep 15' and 'sleep 20', but still have a 15 second delay for dockutil to build everything. This delay doesn't work in a lab situation. I need the customized dock to build immediately after the log in process. What can I do to speed this up even more?
Posted on 12-20-2016 12:37 PM
@ctarbox We have a similar situation as well with dockutil. There's a number of things that happen when a user logs in to a computer for the first time. From my experience, it just takes a bit of time for the computer to get around to running dockutil. It's faster on computers with SSDs.
Are you using a LaunchAgent to trigger your dockutil script, or something like outset?