Dockutil error but still completes

rqomsiya
Contributor III

HI all,

I have the following dockutil script. It completes, but throws these errors when I run in via terminal to test:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied

The script is below:

#!/bin/bash

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 + "
");'`

# Check for the presence of a file created by this script to determine if the Dock has already been configured and if so, exit
if [ -e /Users/$loggedInUser/Library/Preferences/com.cg.docksetup.plist ]; then
    echo "Dock already set up for user $loggedInUser, exiting..."
    exit 0
else
    echo "Dock has not been set up for user $loggedInUser, setting up now..."
    su - "$loggedInUser" -c '/usr/local/bin/dockutil --remove all --no-restart'
    sleep 1
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/Launchpad.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/Safari.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/Self Service.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/Google Chrome.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/Microsoft Office 2011/Microsoft Word.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/Microsoft Office 2011/Microsoft PowerPoint.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/Microsoft Office 2011/Microsoft Excel.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/Cisco/Cisco AnyConnect Secure Mobility Client.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/Microsoft Lync.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications/SecurID.app" --no-restart'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "/Applications"'
    su "$loggedInUser" -c '/usr/local/bin/dockutil --add  "~/Downloads"'
    # Create an empty file to signify that the Dock has been set up
    touch /Users/$loggedInUser/Library/Preferences/com.cg.docksetup.plist
    exit 0
fi

exit 0
0 REPLIES 0